comparison src/editfns.c @ 79472:daa9b2b4d89d

(Fformat): Handle %c specially since it requires the argument to be of type int.
author Andreas Schwab <schwab@suse.de>
date Fri, 23 Nov 2007 13:27:12 +0000
parents 576665ace786
children fc2bcd2a8aad
comparison
equal deleted inserted replaced
79471:ddf4e8b96231 79472:daa9b2b4d89d
3807 3807
3808 if (format[-1] == 'e' || format[-1] == 'f' || format[-1] == 'g') 3808 if (format[-1] == 'e' || format[-1] == 'f' || format[-1] == 'g')
3809 sprintf (p, this_format, XFLOAT_DATA (args[n])); 3809 sprintf (p, this_format, XFLOAT_DATA (args[n]));
3810 else 3810 else
3811 { 3811 {
3812 if (sizeof (EMACS_INT) > sizeof (int)) 3812 if (sizeof (EMACS_INT) > sizeof (int)
3813 && format[-1] != 'c')
3813 { 3814 {
3814 /* Insert 'l' before format spec. */ 3815 /* Insert 'l' before format spec. */
3815 this_format[format - this_format_start] 3816 this_format[format - this_format_start]
3816 = this_format[format - this_format_start - 1]; 3817 = this_format[format - this_format_start - 1];
3817 this_format[format - this_format_start - 1] = 'l'; 3818 this_format[format - this_format_start - 1] = 'l';
3818 this_format[format - this_format_start + 1] = 0; 3819 this_format[format - this_format_start + 1] = 0;
3819 } 3820 }
3820 3821
3821 if (INTEGERP (args[n])) 3822 if (INTEGERP (args[n]))
3822 { 3823 {
3823 if (format[-1] == 'd') 3824 if (format[-1] == 'c')
3825 sprintf (p, this_format, (int) XINT (args[n]));
3826 else if (format[-1] == 'd')
3824 sprintf (p, this_format, XINT (args[n])); 3827 sprintf (p, this_format, XINT (args[n]));
3825 /* Don't sign-extend for octal or hex printing. */ 3828 /* Don't sign-extend for octal or hex printing. */
3826 else 3829 else
3827 sprintf (p, this_format, XUINT (args[n])); 3830 sprintf (p, this_format, XUINT (args[n]));
3828 } 3831 }
3832 else if (format[-1] == 'c')
3833 sprintf (p, this_format, (int) XFLOAT_DATA (args[n]));
3829 else if (format[-1] == 'd') 3834 else if (format[-1] == 'd')
3830 /* Maybe we should use "%1.0f" instead so it also works 3835 /* Maybe we should use "%1.0f" instead so it also works
3831 for values larger than MAXINT. */ 3836 for values larger than MAXINT. */
3832 sprintf (p, this_format, (EMACS_INT) XFLOAT_DATA (args[n])); 3837 sprintf (p, this_format, (EMACS_INT) XFLOAT_DATA (args[n]));
3833 else 3838 else