summaryrefslogtreecommitdiffstats
path: root/Objects/stringobject.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1993-05-12 08:24:20 (GMT)
committerGuido van Rossum <guido@python.org>1993-05-12 08:24:20 (GMT)
commit6ac258d381b5300e3ec935404a111e8dff4617d4 (patch)
tree476a8c807f8f91cc5c259af586b3470201a9c2c1 /Objects/stringobject.c
parentad4fcd49fc5c9ec93743f93da518b84e0634ea59 (diff)
downloadcpython-6ac258d381b5300e3ec935404a111e8dff4617d4.zip
cpython-6ac258d381b5300e3ec935404a111e8dff4617d4.tar.gz
cpython-6ac258d381b5300e3ec935404a111e8dff4617d4.tar.bz2
* pythonrun.c: Print exception type+arg *after* stack trace instead of
before it. * ceval.c, object.c: moved testbool() to object.c (now extern visible) * stringobject.c: fix bugs in and rationalize string resize in formatstring() * tokenizer.[ch]: fix non-working code for lines longer than BUFSIZ
Diffstat (limited to 'Objects/stringobject.c')
-rw-r--r--Objects/stringobject.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/Objects/stringobject.c b/Objects/stringobject.c
index 5c7345d..33fe485 100644
--- a/Objects/stringobject.c
+++ b/Objects/stringobject.c
@@ -491,13 +491,13 @@ formatstring(format, args)
err_badcall();
return NULL;
}
- reslen = rescnt = 100;
+ fmt = getstringvalue(format);
+ fmtcnt = getstringsize(format);
+ reslen = rescnt = fmtcnt + 100;
result = newsizedstringobject((char *)NULL, reslen);
if (result == NULL)
return NULL;
res = getstringvalue(result);
- fmt = getstringvalue(format);
- fmtcnt = getstringsize(format);
if (is_tupleobject(args)) {
arglen = gettuplesize(args);
argidx = 0;
@@ -509,12 +509,11 @@ formatstring(format, args)
while (--fmtcnt >= 0) {
if (*fmt != '%') {
if (--rescnt < 0) {
- rescnt = reslen;
- reslen = reslen * 2; /* Maybe less when big? */
+ rescnt = fmtcnt + 100;
+ reslen += rescnt;
if (resizestring(&result, reslen) < 0)
return NULL;
- res = getstringvalue(result) + rescnt;
- rescnt = reslen - rescnt;
+ res = getstringvalue(result) + reslen - rescnt;
}
*res++ = *fmt++;
}
@@ -692,12 +691,12 @@ formatstring(format, args)
if (width < len)
width = len;
if (rescnt < width + (sign != '\0')) {
- rescnt = reslen;
- reslen = reslen + width + 100;
+ reslen -= rescnt;
+ rescnt = width + fmtcnt + 100;
+ reslen += rescnt;
if (resizestring(&result, reslen) < 0)
return NULL;
- res = getstringvalue(result) + rescnt;
- rescnt = reslen - rescnt;
+ res = getstringvalue(result) + reslen - rescnt;
}
if (sign) {
*res++ = sign;