Index: generic/tclStringObj.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclStringObj.c,v
retrieving revision 1.130
diff -u -r1.130 tclStringObj.c
--- generic/tclStringObj.c	30 Sep 2009 03:11:26 -0000	1.130
+++ generic/tclStringObj.c	18 Jan 2010 01:31:51 -0000
@@ -1864,6 +1864,7 @@
 	 */
 
 	segment = objv[objIndex];
+	numChars = -1;
 	if (ch == 'i') {
 	    ch = 'd';
 	}
@@ -1872,11 +1873,14 @@
 	    msg = "format string ended in middle of field specifier";
 	    goto errorMsg;
 	case 's': {
-	    numChars = Tcl_GetCharLength(segment);
-	    if (gotPrecision && (precision < numChars)) {
-		segment = Tcl_GetRange(segment, 0, precision - 1);
-		Tcl_IncrRefCount(segment);
-		allocSegment = 1;
+	    if (gotPrecision) {
+		numChars = Tcl_GetCharLength(segment);
+		if (precision < numChars) {
+		    segment = Tcl_GetRange(segment, 0, precision - 1);
+		    numChars = precision;
+		    Tcl_IncrRefCount(segment);
+		    allocSegment = 1;
+		}
 	    }
 	    break;
 	}
@@ -2261,8 +2265,10 @@
 	}
 	}
 
-	numChars = Tcl_GetCharLength(segment);
-	if (!gotMinus) {
+	if ((width > 0) && (numChars < 0)) {
+	    numChars = Tcl_GetCharLength(segment);
+	}
+	if ((!gotMinus) && (width > 0)) {
 	    if (numChars < width) {
 		limit -= (width - numChars);
 	    }
@@ -2282,12 +2288,14 @@
 	if (allocSegment) {
 	    Tcl_DecrRefCount(segment);
 	}
-	if (numChars < width) {
-	    limit -= (width - numChars);
-	}
-	while (numChars < width) {
-	    Tcl_AppendToObj(appendObj, (gotZero ? "0" : " "), 1);
-	    numChars++;
+	if (width > 0) {
+	    if (numChars < width) {
+		limit -= (width - numChars);
+	    }
+	    while (numChars < width) {
+		Tcl_AppendToObj(appendObj, (gotZero ? "0" : " "), 1);
+		numChars++;
+	    }
 	}
 
 	objIndex += gotSequential;
