Mercurial > emacs
changeset 86122:54e0c02f7b7b
(Fformat): Correctly format EMACS_UINT values.
author | Andreas Schwab <schwab@suse.de> |
---|---|
date | Thu, 15 Nov 2007 23:37:33 +0000 |
parents | 2a84a3b9a3a3 |
children | 6d5c93a5cfd4 |
files | src/editfns.c |
diffstat | 1 files changed, 26 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/src/editfns.c Thu Nov 15 23:00:45 2007 +0000 +++ b/src/editfns.c Thu Nov 15 23:37:33 2007 +0000 @@ -3801,23 +3801,35 @@ 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