summaryrefslogtreecommitdiff
path: root/src/editfns.c
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>2007-12-06 09:51:45 +0000
committerMiles Bader <miles@gnu.org>2007-12-06 09:51:45 +0000
commit40f159a4ae7d081d4ced7c12a9eea261317c4ea9 (patch)
treed6c70803dc99aa1441ccd764033a34e3c6169158 /src/editfns.c
parent64effd5514fcb3e902c99e7bc211b156be01bead (diff)
parentc6b18b69fc894b12b70b780ff864fb95ffdcf7ee (diff)
downloademacs-40f159a4ae7d081d4ced7c12a9eea261317c4ea9.tar.gz
Merge from emacs--devo--0
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-294
Diffstat (limited to 'src/editfns.c')
-rw-r--r--src/editfns.c53
1 files changed, 36 insertions, 17 deletions
diff --git a/src/editfns.c b/src/editfns.c
index 66e3883494f..fa1b229bfc4 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -3673,8 +3673,10 @@ usage: (format STRING &rest OBJECTS) */)
precision[n+1] = 10 * precision[n+1] + *format - '0';
}
- if (format - this_format_start + 1 > longest_format)
- longest_format = format - this_format_start + 1;
+ /* Extra +1 for 'l' that we may need to insert into the
+ format. */
+ if (format - this_format_start + 2 > longest_format)
+ longest_format = format - this_format_start + 2;
if (format == end)
error ("Format string ends in middle of format specifier");
@@ -3735,7 +3737,7 @@ usage: (format STRING &rest OBJECTS) */)
&& *format != 'i' && *format != 'X' && *format != 'c')
error ("Invalid format operation %%%c", *format);
- thissize = 30;
+ thissize = 30 + (precision[n] > 0 ? precision[n] : 0);
if (*format == 'c')
{
if (! ASCII_CHAR_P (XINT (args[n]))
@@ -3933,23 +3935,40 @@ 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]));
- /* Don't sign-extend for octal or hex printing. */
+ if (sizeof (EMACS_INT) > sizeof (int)
+ && format[-1] != 'c')
+ {
+ /* 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] == 'c')
+ sprintf (p, this_format, (int) XINT (args[n]));
+ else 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] == 'c')
+ sprintf (p, this_format, (int) 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
- sprintf (p, this_format, XUINT (args[n]));
+ /* Don't sign-extend for octal or hex printing. */
+ 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