summaryrefslogtreecommitdiffstats
path: root/generic/tclStringObj.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2005-09-14 21:32:16 (GMT)
committerdgp <dgp@users.sourceforge.net>2005-09-14 21:32:16 (GMT)
commit62b5bf66c2c8dda87b14b78f81bc58a02cdfb172 (patch)
tree82a5606aa3a2ef7d0ea577afdb0814e7a2a96e48 /generic/tclStringObj.c
parentdc74c2b374a963186c53482685a2c91773ade3da (diff)
downloadtcl-62b5bf66c2c8dda87b14b78f81bc58a02cdfb172.zip
tcl-62b5bf66c2c8dda87b14b78f81bc58a02cdfb172.tar.gz
tcl-62b5bf66c2c8dda87b14b78f81bc58a02cdfb172.tar.bz2
* generic/tclStringObj.c: Bug fixes: ObjPrintfVA needed to
support "*" fields and needed to interpret precision limits on %s conversions as a maximum number of bytes, not Tcl_UniChars, to take from the (char *) argument. * generic/tclBasic.c: Updated several callers to use * generic/tclCkalloc.c: TclFormatToErrorInfo() and/or * generic/tclCmdAH.c: TclObjPrintf(). * generic/tclCmdIL.c: * generic/tclCmdMZ.c: * generic/tclDictObj.c: * generic/tclExecute.c: * generic/tclIORChan.c: * generic/tclIOUtil.c: * generic/tclNamesp.c: * generic/tclProc.c:
Diffstat (limited to 'generic/tclStringObj.c')
-rw-r--r--generic/tclStringObj.c17
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':