diff options
Diffstat (limited to 'generic/tclStringObj.c')
-rw-r--r-- | generic/tclStringObj.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c index a2bce94..d5aa6d8 100644 --- a/generic/tclStringObj.c +++ b/generic/tclStringObj.c @@ -33,7 +33,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclStringObj.c,v 1.46 2005/09/14 17:13:18 dgp Exp $ */ + * RCS: @(#) $Id: tclStringObj.c,v 1.47 2005/09/14 21:32:17 dgp Exp $ */ #include "tclInt.h" @@ -2305,13 +2305,19 @@ ObjPrintfVA( case '\0': seekingConversion = 0; break; - case 's': + case 's': { + char *bytes = va_arg(argList, char *); seekingConversion = 0; if (gotPrecision) { - numBytes = lastNum; + char *end = bytes + lastNum; + char *q = bytes; + while ((q < end) && (*q != '\0')) { + q++; + } + numBytes = (int)(q - bytes); } - Tcl_ListObjAppendElement(NULL, list, Tcl_NewStringObj( - va_arg(argList, char *), numBytes)); + Tcl_ListObjAppendElement(NULL, list, + Tcl_NewStringObj(bytes , numBytes)); /* We took no more than numBytes bytes from the (char *). * In turn, [format] will take no more than numBytes * characters from the Tcl_Obj. Since numBytes characters @@ -2319,6 +2325,7 @@ ObjPrintfVA( * will have no effect and we can just pass it through. */ break; + } case 'c': case 'i': case 'u': |