Frequencies Dialog: Avoid initialising things more than once per dialog
[pspp] / src / data / data-in.c
index e72d1b6ad4e1fd45ff5026f301bd3ee034e4b4b3..ace167090c57b9f2f2fe97a4d4e96cd80405764d 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPP - a program for statistical analysis.
-   Copyright (C) 1997-9, 2000, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
+   Copyright (C) 1997-9, 2000, 2006, 2009, 2010, 2011, 2012 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
@@ -281,7 +281,6 @@ parse_number (struct data_in *i)
 
   struct string tmp;
 
-  bool explicit_decimals = false;
   int save_errno;
   char *tail;
 
@@ -334,7 +333,6 @@ parse_number (struct data_in *i)
   /* Decimal point and following digits. */
   if (ss_match_byte (&i->input, style->decimal))
     {
-      explicit_decimals = true;
       ds_put_byte (&tmp, '.');
       while (c_isdigit (ss_first (i->input)))
         ds_put_byte (&tmp, ss_get_byte (&i->input));
@@ -345,7 +343,6 @@ parse_number (struct data_in *i)
       && !ss_is_empty (i->input)
       && strchr ("eEdD-+", ss_first (i->input)))
     {
-      explicit_decimals = true;
       ds_put_byte (&tmp, 'e');
 
       if (strchr ("eEdD", ss_first (i->input)))
@@ -922,7 +919,7 @@ parse_year (struct data_in *i, long *year, size_t max_digits)
       else
         *year += epoch_century + 100;
     }
-  if (*year >= 1582 || *year <= 19999)
+  if (*year >= 1582 && *year <= 19999)
     return NULL;
 
   return xasprintf (_("Year (%ld) must be between 1582 and 19999."), *year);
@@ -1047,7 +1044,7 @@ parse_minute_second (struct data_in *i, double *time)
     *cp++ = ss_get_byte (&i->input);
   *cp = '\0';
 
-  *time += strtod (buf, NULL);
+  *time += c_strtod (buf, NULL);
 
   return NULL;
 }
@@ -1123,7 +1120,7 @@ parse_date (struct data_in *i)
   double time = 0, date = 0;
   enum time_sign time_sign = SIGN_NO_TIME;
 
-  const char *template = fmt_date_template (i->format);
+  const char *template = fmt_date_template (i->format, 0);
   size_t template_width = strlen (template);
   char *error;
 
@@ -1180,14 +1177,18 @@ parse_date (struct data_in *i)
         case '-':
         case '/':
         case '.':
-        case 'X':
           error = parse_date_delimiter (i);
           break;
         case ':':
           error = parse_time_delimiter (i);
         case ' ':
-          parse_spaces (i);
-          error = NULL;
+          if (i->format != FMT_MOYR)
+            {
+              parse_spaces (i);
+              error = NULL;
+            }
+          else
+            error = parse_date_delimiter (i);
           break;
         default:
           assert (count == 1);