SET: Improve error messages for SET CCx.
[pspp] / src / data / settings.c
index 313fed0baf191821434d0cc91de087ebb61bc262..5db8e12e249d51e5537ab12e9f909e6c0c6c2919 100644 (file)
@@ -48,6 +48,9 @@ struct settings
   /* Format of reals in output (SET WRB). */
   enum float_format output_float_format;
 
+  /* MATRIX...END MATRIX settings. */
+  enum settings_mdisplay mdisplay;
+
   int viewlength;
   int viewwidth;
   bool safer_mode;
@@ -71,6 +74,7 @@ struct settings
   struct fmt_spec default_format;
   bool testing_mode;
   int fuzzbits;
+  int scalemin;
 
   int cmd_algorithm;
   int global_algorithm;
@@ -90,6 +94,7 @@ static struct settings the_settings = {
   .input_float_format = FLOAT_NATIVE_DOUBLE,
   .output_integer_format = INTEGER_NATIVE,
   .output_float_format = FLOAT_NATIVE_DOUBLE,
+  .mdisplay = SETTINGS_MDISPLAY_TEXT,
   .viewlength = 24,
   .viewwidth = 79,
   .safer_mode = false,
@@ -118,6 +123,7 @@ static struct settings the_settings = {
   .default_format = { .type = FMT_F, .w = 8, .d = 2 },
   .testing_mode = false,
   .fuzzbits = 6,
+  .scalemin = 24,
   .cmd_algorithm = ENHANCED,
   .global_algorithm = ENHANCED,
   .syntax = ENHANCED,
@@ -544,6 +550,18 @@ settings_set_fuzzbits (int fuzzbits)
   the_settings.fuzzbits = fuzzbits;
 }
 
+int
+settings_get_scalemin (void)
+{
+  return the_settings.scalemin;
+}
+
+void
+settings_set_scalemin (int scalemin)
+{
+  the_settings.scalemin = scalemin;
+}
+
 /* Return the current algorithm setting */
 enum behavior_mode
 settings_get_algorithm (void)
@@ -587,22 +605,21 @@ settings_set_syntax (enum behavior_mode mode)
 }
 
 \f
-/* Sets custom currency specifier CC having name CC_NAME ('A' through
-   'E') to correspond to the settings in CC_STRING. */
-bool
+/* Sets custom currency specifier CC having name CC_NAME ('A' through 'E') to
+   correspond to the settings in CC_STRING.  Returns NULL if successful,
+   otherwise an error message that the caller must free. */
+char * WARN_UNUSED_RESULT
 settings_set_cc (const char *cc_string, enum fmt_type type)
 {
   struct fmt_number_style *style = fmt_number_style_from_string (cc_string);
   if (!style)
-    {
-      msg (SE, _("%s: Custom currency string `%s' does not contain "
-                 "exactly three periods or commas (or it contains both)."),
-           fmt_name (type), cc_string);
-      return false;
-    }
+    return xasprintf (_("Custom currency string `%s' for %s does not contain "
+                        "exactly three periods or commas (or it contains "
+                        "both)."),
+                      fmt_name (type), cc_string);
 
   fmt_settings_set_cc (&the_settings.styles, type, style);
-  return true;
+  return NULL;
 }
 
 void
@@ -611,6 +628,12 @@ settings_set_decimal_char (char decimal)
   the_settings.styles.decimal = decimal;
 }
 
+void
+settings_set_include_leading_zero (bool include_leading_zero)
+{
+  the_settings.styles.include_leading_zero = include_leading_zero;
+}
+
 const struct fmt_settings *
 settings_get_fmt_settings (void)
 {
@@ -701,3 +724,15 @@ settings_set_show_variables (enum settings_value_show s)
 {
   the_settings.show_variables = s;
 }
+
+enum settings_mdisplay
+settings_get_mdisplay (void)
+{
+  return the_settings.mdisplay;
+}
+
+void
+settings_set_mdisplay (enum settings_mdisplay mdisplay)
+{
+  the_settings.mdisplay = mdisplay;
+}