aboutsummaryrefslogtreecommitdiffstats
path: root/src/doprnt.c
diff options
context:
space:
mode:
authorRichard M. Stallman1994-07-05 07:24:16 +0000
committerRichard M. Stallman1994-07-05 07:24:16 +0000
commit35a65fcedefa225bca856ea802a7bc758b48bde3 (patch)
treee7a273ce91df8c556ee725a0e22850d5cae245f8 /src/doprnt.c
parenta522e5bffeb2a9a1ac9f4639eb360ec21ecb4677 (diff)
downloademacs-35a65fcedefa225bca856ea802a7bc758b48bde3.tar.gz
emacs-35a65fcedefa225bca856ea802a7bc758b48bde3.zip
(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)
62 char *fmtcpy; 62 char *fmtcpy;
63 int minlen; 63 int minlen;
64 int size; /* Field width factor; e.g., %90d */ 64 int size; /* Field width factor; e.g., %90d */
65 char charbuf[2]; /* Used for %c. */
65 66
66 if (format_end == 0) 67 if (format_end == 0)
67 format_end = format + strlen (format); 68 format_end = format + strlen (format);
@@ -154,6 +155,7 @@ doprnt (buffer, bufsize, format, format_end, nargs, args)
154 /* Copy string into final output, truncating if no room. */ 155 /* Copy string into final output, truncating if no room. */
155 doit: 156 doit:
156 tem = strlen (string); 157 tem = strlen (string);
158 doit1:
157 if (minlen > 0) 159 if (minlen > 0)
158 { 160 {
159 while (minlen > tem && bufsize > 0) 161 while (minlen > tem && bufsize > 0)
@@ -184,9 +186,12 @@ doprnt (buffer, bufsize, format, format_end, nargs, args)
184 case 'c': 186 case 'c':
185 if (cnt == nargs) 187 if (cnt == nargs)
186 error ("not enough arguments for format string"); 188 error ("not enough arguments for format string");
187 *bufptr++ = (int) args[cnt++]; 189 *charbuf = (int) args[cnt++];
188 bufsize--; 190 string = charbuf;
189 continue; 191 tem = 1;
192 if (fmtcpy[1] != 'c')
193 minlen = atoi (&fmtcpy[1]);
194 goto doit1;
190 195
191 case '%': 196 case '%':
192 fmt--; /* Drop thru and this % will be treated as normal */ 197 fmt--; /* Drop thru and this % will be treated as normal */