Reform string library.
[pspp-builds.git] / src / data / sys-file-reader.c
index 0a040af60f5072dc604e2aad585c395e82951600..98e1a0621d9b5d9be3b6166ab4eb7702d1eb03a3 100644 (file)
@@ -66,7 +66,7 @@ struct sfm_reader
 
   /* Variables. */
   struct hsh_table *var_hash;
-  struct variable *const *svars;
+  struct variable **svars;
 
   /* File's special constants. */
   flt64 sysmis;
@@ -134,16 +134,16 @@ corrupt_msg (int class, const char *format,...)
   va_list args;
   struct string text;
 
-  ds_create (&text, _("corrupt system file: "));
+  ds_init_cstr (&text, _("corrupt system file: "));
   va_start (args, format);
-  ds_vprintf (&text, format, args);
+  ds_put_vformat (&text, format, args);
   va_end (args);
 
   m.category = msg_class_to_category (class);
   m.severity = msg_class_to_severity (class);
   m.where.file_name = NULL;
   m.where.line_number = 0;
-  m.text = ds_c_str (&text);
+  m.text = ds_cstr (&text);
 
   msg_emit (&m);
 }
@@ -510,6 +510,16 @@ sfm_open_reader (struct file_handle *fh, struct dictionary **dict,
 
                      assertive_buf_read (r, &params, sizeof(params), 0);
 
+                     if ( ! measure_is_valid(params.measure) 
+                          || 
+                          ! alignment_is_valid(params.align))
+                       {
+                         msg(MW, 
+                             _("%s: Invalid variable display parameters.  Default parameters substituted."), 
+                             fh_get_file_name(r->fh));
+                         continue;
+                       }
+
                      v = dict_get_var(*dict, i);
 
                      v->measure = params.measure;
@@ -1693,7 +1703,7 @@ sfm_read_case (struct sfm_reader *r, struct ccase *c)
 
   if ( ! r->svars ) 
     {
-      r->svars = (struct variable *const *) hsh_data(r->var_hash);
+      r->svars = (struct variable **) hsh_data(r->var_hash);
       sort(r->svars, hsh_count(r->var_hash), 
           sizeof(*r->svars), compare_var_index, 0);
     }