SHA256
1
0
forked from pool/tcl
tcl/tcl-format.patch

39 lines
1.3 KiB
Diff

Index: generic/tclStringObj.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclStringObj.c,v
retrieving revision 1.70
diff -u -r1.70 tclStringObj.c
--- generic/tclStringObj.c 28 Feb 2008 17:36:49 -0000 1.70
+++ generic/tclStringObj.c 7 Apr 2008 15:12:36 -0000
@@ -2003,8 +2003,8 @@
allocSegment = 1;
Tcl_IncrRefCount(segment);
- if ((isNegative || gotPlus) && (useBig || (ch == 'd'))) {
- Tcl_AppendToObj(segment, (isNegative ? "-" : "+"), 1);
+ if ((isNegative || gotPlus || gotSpace) && (useBig || (ch == 'd'))) {
+ Tcl_AppendToObj(segment, (isNegative ? "-" : gotPlus ? "+" : " "), 1);
}
if (gotHash) {
Index: tests/format.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/format.test,v
retrieving revision 1.25
diff -u -r1.25 format.test
--- tests/format.test 10 Jan 2008 16:09:23 -0000 1.25
+++ tests/format.test 7 Apr 2008 15:12:36 -0000
@@ -496,6 +496,12 @@
test format-15.4 {testing %0..s 0 padding for chars/strings} {
format %05c 61
} {0000=}
+test format-15.5 {testing %d space padding for integers} {
+ format "(% 1d) (% 1d)" 10 -10
+} {( 10) (-10)}
+test format-15.6 {testing %d plus padding for integers} {
+ format "(%+1d) (%+1d)" 10 -10
+} {(+10) (-10)}
set a "0123456789"
set b ""