]> git.eshelyaron.com Git - emacs.git/commitdiff
(Fformat): Correctly format EMACS_UINT values.
authorAndreas Schwab <schwab@suse.de>
Thu, 15 Nov 2007 23:38:14 +0000 (23:38 +0000)
committerAndreas Schwab <schwab@suse.de>
Thu, 15 Nov 2007 23:38:14 +0000 (23:38 +0000)
src/ChangeLog
src/editfns.c

index 82f5f3790faaa41e07e2ecf336841a6aeeb22d10..6c22f16b189ae4c07281cec15f7e46efa59f6370 100644 (file)
@@ -1,5 +1,7 @@
 2007-11-15  Andreas Schwab  <schwab@suse.de>
 
+       * editfns.c (Fformat): Correctly format EMACS_INT values.
+
        * keyboard.c (Fevent_symbol_parse_modifiers): Fix declaration.
 
 2007-11-15  Stefan Monnier  <monnier@iro.umontreal.ca>
index 98ab2f9008149f7a022bd447d8965113c88450f5..74261947d0e2fb1c78a1b5ad2ddf0b012df599ee 100644 (file)
@@ -3801,23 +3801,35 @@ usage: (format STRING &rest OBJECTS)  */)
                     format - this_format_start);
              this_format[format - this_format_start] = 0;
 
-             if (INTEGERP (args[n]))
+             if (format[-1] == 'e' || format[-1] == 'f' || format[-1] == 'g')
+               sprintf (p, this_format, XFLOAT_DATA (args[n]));
+             else
                {
-                 if (format[-1] == 'd')
-                   sprintf (p, this_format, XINT (args[n]));
+                 if (sizeof (EMACS_INT) > sizeof (int))
+                   {
+                     /* Insert 'l' before format spec.  */
+                     this_format[format - this_format_start]
+                       = this_format[format - this_format_start - 1];
+                     this_format[format - this_format_start - 1] = 'l';
+                     this_format[format - this_format_start + 1] = 0;
+                   }
+
+               if (INTEGERP (args[n]))
+                 {
+                   if (format[-1] == 'd')
+                     sprintf (p, this_format, XINT (args[n]));
+                   /* Don't sign-extend for octal or hex printing.  */
+                   else
+                     sprintf (p, this_format, XUINT (args[n]));
+                 }
+               else if (format[-1] == 'd')
+                 /* Maybe we should use "%1.0f" instead so it also works
+                    for values larger than MAXINT.  */
+                 sprintf (p, this_format, (EMACS_INT) XFLOAT_DATA (args[n]));
+               else
                  /* Don't sign-extend for octal or hex printing.  */
-                 else
-                   sprintf (p, this_format, XUINT (args[n]));
+                 sprintf (p, this_format, (EMACS_UINT) XFLOAT_DATA (args[n]));
                }
-             else if (format[-1] == 'e' || format[-1] == 'f' || format[-1] == 'g')
-               sprintf (p, this_format, XFLOAT_DATA (args[n]));
-             else if (format[-1] == 'd')
-               /* Maybe we should use "%1.0f" instead so it also works
-                  for values larger than MAXINT.  */
-               sprintf (p, this_format, (EMACS_INT) XFLOAT_DATA (args[n]));
-             else
-               /* Don't sign-extend for octal or hex printing.  */
-               sprintf (p, this_format, (EMACS_UINT) XFLOAT_DATA (args[n]));
 
              if (p > buf
                  && multibyte