Handle case of a lookup table as the active file.
[pspp] / src / format.c
index 9c6bbea48e77bfd0163384b289fe37c1219ac672..5e06ab2291e43ff4f40efcaeb2fbae4bcfe2a569 100644 (file)
@@ -37,6 +37,9 @@ struct fmt_desc formats[FMT_NUMBER_OF_FORMATS + 1] =
   {"",         -1, -1,  -1, -1,   -1, 0000, -1, -1},
 };
 
+/* Common formats. */
+const struct fmt_spec f8_2 = {FMT_F, 8, 2};
+
 /* Parses the alphabetic prefix of the current token as a format
    specifier name.  Returns the corresponding format specifier
    type if successful, or -1 on failure.  If ALLOW_XT is zero,
@@ -59,7 +62,7 @@ parse_format_specifier_name (const char **cp, enum fmt_parse_flags flags)
       /* Find format. */
       for (idx = 0; idx < FMT_NUMBER_OF_FORMATS; idx++)
         if (strlen (formats[idx].name) == ep - sp
-            && !mm_case_compare (formats[idx].name, sp, ep - sp))
+            && !buf_compare_case (formats[idx].name, sp, ep - sp))
           break;
 
       /* Check format. */
@@ -442,3 +445,29 @@ translate_fmt (int spss)
       return type;
   return -1;
 }
+
+/* Returns an input format specification with type TYPE, width W,
+   and D decimals. */
+struct fmt_spec
+make_input_format (int type, int w, int d) 
+{
+  struct fmt_spec f;
+  f.type = type;
+  f.w = w;
+  f.d = d;
+  assert (check_input_specifier (&f, 0));
+  return f;
+}
+
+/* Returns an output format specification with type TYPE, width
+   W, and D decimals. */
+struct fmt_spec
+make_output_format (int type, int w, int d)
+{
+  struct fmt_spec f;
+  f.type = type;
+  f.w = w;
+  f.d = d;
+  assert (check_output_specifier (&f, 0));
+  return f;
+}