From 6ba55114e28426856f8905b08e31340c268459d5 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 11 Aug 2019 21:17:35 +0000 Subject: Fix handling of length (size_t)-1 in tclMain.c. This should fix handling of command-line arguments with TCL_UTF_MAX=6, necessary to make tclsh run at all ... --- generic/tclMain.c | 2 +- generic/tclUtf.c | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/generic/tclMain.c b/generic/tclMain.c index ea69b2d..31e6438 100644 --- a/generic/tclMain.c +++ b/generic/tclMain.c @@ -70,7 +70,7 @@ NewNativeObj( Tcl_DString ds; #ifdef UNICODE - if (length > 0) { + if (length != TCL_AUTO_LENGTH) { length *= sizeof(WCHAR); } Tcl_WinTCharToUtf(string, length, &ds); diff --git a/generic/tclUtf.c b/generic/tclUtf.c index e27e465..c3b5163 100644 --- a/generic/tclUtf.c +++ b/generic/tclUtf.c @@ -276,7 +276,8 @@ TclWCharToUtfDString( { const WCHAR *w, *wEnd; char *p, *string; - int oldLength, len = 1; + size_t oldLength; + int len = 1; /* * UTF-8 string length in bytes will be <= Unicode string length * 4. @@ -644,14 +645,14 @@ TclUtfToWCharDString( { WCHAR ch = 0, *w, *wString; const char *p, *end; - int oldLength; + size_t oldLength; if (length == TCL_AUTO_LENGTH) { length = strlen(src); } /* - * Unicode string length in Tcl_UniChars will be <= UTF-8 string length in + * Unicode string length in WCHARs will be <= UTF-8 string length in * bytes. */ -- cgit v0.12