From 94d35ef3399039d11540e824f056193020c0b7fd Mon Sep 17 00:00:00 2001 From: John Darrington Date: Sun, 23 Dec 2012 17:01:30 +0100 Subject: [PATCH] syntax-gen.c (syntax_gen_pspp_valist): Add new %g directive --- src/ui/syntax-gen.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/ui/syntax-gen.c b/src/ui/syntax-gen.c index fe88e62913..52c40fa69d 100644 --- a/src/ui/syntax-gen.c +++ b/src/ui/syntax-gen.c @@ -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; } -- 2.30.2