summaryrefslogtreecommitdiffstats
path: root/generic/tkMain.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2019-09-09 11:39:10 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2019-09-09 11:39:10 (GMT)
commit590874e4b5506769cb27c6c379322472a3202d69 (patch)
tree8d856f06abf715923253141125eb81a3fde6b332 /generic/tkMain.c
parent6b1e4d50360b4bea599ade86d9b7bd21cc9fa45d (diff)
parente10bb27a8620007b685ce66d2041f05fad492ce6 (diff)
downloadtk-590874e4b5506769cb27c6c379322472a3202d69.zip
tk-590874e4b5506769cb27c6c379322472a3202d69.tar.gz
tk-590874e4b5506769cb27c6c379322472a3202d69.tar.bz2
Simplify NewNativeObj() function in tkMain.c, since "length" is always -1
Diffstat (limited to 'generic/tkMain.c')
-rw-r--r--generic/tkMain.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/generic/tkMain.c b/generic/tkMain.c
index 007903c..3a9b4a1 100644
--- a/generic/tkMain.c
+++ b/generic/tkMain.c
@@ -78,19 +78,15 @@ extern const TclIntPlatStubs *tclIntPlatStubsPtr;
static inline Tcl_Obj *
NewNativeObj(
- TCHAR *string,
- int length)
+ TCHAR *string)
{
Tcl_Obj *obj;
Tcl_DString ds;
#ifdef UNICODE
- if (length > 0) {
- length *= sizeof(WCHAR);
- }
- Tcl_WinTCharToUtf(string, length, &ds);
+ Tcl_WinTCharToUtf(string, -1, &ds);
#else
- Tcl_ExternalToUtfDString(NULL, (char *) string, length, &ds);
+ Tcl_ExternalToUtfDString(NULL, (char *) string, -1, &ds);
#endif
obj = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds));
Tcl_DStringFree(&ds);
@@ -270,19 +266,19 @@ Tk_MainEx(
if ((argc > 3) && (0 == _tcscmp(TEXT("-encoding"), argv[1]))
&& (TEXT('-') != argv[3][0])) {
- Tcl_Obj *value = NewNativeObj(argv[2], -1);
- Tcl_SetStartupScript(NewNativeObj(argv[3], -1), Tcl_GetString(value));
+ Tcl_Obj *value = NewNativeObj(argv[2]);
+ Tcl_SetStartupScript(NewNativeObj(argv[3]), Tcl_GetString(value));
Tcl_DecrRefCount(value);
argc -= 3;
argv += 3;
} else if ((argc > 1) && (TEXT('-') != argv[1][0])) {
- Tcl_SetStartupScript(NewNativeObj(argv[1], -1), NULL);
+ Tcl_SetStartupScript(NewNativeObj(argv[1]), NULL);
argc--;
argv++;
} else if ((argc > 2) && (length = _tcslen(argv[1]))
&& (length > 1) && (0 == _tcsncmp(TEXT("-file"), argv[1], length))
&& (TEXT('-') != argv[2][0])) {
- Tcl_SetStartupScript(NewNativeObj(argv[2], -1), NULL);
+ Tcl_SetStartupScript(NewNativeObj(argv[2]), NULL);
argc -= 2;
argv += 2;
}
@@ -290,7 +286,7 @@ Tk_MainEx(
path = Tcl_GetStartupScript(&encodingName);
if (path == NULL) {
- appName = NewNativeObj(argv[0], -1);
+ appName = NewNativeObj(argv[0]);
} else {
appName = path;
}
@@ -302,7 +298,7 @@ Tk_MainEx(
argvPtr = Tcl_NewListObj(0, NULL);
while (argc--) {
- Tcl_ListObjAppendElement(NULL, argvPtr, NewNativeObj(*argv++, -1));
+ Tcl_ListObjAppendElement(NULL, argvPtr, NewNativeObj(*argv++));
}
Tcl_SetVar2Ex(interp, "argv", NULL, argvPtr, TCL_GLOBAL_ONLY);