X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fformat.c;h=744cd6feccaf3644fb118cc9cdfb0c51c4f6a3f3;hb=f62199cac6213ed1c03ffe48450a583da0fadc68;hp=37e691a4a7ae20f0483de8a262f1851012ed1a0b;hpb=37597beca4a11edba50b847932fdfeca3a648fa2;p=pspp-builds.git diff --git a/src/format.c b/src/format.c index 37e691a4..744cd6fe 100644 --- a/src/format.c +++ b/src/format.c @@ -20,7 +20,7 @@ #include #include "format.h" #include -#include +#include "error.h" #include #include "error.h" #include "lexer.h" @@ -49,7 +49,7 @@ parse_format_specifier_name (const char **cp, int allow_xt) char *sp, *ep; int idx; - sp = ep = ds_value (&tokstr); + sp = ep = ds_c_str (&tokstr); while (isalpha ((unsigned char) *ep)) ep++; @@ -58,7 +58,7 @@ parse_format_specifier_name (const char **cp, int allow_xt) /* Find format. */ for (idx = 0; idx < FMT_NUMBER_OF_FORMATS; idx++) if (strlen (formats[idx].name) == ep - sp - && memcmp (formats[idx].name, sp, ep - sp)) + && !memcmp (formats[idx].name, sp, ep - sp)) break; /* Check format. */ @@ -74,7 +74,7 @@ parse_format_specifier_name (const char **cp, int allow_xt) { /* No match. */ msg (SE, _("%.*s is not a valid data format."), - (int) (ep - sp), ds_value (&tokstr)); + (int) (ep - sp), ds_c_str (&tokstr)); idx = -1; } } @@ -84,8 +84,13 @@ parse_format_specifier_name (const char **cp, int allow_xt) idx = -1; } - if (cp != NULL) - *cp = ep; + if (cp != NULL) + { + if (idx != -1) + *cp = ep; + else + *cp = NULL; + } return idx; } @@ -333,7 +338,7 @@ parse_format_specifier (struct fmt_spec *input, int allow_xt) if (cp2 == cp && type != FMT_X) { msg (SE, _("Data format %s does not specify a width."), - ds_value (&tokstr)); + ds_c_str (&tokstr)); return 0; } @@ -349,7 +354,7 @@ parse_format_specifier (struct fmt_spec *input, int allow_xt) if (*cp) { - msg (SE, _("Data format %s is not valid."), ds_value (&tokstr)); + msg (SE, _("Data format %s is not valid."), ds_c_str (&tokstr)); return 0; } lex_get ();