summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1993-11-11 14:51:57 (GMT)
committerGuido van Rossum <guido@python.org>1993-11-11 14:51:57 (GMT)
commit6938a297dafc4d1809938f5be38c4afa475e776e (patch)
tree4909de405e5c98f169ed8031e2934e01fe3ef322
parentb31c7f732aea6abf6ce24d3da7fd67b2172acec9 (diff)
downloadcpython-6938a297dafc4d1809938f5be38c4afa475e776e.zip
cpython-6938a297dafc4d1809938f5be38c4afa475e776e.tar.gz
cpython-6938a297dafc4d1809938f5be38c4afa475e776e.tar.bz2
Three micro fixes to formatstring
-rw-r--r--Objects/stringobject.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/Objects/stringobject.c b/Objects/stringobject.c
index 0d03a3b..d40b908 100644
--- a/Objects/stringobject.c
+++ b/Objects/stringobject.c
@@ -643,7 +643,7 @@ formatstring(format, args)
int width = -1;
int prec = -1;
int size = 0;
- int c;
+ int c = '\0';
int fill;
object *v;
char *buf;
@@ -788,15 +788,13 @@ formatstring(format, args)
buf = formatchar(v);
if (buf == NULL)
goto error;
- len = strlen(buf);
+ len = 1;
break;
default:
err_setstr(ValueError,
"unsupported format character");
goto error;
}
- /* XXX There's a bug somewhere here so that
- XXX '%4d'%-1 yields '- 1' ... */
if (sign) {
if (*buf == '-' || *buf == '+') {
sign = *buf++;
@@ -820,7 +818,6 @@ formatstring(format, args)
res = getstringvalue(result) + reslen - rescnt;
}
if (sign) {
- *res++ = sign;
rescnt--;
if (width > len)
width--;
@@ -831,6 +828,8 @@ formatstring(format, args)
*res++ = fill;
} while (--width > len);
}
+ if (sign)
+ *res++ = sign;
memcpy(res, buf, len);
res += len;
rescnt -= len;