Mercurial > hg > xemacs-beta
comparison src/doprnt.c @ 272:c5d627a313b1 r21-0b34
Import from CVS: tag r21-0b34
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:28:48 +0200 |
parents | 92f8ad5d0d3f |
children | 6330739388db |
comparison
equal
deleted
inserted
replaced
271:c7b7086b0a39 | 272:c5d627a313b1 |
---|---|
147 REGISTER Bufbyte *arg_ptr = arg_convert; | 147 REGISTER Bufbyte *arg_ptr = arg_convert; |
148 | 148 |
149 *returned_num = -1; | 149 *returned_num = -1; |
150 while (start != end && isdigit (*start)) | 150 while (start != end && isdigit (*start)) |
151 { | 151 { |
152 if (arg_ptr - arg_convert >= sizeof (arg_convert) - 1) | 152 if ((size_t) (arg_ptr - arg_convert) >= sizeof (arg_convert) - 1) |
153 error ("Format converter number too large"); | 153 error ("Format converter number too large"); |
154 *arg_ptr++ = *start++; | 154 *arg_ptr++ = *start++; |
155 } | 155 } |
156 *arg_ptr = '\0'; | 156 *arg_ptr = '\0'; |
157 if (arg_convert != arg_ptr) | 157 if (arg_convert != arg_ptr) |
189 { | 189 { |
190 struct printf_spec spec; | 190 struct printf_spec spec; |
191 CONST Bufbyte *text_end; | 191 CONST Bufbyte *text_end; |
192 Bufbyte ch; | 192 Bufbyte ch; |
193 | 193 |
194 memset (&spec, 0, sizeof (spec)); | 194 xzero (spec); |
195 if (fmt == fmt_end) | 195 if (fmt == fmt_end) |
196 return specs; | 196 return specs; |
197 text_end = (Bufbyte *) memchr (fmt, '%', fmt_end - fmt); | 197 text_end = (Bufbyte *) memchr (fmt, '%', fmt_end - fmt); |
198 if (!text_end) | 198 if (!text_end) |
199 text_end = fmt_end; | 199 text_end = fmt_end; |
259 if (fmt != fmt_end && *fmt == '*') | 259 if (fmt != fmt_end && *fmt == '*') |
260 { | 260 { |
261 spec.converter = '*'; | 261 spec.converter = '*'; |
262 RESOLVE_FLAG_CONFLICTS(spec); | 262 RESOLVE_FLAG_CONFLICTS(spec); |
263 Dynarr_add (specs, spec); | 263 Dynarr_add (specs, spec); |
264 memset (&spec, 0, sizeof (spec)); | 264 xzero (spec); |
265 spec.argnum = ++prev_argnum; | 265 spec.argnum = ++prev_argnum; |
266 fmt++; | 266 fmt++; |
267 } | 267 } |
268 else | 268 else |
269 { | 269 { |
287 { | 287 { |
288 spec.converter = '*'; | 288 spec.converter = '*'; |
289 spec.forwarding_precision = 1; | 289 spec.forwarding_precision = 1; |
290 RESOLVE_FLAG_CONFLICTS(spec); | 290 RESOLVE_FLAG_CONFLICTS(spec); |
291 Dynarr_add (specs, spec); | 291 Dynarr_add (specs, spec); |
292 memset (&spec, 0, sizeof (spec)); | 292 xzero (spec); |
293 spec.argnum = ++prev_argnum; | 293 spec.argnum = ++prev_argnum; |
294 fmt++; | 294 fmt++; |
295 } | 295 } |
296 else | 296 else |
297 { | 297 { |
359 printf_arg_dynarr *args = Dynarr_new (printf_arg); | 359 printf_arg_dynarr *args = Dynarr_new (printf_arg); |
360 union printf_arg arg; | 360 union printf_arg arg; |
361 REGISTER int i; | 361 REGISTER int i; |
362 int args_needed = get_args_needed (specs); | 362 int args_needed = get_args_needed (specs); |
363 | 363 |
364 memset (&arg, 0, sizeof (union printf_arg)); | 364 xzero (arg); |
365 for (i = 1; i <= args_needed; i++) | 365 for (i = 1; i <= args_needed; i++) |
366 { | 366 { |
367 int j; | 367 int j; |
368 char ch; | 368 char ch; |
369 struct printf_spec *spec = 0; | 369 struct printf_spec *spec = 0; |
478 { | 478 { |
479 doprnt_1 (stream, (Bufbyte *) &ch, 1, 0, -1, 0, 0); | 479 doprnt_1 (stream, (Bufbyte *) &ch, 1, 0, -1, 0, 0); |
480 continue; | 480 continue; |
481 } | 481 } |
482 | 482 |
483 /* | 483 /* The char '*' as converter means the field width, precision |
484 * * as converter means the field width, precision was specified | 484 was specified as an argument. Extract the data and forward |
485 * as an argument. Extract the data and forward it to the | 485 it to the next spec, to which it will apply. */ |
486 * next spec, to which it will apply. | |
487 */ | |
488 if (ch == '*') | 486 if (ch == '*') |
489 { | 487 { |
490 struct printf_spec *nextspec = Dynarr_atp (specs, i + 1); | 488 struct printf_spec *nextspec = Dynarr_atp (specs, i + 1); |
491 Lisp_Object obj = largs[spec->argnum - 1]; | 489 Lisp_Object obj = largs[spec->argnum - 1]; |
492 | 490 |
528 string = Dynarr_at (args, spec->argnum - 1).bp; | 526 string = Dynarr_at (args, spec->argnum - 1).bp; |
529 /* error() can be called with null string arguments. | 527 /* error() can be called with null string arguments. |
530 E.g., in fileio.c, the return value of strerror() | 528 E.g., in fileio.c, the return value of strerror() |
531 is never checked. We'll print (null), like some | 529 is never checked. We'll print (null), like some |
532 printf implementations do. Would it be better (and safe) | 530 printf implementations do. Would it be better (and safe) |
533 to signal an error instead? Or should we just use the | 531 to signal an error instead? Or should we just use the |
534 empty string? -dkindred@cs.cmu.edu 8/1997 | 532 empty string? -dkindred@cs.cmu.edu 8/1997 |
535 */ | 533 */ |
536 if (!string) | 534 if (!string) |
537 string = (Bufbyte *) "(null)"; | 535 string = (Bufbyte *) "(null)"; |
538 string_len = strlen ((char *) string); | 536 string_len = strlen ((char *) string); |