aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndreas Schwab2007-11-15 23:38:14 +0000
committerAndreas Schwab2007-11-15 23:38:14 +0000
commit0f860bd79348a8d857cbf61d114bf689c6af5279 (patch)
tree4fb1a494d545150fc23cb5722eae10ef70b1507b /src
parent9b6112e8c3b29f91d8b337c247f3aaf7588dcadb (diff)
downloademacs-0f860bd79348a8d857cbf61d114bf689c6af5279.tar.gz
emacs-0f860bd79348a8d857cbf61d114bf689c6af5279.zip
(Fformat): Correctly format EMACS_UINT values.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog2
-rw-r--r--src/editfns.c40
2 files changed, 28 insertions, 14 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 82f5f3790fa..6c22f16b189 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,7 @@
12007-11-15 Andreas Schwab <schwab@suse.de> 12007-11-15 Andreas Schwab <schwab@suse.de>
2 2
3 * editfns.c (Fformat): Correctly format EMACS_INT values.
4
3 * keyboard.c (Fevent_symbol_parse_modifiers): Fix declaration. 5 * keyboard.c (Fevent_symbol_parse_modifiers): Fix declaration.
4 6
52007-11-15 Stefan Monnier <monnier@iro.umontreal.ca> 72007-11-15 Stefan Monnier <monnier@iro.umontreal.ca>
diff --git a/src/editfns.c b/src/editfns.c
index 98ab2f90081..74261947d0e 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -3801,23 +3801,35 @@ usage: (format STRING &rest OBJECTS) */)
3801 format - this_format_start); 3801 format - this_format_start);
3802 this_format[format - this_format_start] = 0; 3802 this_format[format - this_format_start] = 0;
3803 3803
3804 if (INTEGERP (args[n])) 3804 if (format[-1] == 'e' || format[-1] == 'f' || format[-1] == 'g')
3805 sprintf (p, this_format, XFLOAT_DATA (args[n]));
3806 else
3805 { 3807 {
3806 if (format[-1] == 'd') 3808 if (sizeof (EMACS_INT) > sizeof (int))
3807 sprintf (p, this_format, XINT (args[n])); 3809 {
3810 /* Insert 'l' before format spec. */
3811 this_format[format - this_format_start]
3812 = this_format[format - this_format_start - 1];
3813 this_format[format - this_format_start - 1] = 'l';
3814 this_format[format - this_format_start + 1] = 0;
3815 }
3816
3817 if (INTEGERP (args[n]))
3818 {
3819 if (format[-1] == 'd')
3820 sprintf (p, this_format, XINT (args[n]));
3821 /* Don't sign-extend for octal or hex printing. */
3822 else
3823 sprintf (p, this_format, XUINT (args[n]));
3824 }
3825 else if (format[-1] == 'd')
3826 /* Maybe we should use "%1.0f" instead so it also works
3827 for values larger than MAXINT. */
3828 sprintf (p, this_format, (EMACS_INT) XFLOAT_DATA (args[n]));
3829 else
3808 /* Don't sign-extend for octal or hex printing. */ 3830 /* Don't sign-extend for octal or hex printing. */
3809 else 3831 sprintf (p, this_format, (EMACS_UINT) XFLOAT_DATA (args[n]));
3810 sprintf (p, this_format, XUINT (args[n]));
3811 } 3832 }
3812 else if (format[-1] == 'e' || format[-1] == 'f' || format[-1] == 'g')
3813 sprintf (p, this_format, XFLOAT_DATA (args[n]));
3814 else if (format[-1] == 'd')
3815 /* Maybe we should use "%1.0f" instead so it also works
3816 for values larger than MAXINT. */
3817 sprintf (p, this_format, (EMACS_INT) XFLOAT_DATA (args[n]));
3818 else
3819 /* Don't sign-extend for octal or hex printing. */
3820 sprintf (p, this_format, (EMACS_UINT) XFLOAT_DATA (args[n]));
3821 3833
3822 if (p > buf 3834 if (p > buf
3823 && multibyte 3835 && multibyte