changeset 86362:dbb20895db72

(Fformat): Handle %c specially since it requires the argument to be of type int.
author Andreas Schwab <schwab@suse.de>
date Fri, 23 Nov 2007 13:25:23 +0000
parents 38f93f3d00a2
children 662e64745141
files src/editfns.c
diffstat 1 files changed, 20 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/src/editfns.c	Fri Nov 23 06:58:00 2007 +0000
+++ b/src/editfns.c	Fri Nov 23 13:25:23 2007 +0000
@@ -3807,7 +3807,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]
@@ -3816,21 +3817,25 @@
 		      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