comparison src/doprnt.c @ 371:cc15677e0335 r21-2b1

Import from CVS: tag r21-2b1
author cvs
date Mon, 13 Aug 2007 11:03:08 +0200
parents a4f53d9b3154
children 8626e4521993
comparison
equal deleted inserted replaced
370:bd866891f083 371:cc15677e0335
384 match the actual type **after default promotions**." */ 384 match the actual type **after default promotions**." */
385 385
386 if (strchr (int_converters, ch)) 386 if (strchr (int_converters, ch))
387 { 387 {
388 if (spec->h_flag) 388 if (spec->h_flag)
389 arg.i = va_arg (vargs, int /* short */); 389 arg.i = va_arg (vargs, short);
390 else if (spec->l_flag) 390 else if (spec->l_flag)
391 arg.l = va_arg (vargs, long); 391 arg.l = va_arg (vargs, long);
392 else 392 else
393 arg.i = va_arg (vargs, int); 393 arg.i = va_arg (vargs, int);
394 } 394 }
395 else if (strchr (unsigned_int_converters, ch)) 395 else if (strchr (unsigned_int_converters, ch))
396 { 396 {
397 if (spec->h_flag) 397 if (spec->h_flag)
398 arg.ui = va_arg (vargs, unsigned int /* unsigned short */); 398 arg.ui = va_arg (vargs, unsigned short);
399 else if (spec->l_flag) 399 else if (spec->l_flag)
400 arg.ul = va_arg (vargs, unsigned long); 400 arg.ul = va_arg (vargs, unsigned long);
401 else 401 else
402 arg.ui = va_arg (vargs, unsigned int); 402 arg.ui = va_arg (vargs, unsigned int);
403 } 403 }
631 631
632 else 632 else
633 { 633 {
634 char text_to_print[500]; 634 char text_to_print[500];
635 char constructed_spec[100]; 635 char constructed_spec[100];
636 int tem;
637 636
638 /* Partially reconstruct the spec and use sprintf() to 637 /* Partially reconstruct the spec and use sprintf() to
639 format the string. */ 638 format the string. */
640 639
641 /* Make sure nothing stupid happens */ 640 /* Make sure nothing stupid happens */
650 strcat (constructed_spec, "+"); 649 strcat (constructed_spec, "+");
651 if (spec->space_flag) 650 if (spec->space_flag)
652 strcat (constructed_spec, " "); 651 strcat (constructed_spec, " ");
653 if (spec->number_flag) 652 if (spec->number_flag)
654 strcat (constructed_spec, "#"); 653 strcat (constructed_spec, "#");
655 tem = strlen (constructed_spec);
656 if (spec->precision >= 0) 654 if (spec->precision >= 0)
657 { 655 {
658 strcat (constructed_spec, "."); 656 strcat (constructed_spec, ".");
659 long_to_string (constructed_spec + strlen (constructed_spec), 657 long_to_string (constructed_spec + strlen (constructed_spec),
660 spec->precision); 658 spec->precision);
674 else 672 else
675 sprintf (text_to_print, constructed_spec, arg.ui); 673 sprintf (text_to_print, constructed_spec, arg.ui);
676 } 674 }
677 else 675 else
678 { 676 {
679 /* In the special case of zero padding a signed integer */
680 /* with a field width specified, we overwrite the default */
681 /* format. */
682 if (spec->zero_flag && spec->minwidth)
683 sprintf (constructed_spec + tem,
684 "0%d%c", spec->minwidth, ch);
685 if (spec->l_flag) 677 if (spec->l_flag)
686 sprintf (text_to_print, constructed_spec, arg.l); 678 sprintf (text_to_print, constructed_spec, arg.l);
687 else 679 else
688 sprintf (text_to_print, constructed_spec, arg.i); 680 sprintf (text_to_print, constructed_spec, arg.i);
689 } 681 }