diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-09-16 07:41:01 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-09-16 07:41:01 (GMT) |
commit | b759c79faef78af4298e356f590b3d3a35b5ae01 (patch) | |
tree | 086c86b546650518426dcc5803be311f66cb3831 /generic/tkMain.c | |
parent | 79f10dcb586890630b25aa27250f270b39125713 (diff) | |
download | tk-b759c79faef78af4298e356f590b3d3a35b5ae01.zip tk-b759c79faef78af4298e356f590b3d3a35b5ae01.tar.gz tk-b759c79faef78af4298e356f590b3d3a35b5ae01.tar.bz2 |
Simplify NewNativeObj(), since its last parameter is always -1.
Change Tcl_StringMatch() calls to Tcl_StringCaseMatch()
A few end-of-line unnecessary spacings.
Diffstat (limited to 'generic/tkMain.c')
-rw-r--r-- | generic/tkMain.c | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/generic/tkMain.c b/generic/tkMain.c index b80ce4d..f0b7b3e 100644 --- a/generic/tkMain.c +++ b/generic/tkMain.c @@ -86,19 +86,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); @@ -244,7 +240,7 @@ Tk_MainEx( is.gotPartial = 0; Tcl_Preserve(interp); -#if defined(_WIN32) && !defined(__CYGWIN__) +#if defined(_WIN32) #if !defined(STATIC_BUILD) /* If compiled for Win32 but running on Cygwin, don't use console */ if (!tclStubsPtr->reserved9) @@ -278,19 +274,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; } @@ -298,7 +294,7 @@ Tk_MainEx( path = Tcl_GetStartupScript(&encodingName); if (path == NULL) { - appName = NewNativeObj(argv[0], -1); + appName = NewNativeObj(argv[0]); } else { appName = path; } @@ -310,7 +306,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); @@ -440,7 +436,7 @@ StdinProc( count = Tcl_Gets(chan, &isPtr->line); - if (count < 0 && !isPtr->gotPartial) { + if (count == -1 && !isPtr->gotPartial) { if (isPtr->tty) { Tcl_Exit(0); } else { |