summaryrefslogtreecommitdiff
path: root/src/doprnt.c
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1994-07-05 07:24:16 +0000
committerRichard M. Stallman <rms@gnu.org>1994-07-05 07:24:16 +0000
commitdc80c8908d07cd6e7af399eca11098ba703d363a (patch)
treef9c5b77f3e1fde322f175f55f381d424e4150c16 /src/doprnt.c
parent7c5ace62315eea7951a4a6e6970775a50f57da24 (diff)
downloademacs-dc80c8908d07cd6e7af399eca11098ba703d363a.tar.gz
(doprnt): Handle padding on %c.
Diffstat (limited to 'src/doprnt.c')
-rw-r--r--src/doprnt.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/doprnt.c b/src/doprnt.c
index 13fa047dcbe..3ea758d71e8 100644
--- a/src/doprnt.c
+++ b/src/doprnt.c
@@ -62,6 +62,7 @@ doprnt (buffer, bufsize, format, format_end, nargs, args)
char *fmtcpy;
int minlen;
int size; /* Field width factor; e.g., %90d */
+ char charbuf[2]; /* Used for %c. */
if (format_end == 0)
format_end = format + strlen (format);
@@ -154,6 +155,7 @@ doprnt (buffer, bufsize, format, format_end, nargs, args)
/* Copy string into final output, truncating if no room. */
doit:
tem = strlen (string);
+ doit1:
if (minlen > 0)
{
while (minlen > tem && bufsize > 0)
@@ -184,9 +186,12 @@ doprnt (buffer, bufsize, format, format_end, nargs, args)
case 'c':
if (cnt == nargs)
error ("not enough arguments for format string");
- *bufptr++ = (int) args[cnt++];
- bufsize--;
- continue;
+ *charbuf = (int) args[cnt++];
+ string = charbuf;
+ tem = 1;
+ if (fmtcpy[1] != 'c')
+ minlen = atoi (&fmtcpy[1]);
+ goto doit1;
case '%':
fmt--; /* Drop thru and this % will be treated as normal */