Change many %g format specifiers to %.*g with precision DBL_DIG + 1.
[pspp] / src / language / xforms / compute.c
index 5089d80ded1b13abd40b6e94041ae9d7f4a0873d..00f7c5ad4706b4eec18f51872eb78640c32df110 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 1997-9, 2000, 2009, 2010, 2011 Free Software Foundation, Inc.
+   Copyright (C) 1997-9, 2000, 2009, 2010, 2011, 2014 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 
 #include <config.h>
 
+#include <float.h>
 #include <stdint.h>
 #include <stdlib.h>
 
 #include "data/case.h"
+#include "data/dataset.h"
 #include "data/dictionary.h"
-#include "data/procedure.h"
 #include "data/transformations.h"
 #include "data/variable.h"
 #include "data/vector.h"
@@ -100,7 +101,7 @@ cmd_compute (struct lexer *lexer, struct dataset *ds)
 
   lvalue_finalize (lvalue, compute, dict);
 
-  return lex_end_of_command (lexer);
+  return CMD_SUCCESS;
 
  fail:
   lvalue_destroy (lvalue, dict);
@@ -150,9 +151,9 @@ compute_num_vec (void *compute_, struct ccase **c, casenumber case_num)
                        "as an index into vector %s."),
                  vector_get_name (compute->vector));
           else
-            msg (SW, _("When executing COMPUTE: %g is not a valid value as "
+            msg (SW, _("When executing COMPUTE: %.*g is not a valid value as "
                        "an index into vector %s."),
-                 index, vector_get_name (compute->vector));
+                 DBL_DIG + 1, index, vector_get_name (compute->vector));
           return TRNS_CONTINUE;
         }
 
@@ -208,9 +209,9 @@ compute_str_vec (void *compute_, struct ccase **c, casenumber case_num)
         }
       else if (rindx < 1 || rindx > vector_get_var_cnt (compute->vector))
         {
-          msg (SW, _("When executing COMPUTE: %g is not a valid value as "
+          msg (SW, _("When executing COMPUTE: %.*g is not a valid value as "
                      "an index into vector %s."),
-               index, vector_get_name (compute->vector));
+               DBL_DIG + 1, index, vector_get_name (compute->vector));
           return TRNS_CONTINUE;
         }
 
@@ -256,7 +257,7 @@ cmd_if (struct lexer *lexer, struct dataset *ds)
 
   lvalue_finalize (lvalue, compute, dict);
 
-  return lex_end_of_command (lexer);
+  return CMD_SUCCESS;
 
  fail:
   lvalue_destroy (lvalue, dict);
@@ -346,7 +347,7 @@ lvalue_parse (struct lexer *lexer, struct dataset *ds)
   if (!lex_force_id (lexer))
     goto lossage;
 
-  if (lex_look_ahead (lexer) == T_LPAREN)
+  if (lex_next_token (lexer, 1) == T_LPAREN)
     {
       /* Vector. */
       lvalue->vector = dict_lookup_vector (dict, lex_tokcstr (lexer));