* 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
This commit is contained in:
Guido van Rossum 1993-05-12 08:24:20 +00:00
parent ad4fcd49fc
commit 6ac258d381
7 changed files with 95 additions and 81 deletions

View file

@ -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;