From: Andreas Schwab Date: Fri, 23 Nov 2007 13:27:46 +0000 (+0000) Subject: (Fformat): Handle %c specially since it requires the X-Git-Tag: emacs-pretest-23.0.90~9525 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ff6e6ac8392ae8a5b6a6c190c2d1efb33d239580;p=emacs.git (Fformat): Handle %c specially since it requires the argument to be of type int. --- diff --git a/src/ChangeLog b/src/ChangeLog index 7b3fc9bb833..3527506b20a 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2007-11-23 Andreas Schwab + + * editfns.c (Fformat): Handle %c specially since it requires the + argument to be of type int. + 2007-11-23 Markus Triska * emacs.c (main): Call init_editfns before init_process, since diff --git a/src/editfns.c b/src/editfns.c index 008cc3a95bf..f5b71f2aa18 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -3807,7 +3807,8 @@ usage: (format STRING &rest OBJECTS) */) sprintf (p, this_format, XFLOAT_DATA (args[n])); else { - if (sizeof (EMACS_INT) > sizeof (int)) + if (sizeof (EMACS_INT) > sizeof (int) + && format[-1] != 'c') { /* Insert 'l' before format spec. */ this_format[format - this_format_start] @@ -3816,21 +3817,25 @@ usage: (format STRING &rest OBJECTS) */) this_format[format - this_format_start + 1] = 0; } - if (INTEGERP (args[n])) - { - if (format[-1] == 'd') - sprintf (p, this_format, XINT (args[n])); + 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 /* 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. */ - sprintf (p, this_format, (EMACS_UINT) XFLOAT_DATA (args[n])); + sprintf (p, this_format, (EMACS_UINT) XFLOAT_DATA (args[n])); } if (p > buf