diff options
| author | Andreas Schwab | 2007-11-15 23:45:21 +0000 |
|---|---|---|
| committer | Andreas Schwab | 2007-11-15 23:45:21 +0000 |
| commit | f52fcaa4f399a0f96d4be0bcaa8342818f15e82b (patch) | |
| tree | 7ca95bd1e414205f965800c2a5b4b11f8d6774f6 /src | |
| parent | 3b58b87349b6d8bae3ad7c8da3affec6d435de29 (diff) | |
| download | emacs-f52fcaa4f399a0f96d4be0bcaa8342818f15e82b.tar.gz emacs-f52fcaa4f399a0f96d4be0bcaa8342818f15e82b.zip | |
(Fformat): Correctly format EMACS_INT values.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 4 | ||||
| -rw-r--r-- | src/editfns.c | 40 |
2 files changed, 30 insertions, 14 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 1899b577f74..c6c2db23f12 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2007-11-15 Andreas Schwab <schwab@suse.de> | ||
| 2 | |||
| 3 | * editfns.c (Fformat): Correctly format EMACS_INT values. | ||
| 4 | |||
| 1 | 2007-11-15 Juanma Barranquero <lekktu@gmail.com> | 5 | 2007-11-15 Juanma Barranquero <lekktu@gmail.com> |
| 2 | 6 | ||
| 3 | * macfns.c (Fx_create_frame, Fx_display_pixel_width) | 7 | * macfns.c (Fx_create_frame, Fx_display_pixel_width) |
diff --git a/src/editfns.c b/src/editfns.c index 6c6742d242e..fb9c1c96b59 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -3803,23 +3803,35 @@ usage: (format STRING &rest OBJECTS) */) | |||
| 3803 | format - this_format_start); | 3803 | format - this_format_start); |
| 3804 | this_format[format - this_format_start] = 0; | 3804 | this_format[format - this_format_start] = 0; |
| 3805 | 3805 | ||
| 3806 | if (INTEGERP (args[n])) | 3806 | if (format[-1] == 'e' || format[-1] == 'f' || format[-1] == 'g') |
| 3807 | sprintf (p, this_format, XFLOAT_DATA (args[n])); | ||
| 3808 | else | ||
| 3807 | { | 3809 | { |
| 3808 | if (format[-1] == 'd') | 3810 | if (sizeof (EMACS_INT) > sizeof (int)) |
| 3809 | sprintf (p, this_format, XINT (args[n])); | 3811 | { |
| 3810 | /* Don't sign-extend for octal or hex printing. */ | 3812 | /* Insert 'l' before format spec. */ |
| 3813 | this_format[format - this_format_start] | ||
| 3814 | = this_format[format - this_format_start - 1]; | ||
| 3815 | this_format[format - this_format_start - 1] = 'l'; | ||
| 3816 | this_format[format - this_format_start + 1] = 0; | ||
| 3817 | } | ||
| 3818 | |||
| 3819 | if (INTEGERP (args[n])) | ||
| 3820 | { | ||
| 3821 | if (format[-1] == 'd') | ||
| 3822 | sprintf (p, this_format, XINT (args[n])); | ||
| 3823 | /* Don't sign-extend for octal or hex printing. */ | ||
| 3824 | else | ||
| 3825 | sprintf (p, this_format, XUINT (args[n])); | ||
| 3826 | } | ||
| 3827 | else if (format[-1] == 'd') | ||
| 3828 | /* Maybe we should use "%1.0f" instead so it also works | ||
| 3829 | for values larger than MAXINT. */ | ||
| 3830 | sprintf (p, this_format, (EMACS_INT) XFLOAT_DATA (args[n])); | ||
| 3811 | else | 3831 | else |
| 3812 | sprintf (p, this_format, XUINT (args[n])); | 3832 | /* Don't sign-extend for octal or hex printing. */ |
| 3833 | sprintf (p, this_format, (EMACS_UINT) XFLOAT_DATA (args[n])); | ||
| 3813 | } | 3834 | } |
| 3814 | else if (format[-1] == 'e' || format[-1] == 'f' || format[-1] == 'g') | ||
| 3815 | sprintf (p, this_format, XFLOAT_DATA (args[n])); | ||
| 3816 | else if (format[-1] == 'd') | ||
| 3817 | /* Maybe we should use "%1.0f" instead so it also works | ||
| 3818 | for values larger than MAXINT. */ | ||
| 3819 | sprintf (p, this_format, (EMACS_INT) XFLOAT_DATA (args[n])); | ||
| 3820 | else | ||
| 3821 | /* Don't sign-extend for octal or hex printing. */ | ||
| 3822 | sprintf (p, this_format, (EMACS_UINT) XFLOAT_DATA (args[n])); | ||
| 3823 | 3835 | ||
| 3824 | if (p > buf | 3836 | if (p > buf |
| 3825 | && multibyte | 3837 | && multibyte |