Article View: gnu.emacs.bug
Article #99157bugfix for doprnt
From: Bernd Gutjahr
Date: Tue, 13 Nov 1990 15:16
Date: Tue, 13 Nov 1990 15:16
109 lines
3469 bytes
3469 bytes
Dear Mr. Stallman,
Today I found, that (format "--%-10s--" "hello") did not return
"--hello --", but "--hello--".
I've looked into ~emacs/src/doprnt.c and discovered, that it
handles %[bodx] with sprintf, with it correct, but not %[sc%].
So I've patches doprnt.c, to do all conversion specifications
will be handled by sprintf.
Besides, binary conversion with %b doesn't work.
Bernd Gutjahr
--
Bernd Gutjahr
I S A GmbH - Informationssysteme fuer computerintegrierte Automatisierung
Azenbergstr. 35, D-7000 Stuttgart 1, West-Germany, Phone: +49-711/22769-0
email: gutjahr@isa.de
*** doprnt.c.ORIG Tue Nov 13 15:27:27 1990
--- doprnt.c Tue Nov 13 15:36:39 1990
***************
*** 38,44 ****
register int tem;
char *string;
char fmtcpy[20];
- int minlen;
bufsize--;
while (*fmt && bufsize > 0) /* Loop until end of format string or buffer full */
--- 38,43 ----
***************
*** 57,63 ****
fmt++;
}
*string = 0;
- minlen = 0;
switch (*fmt++)
{
default:
--- 56,61 ----
***************
*** 67,72 ****
--- 65,72 ----
case 'd':
case 'o':
case 'x':
+ case 's':
+ case 'c':
if (cnt == nargs)
error ("Format string wants too many arguments");
sprintf (tembuf, fmtcpy, args[cnt++]);
***************
*** 74,95 ****
string = tembuf;
goto doit;
! case 's':
! if (cnt == nargs)
! error ("Format string wants too many arguments");
! string = args[cnt++];
! if (fmtcpy[1] != 's')
! minlen = atoi (&fmtcpy[1]);
! /* Copy string into final output, truncating if no room. */
doit:
tem = strlen (string);
- minlen -= tem;
- while (minlen > 0 && bufsize > 0)
- {
- *bufptr++ = ' ';
- bufsize--;
- minlen--;
- }
if (tem > bufsize)
tem = bufsize;
strncpy (bufptr, string, tem);
--- 74,86 ----
string = tembuf;
goto doit;
! case '%':
! sprintf (tembuf, fmtcpy);
! /* Now copy tembuf into final output, truncating as nec. */
! string = tembuf;
!
doit:
tem = strlen (string);
if (tem > bufsize)
tem = bufsize;
strncpy (bufptr, string, tem);
***************
*** 97,111 ****
bufsize -= tem;
continue;
- case 'c':
- if (cnt == nargs)
- error ("Format string wants too many arguments");
- *bufptr++ = (int) args[cnt++];
- bufsize--;
- continue;
-
- case '%':
- fmt--; /* Drop thru and this % will be treated as normal */
}
}
*bufptr++ = *fmt++; /* Just some characters; Copy 'em */
--- 88,93 ----
Technical Details
Message-ID:
<9011131516.AA14955@leonardo.isa.de>Path:
arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!shelby!apple!julius.cs.uiuc.edu!wuarchive!cs.utexas.edu!tut.cis.ohio-state.edu!isa.de!gutjahrShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fb2f1,d064bf63a58026c2,start X-Google-Attributes: gidfb2f1,public X-Google-ArrivalTime: 1990-11-13 07:16:28 PST Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!shelby!apple!julius.cs.uiuc.edu!wuarchive!cs.utexas.edu!tut.cis.ohio-state.edu!isa.de!gutjahr From: gutjahr@isa.de (Bernd Gutjahr) Newsgroups: gnu.emacs.bug Subject: bugfix for doprnt Message-ID: <9011131516.AA14955@leonardo.isa.de> Date: 13 Nov 90 15:16:28 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 109 Approved: bug-gnu-emacs@prep.ai.mit.edu Posted: Tue Nov 13 16:16:28 1990