value-parser: Make parse_value() accept variable's print format also.
[pspp-builds.git] / src / language / lexer / value-parser.c
index ff2701e8dadfb586b64a791367de731177b00563..74478cfa60ac7bce5249792e38fc6f77a0504062 100644 (file)
@@ -129,18 +129,15 @@ parse_number (struct lexer *lexer, double *x, const enum fmt_type *format)
     }
 }
 
-/* Parses the current token from LEXER into value V, which must
-   already have been initialized with the specified WIDTH.
-   Returns true if successful, false otherwise. */
+/* Parses the current token from LEXER into value V, which must already have
+   been initialized with the specified VAR's WIDTH.  Returns true if
+   successful, false otherwise. */
 bool
-parse_value (struct lexer *lexer, union value *v, int width)
+parse_value (struct lexer *lexer, union value *v, const struct variable *var)
 {
+  int width = var_get_width (var);
   if (width == 0)
-    {
-      if (!lex_force_num (lexer))
-       return false;
-      v->f = lex_tokval (lexer);
-    }
+    return parse_number (lexer, &v->f, &var_get_print_format (var)->type);
   else if (lex_force_string (lexer))
     {
       const char *s = lex_tokcstr (lexer);