# HG changeset patch # User Andreas Schwab # Date 1195824432 0 # Node ID daa9b2b4d89d976bd41208903e05a7de9efd8124 # Parent ddf4e8b96231ff2e1b307aace4e7dbc461c6e931 (Fformat): Handle %c specially since it requires the argument to be of type int. diff -r ddf4e8b96231 -r daa9b2b4d89d src/editfns.c --- a/src/editfns.c Thu Nov 22 12:45:49 2007 +0000 +++ b/src/editfns.c Fri Nov 23 13:27:12 2007 +0000 @@ -3809,7 +3809,8 @@ 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] @@ -3820,12 +3821,16 @@ if (INTEGERP (args[n])) { - if (format[-1] == 'd') + 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. */