Work on support for variable sets.
[pspp] / src / data / por-file-reader.c
index 8cea15e7496592588233047bcaf5d95e8e246bbf..2487ab2cb43f140d3fe6f9962b9a07afa4090d8e 100644 (file)
@@ -623,32 +623,23 @@ static struct fmt_spec
 convert_format (struct pfm_reader *r, const int portable_format[3],
                 struct variable *v, bool *report_error)
 {
-  struct fmt_spec format;
-  bool ok;
-
-  if (!fmt_from_io (portable_format[0], &format.type))
+  enum fmt_type type;
+  if (fmt_from_io (portable_format[0], &type))
     {
-      if (*report_error)
-        warning (r, _("%s: Bad format specifier byte (%d).  Variable "
-                      "will be assigned a default format."),
-                 var_get_name (v), portable_format[0]);
-      goto assign_default;
-    }
+      struct fmt_spec format = {
+        .type = type,
+        .w = portable_format[1],
+        .d = portable_format[2],
+      };
 
-  format.w = portable_format[1];
-  format.d = portable_format[2];
+      if (fmt_check_output (format)
+          && fmt_check_width_compat (format, var_get_width (v)))
+        return format;
 
-  msg_disable ();
-  ok = (fmt_check_output (&format)
-        && fmt_check_width_compat (&format, var_get_width (v)));
-  msg_enable ();
-
-  if (!ok)
-    {
       if (*report_error)
         {
           char fmt_string[FMT_STRING_LEN_MAX + 1];
-          fmt_to_string (&format, fmt_string);
+          fmt_to_string (format, fmt_string);
           if (var_is_numeric (v))
             warning (r, _("Numeric variable %s has invalid format "
                           "specifier %s."),
@@ -658,12 +649,15 @@ convert_format (struct pfm_reader *r, const int portable_format[3],
                           "invalid format specifier %s."),
                      var_get_name (v), var_get_width (v), fmt_string);
         }
-      goto assign_default;
+    }
+  else
+    {
+      if (*report_error)
+        warning (r, _("%s: Bad format specifier byte (%d).  Variable "
+                      "will be assigned a default format."),
+                 var_get_name (v), portable_format[0]);
     }
 
-  return format;
-
-assign_default:
   *report_error = false;
   return fmt_default_for_width (var_get_width (v));
 }
@@ -716,8 +710,7 @@ read_variables (struct pfm_reader *r, struct dictionary *dict)
       for (j = 0; j < 6; j++)
         fmt[j] = read_int (r);
 
-      if (!dict_id_is_valid (dict, name, false)
-          || *name == '#' || *name == '$')
+      if (!dict_id_is_valid (dict, name) || *name == '#' || *name == '$')
         error (r, _("Invalid variable name `%s' in position %d."), name, i);
       str_uppercase (name);
 
@@ -742,8 +735,8 @@ read_variables (struct pfm_reader *r, struct dictionary *dict)
 
       print = convert_format (r, &fmt[0], v, &report_error);
       write = convert_format (r, &fmt[3], v, &report_error);
-      var_set_print_format (v, &print);
-      var_set_write_format (v, &write);
+      var_set_print_format (v, print);
+      var_set_write_format (v, write);
 
       /* Range missing values. */
       mv_init (&miss, width);