syntax-gen.c (syntax_gen_pspp_valist): Add new %g directive
authorJohn Darrington <john@darrington.wattle.id.au>
Sun, 23 Dec 2012 16:01:30 +0000 (17:01 +0100)
committerJohn Darrington <john@darrington.wattle.id.au>
Sun, 23 Dec 2012 16:19:32 +0000 (17:19 +0100)
src/ui/syntax-gen.c

index fe88e62913d776cbc83331dbda25e6e09a018855..52c40fa69d6cc83a58662b6a1d6a28354cd335df 100644 (file)
@@ -231,6 +231,7 @@ syntax_gen_pspp_valist (struct string *output, const char *format,
 {
   for (;;)
     {
+      char directive;
       size_t copy = strcspn (format, "%");
       ds_put_substring (output, ss_buffer (format, copy));
       format += copy;
@@ -239,7 +240,8 @@ syntax_gen_pspp_valist (struct string *output, const char *format,
         return;
       assert (*format == '%');
       format++;
-      switch (*format++)
+      directive = *format++;
+      switch (directive)
         {
         case 's':
           {
@@ -266,16 +268,14 @@ syntax_gen_pspp_valist (struct string *output, const char *format,
           break;
 
         case 'f':
+       case 'g':
           {
+           char conv[3];
             double d = va_arg (args, double);
-            switch (*format++)
-              {
-              case 'p':
-                ds_put_c_format (output, "%f", d);
-                break;
-              default:
-                NOT_REACHED ();
-              }
+           conv[0]='%';
+           conv[1]=directive;
+           conv[2]='\0';
+           ds_put_c_format (output, conv, d);
             break;
           }