Make data input and output take a fmt_settings structure.
authorBen Pfaff <blp@cs.stanford.edu>
Thu, 7 Jan 2021 00:24:46 +0000 (16:24 -0800)
committerBen Pfaff <blp@cs.stanford.edu>
Thu, 7 Jan 2021 04:29:34 +0000 (20:29 -0800)
This will allow pivot_table formatting to supply its own.

40 files changed:
src/data/calendar.c
src/data/calendar.h
src/data/csv-file-writer.c
src/data/data-in.c
src/data/data-in.h
src/data/data-out.c
src/data/data-out.h
src/data/format-guesser.c
src/data/format.c
src/data/format.h
src/data/gnumeric-reader.c
src/data/ods-reader.c
src/data/psql-reader.c
src/data/settings.c
src/data/settings.h
src/data/variable.c
src/language/data-io/data-list.c
src/language/data-io/data-parser.c
src/language/data-io/get-data.c
src/language/data-io/matrix-reader.c
src/language/data-io/print.c
src/language/data-io/save-translate.c
src/language/dictionary/mrsets.c
src/language/expressions/helpers.c
src/language/expressions/operations.def
src/language/lexer/value-parser.c
src/language/stats/crosstabs.q
src/language/stats/flip.c
src/language/utilities/set.q
src/language/xforms/recode.c
src/math/box-whisker.c
src/output/pivot-table.c
src/output/spv/spv-legacy-decoder.c
src/ui/gui/helper.c
src/ui/gui/missing-val-dialog.c
src/ui/gui/psppire-data-store.c
src/ui/gui/psppire-import-textfile.c
src/ui/gui/psppire-value-entry.c
src/ui/gui/var-type-dialog.c
src/ui/syntax-gen.c

index a2bb7e600004c6cd025c90e0c26641e12fe30ce0..e07e7d63aca2e9043f7edf692c351147183137e4 100644 (file)
@@ -71,12 +71,14 @@ raw_gregorian_to_offset (int y, int m, int d)
    Gregorian calendar.  Returns SYSMIS for dates before 14 Oct
    1582. */
 double
-calendar_gregorian_to_offset (int y, int m, int d, char **errorp)
+calendar_gregorian_to_offset (int y, int m, int d,
+                              const struct fmt_settings *settings,
+                              char **errorp)
 {
   /* Normalize year. */
   if (y >= 0 && y < 100)
     {
-      int epoch = settings_get_epoch ();
+      int epoch = fmt_settings_get_epoch (settings);
       int century = epoch / 100 + (y < epoch % 100);
       y += century * 100;
     }
index be1e5cb8284dcdada5dfb9acd2999bf801ecd815..02a9de28ace572aa9ddf5923e8fb61cdf8fcb85a 100644 (file)
@@ -19,7 +19,11 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #ifndef CALENDAR_H
 #define CALENDAR_H 1
 
-double calendar_gregorian_to_offset (int y, int m, int d, char **errorp);
+struct fmt_settings;
+
+double calendar_gregorian_to_offset (int y, int m, int d,
+                                     const struct fmt_settings *,
+                                     char **errorp);
 void calendar_offset_to_gregorian (int ofs, int *y, int *m, int *d, int *yd);
 int calendar_offset_to_year (int ofs);
 int calendar_offset_to_month (int ofs);
index 0e521a97442e543925a5aab8da9a9a15c5748587..d8c3e000ef84031f824998be068bdf1c94e5f992 100644 (file)
@@ -225,7 +225,8 @@ static void
 csv_output_format (struct csv_writer *w, const struct csv_var *cv,
                    const union value *value)
 {
-  char *s = data_out (value, w->encoding, &cv->format);
+  char *s = data_out (value, w->encoding, &cv->format,
+                      settings_get_fmt_settings ());
   struct substring ss = ss_cstr (s);
   if (cv->format.type != FMT_A)
     ss_trim (&ss, ss_cstr (" "));
index caf196ed4e2f307b1cb39cfaaa857881585abe52..d734eb911da8d910f871fda8d27d57aad8a18e0c 100644 (file)
@@ -53,6 +53,8 @@
 /* Information about parsing one data field. */
 struct data_in
   {
+    const struct fmt_settings *settings;
+
     struct substring input;     /* Source. */
     enum fmt_type format;       /* Input format. */
 
@@ -83,7 +85,7 @@ static int hexit_value (int c);
  */
 char *
 data_in (struct substring input, const char *input_encoding,
-         enum fmt_type format,
+         enum fmt_type format, const struct fmt_settings *settings,
          union value *output, int width, const char *output_encoding)
 {
   static data_in_parser_func *const handlers[FMT_NUMBER_OF_FORMATS] =
@@ -101,6 +103,8 @@ data_in (struct substring input, const char *input_encoding,
 
   assert ((width != 0) == fmt_is_string (format));
 
+  i.settings = settings;
+
   i.format = format;
 
   i.output = output;
@@ -165,10 +169,10 @@ data_in (struct substring input, const char *input_encoding,
 
 bool
 data_in_msg (struct substring input, const char *input_encoding,
-             enum fmt_type format,
+             enum fmt_type format, const struct fmt_settings *settings,
              union value *output, int width, const char *output_encoding)
 {
-  char *error = data_in (input, input_encoding, format,
+  char *error = data_in (input, input_encoding, format, settings,
                          output, width, output_encoding);
   if (error != NULL)
     {
@@ -182,9 +186,10 @@ data_in_msg (struct substring input, const char *input_encoding,
 }
 
 static bool
-number_has_implied_decimals (const char *s, enum fmt_type type)
+number_has_implied_decimals (const struct fmt_settings *settings,
+                             const char *s, enum fmt_type type)
 {
-  int decimal = settings_get_style (type)->decimal;
+  int decimal = fmt_settings_get_style (settings, type)->decimal;
   bool got_digit = false;
   for (;;)
     {
@@ -221,7 +226,8 @@ number_has_implied_decimals (const char *s, enum fmt_type type)
 
 static bool
 has_implied_decimals (struct substring input, const char *input_encoding,
-                      enum fmt_type format)
+                      enum fmt_type format,
+                      const struct fmt_settings *settings)
 {
   bool retval;
   char *s;
@@ -252,7 +258,7 @@ has_implied_decimals (struct substring input, const char *input_encoding,
                      ss_data (input), ss_length (input));
   retval = (format == FMT_Z
             ? strchr (s, '.') == NULL
-            : number_has_implied_decimals (s, format));
+            : number_has_implied_decimals (settings, s, format));
   free (s);
 
   return retval;
@@ -267,10 +273,12 @@ has_implied_decimals (struct substring input, const char *input_encoding,
    If it is appropriate, this function modifies the numeric value in OUTPUT. */
 void
 data_in_imply_decimals (struct substring input, const char *input_encoding,
-                        enum fmt_type format, int d, union value *output)
+                        enum fmt_type format, int d,
+                        const struct fmt_settings *settings,
+                        union value *output)
 {
   if (d > 0 && output->f != SYSMIS
-      && has_implied_decimals (input, input_encoding, format))
+      && has_implied_decimals (input, input_encoding, format, settings))
     output->f /= pow (10., d);
 }
 \f
@@ -280,19 +288,15 @@ data_in_imply_decimals (struct substring input, const char *input_encoding,
 static char *
 parse_number (struct data_in *i)
 {
-  const struct fmt_number_style *style =
-    settings_get_style (i->format);
+  const struct fmt_number_style *style = fmt_settings_get_style (
+    i->settings,
+    fmt_get_category (i->format) == FMT_CAT_CUSTOM ? FMT_F : i->format);
 
   struct string tmp;
 
   int save_errno;
   char *tail;
 
-  if  (fmt_get_category (i->format) == FMT_CAT_CUSTOM)
-    {
-      style = settings_get_style (FMT_F);
-    }
-
   /* Trim spaces and check for missing value representation. */
   if (trim_spaces_and_check_missing (i))
     return NULL;
@@ -919,7 +923,7 @@ parse_year (struct data_in *i, long *year, size_t max_digits)
 
   if (*year >= 0 && *year <= 99)
     {
-      int epoch = settings_get_epoch ();
+      int epoch = fmt_settings_get_epoch (i->settings);
       int epoch_century = ROUND_DOWN (epoch, 100);
       int epoch_offset = epoch - epoch_century;
       if (*year >= epoch_offset)
@@ -1046,7 +1050,7 @@ parse_minute_second (struct data_in *i, double *time)
   cp = buf;
   while (c_isdigit (ss_first (i->input)))
     *cp++ = ss_get_byte (&i->input);
-  if (ss_match_byte (&i->input, settings_get_decimal_char (FMT_F)))
+  if (ss_match_byte (&i->input, i->settings->decimal))
     *cp++ = '.';
   while (c_isdigit (ss_first (i->input)))
     *cp++ = ss_get_byte (&i->input);
@@ -1224,7 +1228,8 @@ parse_date (struct data_in *i)
       char *error;
       double ofs;
 
-      ofs = calendar_gregorian_to_offset (year, month, day, &error);
+      ofs = calendar_gregorian_to_offset (
+        year, month, day, settings_get_fmt_settings (), &error);
       if (ofs == SYSMIS)
         return error;
       date = (yday - 1 + ofs) * 60. * 60. * 24.;
index 74349052597c75fcbc714674f2759e45edc6b94c..6540004d2333921560c7437e83c42e78323c9469 100644 (file)
@@ -25,14 +25,15 @@ union value;
 struct dictionary;
 
 char *data_in (struct substring input, const char *input_encoding,
-               enum fmt_type,
+               enum fmt_type, const struct fmt_settings *,
                union value *output, int width, const char *output_encoding);
 
 bool data_in_msg (struct substring input, const char *input_encoding,
-                  enum fmt_type,
+                  enum fmt_type, const struct fmt_settings *,
                   union value *output, int width, const char *output_encoding);
 
 void data_in_imply_decimals (struct substring input, const char *encoding,
-                             enum fmt_type format, int d, union value *output);
+                             enum fmt_type format, int d,
+                             const struct fmt_settings *, union value *output);
 
 #endif /* data/data-in.h */
index cbd114b8e58cf8399caba921df0c12168cca4b90..37a25a267238deac8440e096c64931d957cdd723 100644 (file)
@@ -66,14 +66,16 @@ static void rounder_format (const struct rounder *, int decimals,
 \f
 typedef void data_out_converter_func (const union value *,
                                       const struct fmt_spec *,
-                                      char *);
+                                      const struct fmt_settings *, char *);
 #define FMT(NAME, METHOD, IMIN, OMIN, IO, CATEGORY) \
         static data_out_converter_func output_##METHOD;
 #include "format.def"
 
 static bool output_decimal (const struct rounder *, const struct fmt_spec *,
-                            bool require_affixes, char *);
+                            const struct fmt_settings *, bool require_affixes,
+                            char *);
 static bool output_scientific (double, const struct fmt_spec *,
+                               const struct fmt_settings *,
                                bool require_affixes, char *);
 
 static double power10 (int) PURE_FUNCTION;
@@ -108,6 +110,7 @@ static data_out_converter_func *const converters[FMT_NUMBER_OF_FORMATS] =
 void
 data_out_recode (const union value *input, const char *input_encoding,
                  const struct fmt_spec *format,
+                 const struct fmt_settings *settings,
                  struct string *output, const char *output_encoding)
 {
   assert (fmt_check_output (format));
@@ -120,11 +123,11 @@ data_out_recode (const union value *input, const char *input_encoding,
       free (out);
     }
   else if (fmt_get_category (format->type) == FMT_CAT_BINARY)
-    converters[format->type] (input, format,
+    converters[format->type] (input, format, settings,
                               ds_put_uninit (output, format->w));
   else
     {
-      char *utf8_encoded = data_out (input, input_encoding, format);
+      char *utf8_encoded = data_out (input, input_encoding, format, settings);
       char *output_encoded = recode_string (output_encoding, UTF8,
                                             utf8_encoded, -1);
       ds_put_cstr (output, output_encoded);
@@ -165,7 +168,8 @@ binary_to_utf8 (const char *in, struct pool *pool)
    If POOL is non-null, then the return value is allocated on that pool.  */
 char *
 data_out_pool (const union value *input, const char *input_encoding,
-              const struct fmt_spec *format, struct pool *pool)
+              const struct fmt_spec *format,
+               const struct fmt_settings *settings, struct pool *pool)
 {
   assert (fmt_check_output (format));
   if (format->type == FMT_A)
@@ -178,17 +182,18 @@ data_out_pool (const union value *input, const char *input_encoding,
       char tmp[16];
 
       assert (format->w + 1 <= sizeof tmp);
-      converters[format->type] (input, format, tmp);
+      converters[format->type] (input, format, settings, tmp);
       return binary_to_utf8 (tmp, pool);
     }
   else
     {
-      const struct fmt_number_style *style = settings_get_style (format->type);
+      const struct fmt_number_style *style = fmt_settings_get_style (
+        settings, format->type);
       size_t size = format->w + style->extra_bytes + 1;
       char *output;
 
       output = pool_alloc_unaligned (pool, size);
-      converters[format->type] (input, format, output);
+      converters[format->type] (input, format, settings, output);
       return output;
     }
 }
@@ -198,12 +203,14 @@ data_out_pool (const union value *input, const char *input_encoding,
    necessary to fully display the selected number of decimal places. */
 char *
 data_out_stretchy (const union value *input, const char *encoding,
-                   const struct fmt_spec *format, struct pool *pool)
+                   const struct fmt_spec *format,
+                   const struct fmt_settings *settings, struct pool *pool)
 {
 
   if (fmt_get_category (format->type) & (FMT_CAT_BASIC | FMT_CAT_CUSTOM))
     {
-      const struct fmt_number_style *style = settings_get_style (format->type);
+      const struct fmt_number_style *style
+        = fmt_settings_get_style (settings, format->type);
       struct fmt_spec wide_format;
       char tmp[128];
       size_t size;
@@ -215,19 +222,19 @@ data_out_stretchy (const union value *input, const char *encoding,
       size = format->w + style->extra_bytes + 1;
       if (size <= sizeof tmp)
         {
-          output_number (input, &wide_format, tmp);
+          output_number (input, &wide_format, settings, tmp);
           return pool_strdup (pool, tmp + strspn (tmp, " "));
         }
     }
 
-  return data_out_pool (input, encoding, format, pool);
+  return data_out_pool (input, encoding, format, settings, pool);
 }
 
 char *
 data_out (const union value *input, const char *input_encoding,
-          const struct fmt_spec *format)
+          const struct fmt_spec *format, const struct fmt_settings *settings)
 {
-  return data_out_pool (input, input_encoding, format, NULL);
+  return data_out_pool (input, input_encoding, format, settings, NULL);
 }
 
 \f
@@ -237,7 +244,7 @@ data_out (const union value *input, const char *input_encoding,
    CCE formats. */
 static void
 output_number (const union value *input, const struct fmt_spec *format,
-               char *output)
+               const struct fmt_settings *settings, char *output)
 {
   double number = input->f;
 
@@ -252,13 +259,13 @@ output_number (const union value *input, const struct fmt_spec *format,
           struct rounder r;
           rounder_init (&r, number, format->d);
 
-          if (output_decimal (&r, format, true, output)
-              || output_scientific (number, format, true, output)
-              || output_decimal (&r, format, false, output))
+          if (output_decimal (&r, format, settings, true, output)
+              || output_scientific (number, format, settings, true, output)
+              || output_decimal (&r, format, settings, false, output))
             return;
         }
 
-      if (!output_scientific (number, format, false, output))
+      if (!output_scientific (number, format, settings, false, output))
         output_overflow (format, output);
     }
 }
@@ -266,7 +273,7 @@ output_number (const union value *input, const struct fmt_spec *format,
 /* Outputs N format. */
 static void
 output_N (const union value *input, const struct fmt_spec *format,
-          char *output)
+          const struct fmt_settings *settings UNUSED, char *output)
 {
   double number = input->f * power10 (format->d);
   if (input->f == SYSMIS || number < 0)
@@ -288,7 +295,7 @@ output_N (const union value *input, const struct fmt_spec *format,
 /* Outputs Z format. */
 static void
 output_Z (const union value *input, const struct fmt_spec *format,
-          char *output)
+          const struct fmt_settings *settings UNUSED, char *output)
 {
   double number = input->f * power10 (format->d);
   char buf[128];
@@ -313,7 +320,7 @@ output_Z (const union value *input, const struct fmt_spec *format,
 /* Outputs P format. */
 static void
 output_P (const union value *input, const struct fmt_spec *format,
-          char *output)
+          const struct fmt_settings *settings UNUSED, char *output)
 {
   if (output_bcd_integer (fabs (input->f * power10 (format->d)),
                           format->w * 2 - 1, output)
@@ -326,7 +333,7 @@ output_P (const union value *input, const struct fmt_spec *format,
 /* Outputs PK format. */
 static void
 output_PK (const union value *input, const struct fmt_spec *format,
-           char *output)
+           const struct fmt_settings *settings UNUSED, char *output)
 {
   output_bcd_integer (input->f * power10 (format->d), format->w * 2, output);
 }
@@ -334,7 +341,7 @@ output_PK (const union value *input, const struct fmt_spec *format,
 /* Outputs IB format. */
 static void
 output_IB (const union value *input, const struct fmt_spec *format,
-           char *output)
+           const struct fmt_settings *settings UNUSED, char *output)
 {
   double number = round (input->f * power10 (format->d));
   if (input->f == SYSMIS
@@ -357,7 +364,7 @@ output_IB (const union value *input, const struct fmt_spec *format,
 /* Outputs PIB format. */
 static void
 output_PIB (const union value *input, const struct fmt_spec *format,
-            char *output)
+            const struct fmt_settings *settings UNUSED, char *output)
 {
   double number = round (input->f * power10 (format->d));
   if (input->f == SYSMIS
@@ -373,7 +380,7 @@ output_PIB (const union value *input, const struct fmt_spec *format,
 /* Outputs PIBHEX format. */
 static void
 output_PIBHEX (const union value *input, const struct fmt_spec *format,
-               char *output)
+               const struct fmt_settings *settings UNUSED, char *output)
 {
   double number = round (input->f);
   if (input->f == SYSMIS)
@@ -392,7 +399,7 @@ output_PIBHEX (const union value *input, const struct fmt_spec *format,
 /* Outputs RB format. */
 static void
 output_RB (const union value *input, const struct fmt_spec *format,
-           char *output)
+           const struct fmt_settings *settings UNUSED, char *output)
 {
   double d = input->f;
   memcpy (output, &d, format->w);
@@ -403,7 +410,7 @@ output_RB (const union value *input, const struct fmt_spec *format,
 /* Outputs RBHEX format. */
 static void
 output_RBHEX (const union value *input, const struct fmt_spec *format,
-              char *output)
+              const struct fmt_settings *settings UNUSED, char *output)
 {
   double d = input->f;
 
@@ -414,7 +421,7 @@ output_RBHEX (const union value *input, const struct fmt_spec *format,
    DATETIME, TIME, and DTIME formats. */
 static void
 output_date (const union value *input, const struct fmt_spec *format,
-             char *output)
+             const struct fmt_settings *settings, char *output)
 {
   double number = input->f;
   int year, month, day, yday;
@@ -482,7 +489,7 @@ output_date (const union value *input, const struct fmt_spec *format,
             }
           else
             {
-              int epoch =  settings_get_epoch ();
+              int epoch = fmt_settings_get_epoch (settings);
               int offset = year - epoch;
               if (offset < 0 || offset > 99)
                 goto overflow;
@@ -527,11 +534,11 @@ output_date (const union value *input, const struct fmt_spec *format,
               int d = MIN (format->d, excess_width - 4);
               int w = d + 3;
               c_snprintf (p, 64, ":%0*.*f", w, d, number);
-             if (settings_get_decimal_char (FMT_F) != '.')
+             if (settings->decimal != '.')
                 {
                   char *cp = strchr (p, '.');
                   if (cp != NULL)
-                   *cp = settings_get_decimal_char (FMT_F);
+                   *cp = settings->decimal;
                 }
               p += strlen (p);
             }
@@ -560,7 +567,7 @@ output_date (const union value *input, const struct fmt_spec *format,
 /* Outputs WKDAY format. */
 static void
 output_WKDAY (const union value *input, const struct fmt_spec *format,
-              char *output)
+              const struct fmt_settings *settings UNUSED, char *output)
 {
   static const char *const weekdays[7] =
     {
@@ -586,7 +593,7 @@ output_WKDAY (const union value *input, const struct fmt_spec *format,
 /* Outputs MONTH format. */
 static void
 output_MONTH (const union value *input, const struct fmt_spec *format,
-              char *output)
+              const struct fmt_settings *settings UNUSED, char *output)
 {
   static const char *const months[12] =
     {
@@ -611,7 +618,8 @@ output_MONTH (const union value *input, const struct fmt_spec *format,
 /* Outputs A format. */
 static void
 output_A (const union value *input UNUSED,
-          const struct fmt_spec *format UNUSED, char *output UNUSED)
+          const struct fmt_spec *format UNUSED,
+          const struct fmt_settings *settings UNUSED, char *output UNUSED)
 {
   NOT_REACHED ();
 }
@@ -619,7 +627,7 @@ output_A (const union value *input UNUSED,
 /* Outputs AHEX format. */
 static void
 output_AHEX (const union value *input, const struct fmt_spec *format,
-             char *output)
+             const struct fmt_settings *settings UNUSED, char *output)
 {
   output_hex (input->s, format->w / 2, output);
 }
@@ -650,10 +658,11 @@ allocate_space (int request, int max_width, int *width)
    omitted to make the number fit. */
 static bool
 output_decimal (const struct rounder *r, const struct fmt_spec *format,
-                bool require_affixes, char *output)
+                const struct fmt_settings *settings, bool require_affixes,
+                char *output)
 {
   const struct fmt_number_style *style =
-    settings_get_style (format->type);
+    fmt_settings_get_style (settings, format->type);
 
   int decimals;
 
@@ -755,10 +764,11 @@ output_decimal (const struct rounder *r, const struct fmt_spec *format,
    the style of the format specified in FORMAT. */
 static bool
 output_scientific (double number, const struct fmt_spec *format,
+                   const struct fmt_settings *settings,
                    bool require_affixes, char *output)
 {
   const struct fmt_number_style *style =
-    settings_get_style (format->type);
+    fmt_settings_get_style (settings, format->type);
   int width;
   int fraction_width;
   bool add_affixes;
index 65ac60544fffd6bc065c6b18633c222183d8be5b..f0bc9b24c871e445424461d14bf0739176478866 100644 (file)
 #include "libpspp/float-format.h"
 #include "libpspp/integer-format.h"
 
+struct fmt_settings;
 struct fmt_spec;
 struct string;
 union value;
 
 char *data_out (const union value *input, const char *input_encoding,
-                const struct fmt_spec *);
+                const struct fmt_spec *, const struct fmt_settings *);
 
 char *data_out_pool (const union value *input, const char *input_encoding,
-                     const struct fmt_spec *, struct pool *pool);
+                     const struct fmt_spec *, const struct fmt_settings *,
+                     struct pool *pool);
 
 char *data_out_stretchy (const union value *input, const char *input_encoding,
-                         const struct fmt_spec *, struct pool *);
+                         const struct fmt_spec *, const struct fmt_settings *,
+                         struct pool *);
 
 void data_out_recode (const union value *input, const char *input_encoding,
-                      const struct fmt_spec *,
+                      const struct fmt_spec *, const struct fmt_settings *,
                       struct string *output, const char *output_encoding);
 
 #endif /* data-out.h */
index 189320d293d16ba8787a06b4b5896137e8ebacb5..7475b2946f8fd68ffddf332d09f0c7e1b017ff25 100644 (file)
@@ -404,7 +404,7 @@ add_numeric (struct fmt_guesser *g, struct substring s)
          can't tell whether the ',' or '.' is a grouping or
          decimal character.  Assume that the decimal character
          from the settings is in use. */
-      if (prev_delim == settings_get_decimal_char (FMT_F))
+      if (prev_delim == settings_get_fmt_settings ()->decimal)
         {
           decimal = prev_delim;
           precision = delim_digits;
@@ -448,7 +448,7 @@ add_numeric (struct fmt_guesser *g, struct substring s)
 static void
 guess_numeric (struct fmt_guesser *g, struct fmt_spec *f)
 {
-  int decimal_char = settings_get_decimal_char (FMT_COMMA);
+  int decimal_char = settings_get_fmt_settings ()->decimal;
 
   f->d = g->decimals / g->count;
   if (g->pct)
@@ -679,7 +679,7 @@ parse_date_number (struct substring *s, enum date_token tokens_seen,
   size_t digit_cnt = ss_get_long (s, &value);
   enum date_token token = 0;
 
-  if (ss_match_byte (s, settings_get_decimal_char (FMT_F))
+  if (ss_match_byte (s, settings_get_fmt_settings ()->decimal)
       && tokens_seen & DT_COLON
       && value <= 59)
     {
index d0b87a503f198a8d7db58978abbf6c2fa27a6d06..12939c5dce5cbfcc64edb6155e230afdfb2723f6 100644 (file)
@@ -208,7 +208,8 @@ fmt_for_output (enum fmt_type type, int w, int d)
 /* Returns the output format specifier corresponding to input
    format specifier INPUT. */
 struct fmt_spec
-fmt_for_output_from_input (const struct fmt_spec *input)
+fmt_for_output_from_input (const struct fmt_spec *input,
+                           const struct fmt_settings *settings)
 {
   struct fmt_spec output;
 
@@ -237,7 +238,7 @@ fmt_for_output_from_input (const struct fmt_spec *input)
     case FMT_PCT:
       {
         const struct fmt_number_style *style =
-         settings_get_style (input->type);
+         fmt_settings_get_style (settings, input->type);
 
         output.w += fmt_affix_width (style);
         if (style->grouping != 0 && input->w - input->d >= 3)
index 8cc1b8718a78e9fa0ef6e4444f2d5dfa0cedb4db..223ce1533d11f2185568d8f18f9e1c444277cde3 100644 (file)
@@ -24,6 +24,8 @@
 #include "data/val-type.h"
 #include "libpspp/str.h"
 
+struct fmt_settings;
+
 /* How a format is going to be used. */
 enum fmt_use
   {
@@ -83,7 +85,8 @@ struct fmt_spec
 /* Constructing formats. */
 struct fmt_spec fmt_for_input (enum fmt_type, int w, int d) PURE_FUNCTION;
 struct fmt_spec fmt_for_output (enum fmt_type, int w, int d) PURE_FUNCTION;
-struct fmt_spec fmt_for_output_from_input (const struct fmt_spec *);
+struct fmt_spec fmt_for_output_from_input (const struct fmt_spec *,
+                                           const struct fmt_settings *);
 struct fmt_spec fmt_default_for_width (int width);
 
 /* Verifying formats. */
index c1bf389d262c6ee0368d324d224732d9568fb157..1378469c8a50e640ef563510cf746914cbf469dd 100644 (file)
@@ -637,10 +637,8 @@ convert_xml_string_to_value (struct ccase *c, const struct variable *var,
 
       const struct fmt_spec *fmt = var_get_write_format (var);
 
-      char *m = data_in (ss_cstr (text), "UTF-8",
-                        fmt->type,
-                        v,
-                        var_get_width (var),
+      char *m = data_in (ss_cstr (text), "UTF-8", fmt->type,
+                         settings_get_fmt_settings (), v, var_get_width (var),
                         "UTF-8");
 
       if (m)
index cac060f81d9fa93b518d2f55b0c493a2f4a18dc3..bb72e2437c85800319ca3b7cb8b302c8592fb35d 100644 (file)
@@ -674,11 +674,9 @@ convert_xml_to_value (struct ccase *c, const struct variable *var,
          const char *text = xmv->value ?
            CHAR_CAST (const char *, xmv->value) : CHAR_CAST (const char *, xmv->text);
 
-         char *m = data_in (ss_cstr (text), "UTF-8",
-                        fmt->type,
-                        v,
-                        var_get_width (var),
-                        "UTF-8");
+         char *m = data_in (ss_cstr (text), "UTF-8", fmt->type,
+                             settings_get_fmt_settings (), v,
+                             var_get_width (var), "UTF-8");
 
          if (m)
            {
index a6062a0941b715912492651c4097ef8d0f8c067f..f4c44a177f5b53dea84405aae9ae5b5f6b2663f2 100644 (file)
@@ -286,7 +286,8 @@ psql_open_reader (struct psql_read_info *info, struct dictionary **dict)
        }
     }
 
-  r->postgres_epoch = calendar_gregorian_to_offset (2000, 1, 1, NULL);
+  r->postgres_epoch = calendar_gregorian_to_offset (
+    2000, 1, 1, settings_get_fmt_settings (), NULL);
 
   {
     const int enc = PQclientEncoding (r->conn);
index 776cd51957fe4916301a8dbe30f8de4c195bf001..2479431b554687aff821f219cb6ae9cbf994683b 100644 (file)
@@ -289,13 +289,6 @@ settings_set_include (bool include)
   the_settings.include = include;
 }
 
-/* What year to use as the start of the epoch. */
-int
-settings_get_epoch (void)
-{
-  return fmt_settings_get_epoch (&the_settings.styles);
-}
-
 /* Sets the year that starts the epoch. */
 void
 settings_set_epoch (int epoch)
@@ -546,26 +539,16 @@ settings_set_cc (const char *cc_string, enum fmt_type type)
   return true;
 }
 
-/* Returns the decimal point character for TYPE. */
-int
-settings_get_decimal_char (enum fmt_type type)
-{
-  return fmt_settings_get_style (&the_settings.styles, type)->decimal;
-}
-
 void
 settings_set_decimal_char (char decimal)
 {
   the_settings.styles.decimal = decimal;
 }
 
-/* Returns the number formatting style associated with the given
-   format TYPE. */
-const struct fmt_number_style *
-settings_get_style (enum fmt_type type)
+const struct fmt_settings *
+settings_get_fmt_settings (void)
 {
-  assert (is_fmt_type (type));
-  return fmt_settings_get_style (&the_settings.styles, type);
+  return &the_settings.styles;
 }
 
 /* Returns a string of the form "$#,###.##" according to FMT,
index 8ab7357d0a4167c676a34a04d521d1b56dfa8b1a..f485ce152cf8e22cf90a40fb75b53ad3f408ac57 100644 (file)
@@ -72,7 +72,6 @@ void settings_set_safer_mode (void);
 bool settings_get_include (void);
 void settings_set_include (bool);
 
-int settings_get_epoch (void);
 void settings_set_epoch (int);
 
 bool settings_get_scompression (void);
@@ -143,11 +142,9 @@ void unset_cmd_algorithm (void);
 enum fmt_type;
 bool settings_set_cc (const char *cc_string, enum fmt_type type);
 
-int settings_get_decimal_char (enum fmt_type type);
 void settings_set_decimal_char (char decimal);
 
-
-const struct fmt_number_style * settings_get_style (enum fmt_type type);
+const struct fmt_settings *settings_get_fmt_settings (void);
 
 char * settings_dollar_template (const struct fmt_spec *fmt);
 
index 593e23ca720bcbc89bae8bfde8c6312d23f0ac9a..4859b1303faa3b31e737909c18003b59bbb81fd7 100644 (file)
@@ -572,7 +572,8 @@ static void
 append_value (const struct variable *v, const union value *value,
              struct string *str)
 {
-  char *s = data_out (value, var_get_encoding (v), &v->print);
+  char *s = data_out (value, var_get_encoding (v), &v->print,
+                      settings_get_fmt_settings ());
   struct substring ss = ss_cstr (s);
   ss_rtrim (&ss, ss_cstr (" "));
   ds_put_substring (str, ss);
index 754341ccac3a120c8dc840e4d261894db54e9ba1..58224baa2de01b6b3920e7947cb25cd528de9be7 100644 (file)
@@ -242,7 +242,7 @@ cmd_data_list (struct lexer *lexer, struct dataset *ds)
                   data_parser_set_quotes (parser, ss_cstr ("'\""));
                   data_parser_set_soft_delimiters (parser,
                                                    ss_cstr (CC_SPACES));
-                  const char decimal = settings_get_decimal_char (FMT_F);
+                  const char decimal = settings_get_fmt_settings ()->decimal;
                   data_parser_set_hard_delimiters (parser,
                                                    ss_buffer (",", (decimal == '.') ? 1 : 0));
                 }
@@ -368,7 +368,8 @@ parse_fixed (struct lexer *lexer, struct dictionary *dict,
             if (v != NULL)
               {
                 /* Success. */
-                struct fmt_spec output = fmt_for_output_from_input (f);
+                struct fmt_spec output = fmt_for_output_from_input (
+                  f, settings_get_fmt_settings ());
                 var_set_both_formats (v, &output);
               }
             else
@@ -472,7 +473,8 @@ parse_free (struct lexer *lexer, struct dictionary *dict,
           if (input.type == FMT_N)
             input.type = FMT_F;
 
-         output = fmt_for_output_from_input (&input);
+         output = fmt_for_output_from_input (&input,
+                                              settings_get_fmt_settings ());
        }
       else
        {
index 2f24b8a23886877be6dbde22f680b209b9d4108f..818c15a30f2ab09115b25b5ff7e7dc1f711eb738 100644 (file)
@@ -546,12 +546,14 @@ parse_fixed (const struct data_parser *parser, struct dfm_reader *reader,
                                           f->format.w);
           union value *value = case_data_rw_idx (c, f->case_idx);
           char *error = data_in (s, input_encoding, f->format.type,
+                                 settings_get_fmt_settings (),
                                  value, fmt_var_width (&f->format),
                                  output_encoding);
 
           if (error == NULL)
             data_in_imply_decimals (s, input_encoding, f->format.type,
-                                    f->format.d, value);
+                                    f->format.d, settings_get_fmt_settings (),
+                                    value);
           else
             parse_error (reader, f, f->first_column,
                          f->first_column + f->format.w, error);
@@ -598,6 +600,7 @@ parse_delimited_span (const struct data_parser *parser,
 
       const char *input_encoding = dfm_reader_get_encoding (reader);
       error = data_in (s, input_encoding, f->format.type,
+                       settings_get_fmt_settings (),
                        case_data_rw_idx (c, f->case_idx),
                        fmt_var_width (&f->format), output_encoding);
       if (error != NULL)
@@ -643,6 +646,7 @@ parse_delimited_no_span (const struct data_parser *parser,
 
       const char *input_encoding = dfm_reader_get_encoding (reader);
       error = data_in (s, input_encoding, f->format.type,
+                       settings_get_fmt_settings (),
                        case_data_rw_idx (c, f->case_idx),
                        fmt_var_width (&f->format), output_encoding);
       if (error != NULL)
index 66dd19f2397d7636228f2069eea4406eb07945ae..cdc867400579bf2d5d4a5e940251dc34409fb824 100644 (file)
@@ -619,7 +619,8 @@ parse_get_txt (struct lexer *lexer, struct dataset *ds)
            {
              goto error;
            }
-          output = fmt_for_output_from_input (&input);
+          output = fmt_for_output_from_input (&input,
+                                              settings_get_fmt_settings ());
         }
       else
         {
@@ -654,7 +655,8 @@ parse_get_txt (struct lexer *lexer, struct dataset *ds)
                 goto error;
             }
           else
-            output = fmt_for_output_from_input (&input);
+            output = fmt_for_output_from_input (&input,
+                                                settings_get_fmt_settings ());
         }
       v = dict_create_var (dict, name, fmt_var_width (&input));
       if (v == NULL)
index f1dbae184facb82ecd97826cdf465b03d0a252a7..fbebb922fb5dab8e38a86483ba8b0f13e832355e 100644 (file)
@@ -247,7 +247,7 @@ next_matrix_from_reader (struct matrix_material *mm,
 
       struct fmt_spec fmt = {FMT_A, 0, 0};
       fmt.w = w;
-      char *vname = data_out (uvv, enc, &fmt);
+      char *vname = data_out (uvv, enc, &fmt, settings_get_fmt_settings ());
       struct substring the_name = ss_cstr (vname);
 
       int mrow = -1;
index 7111c03c65a6e98f42bab1407433e7f94d853ee1..1c63f9c2ce7762fec294a2f6e9672dd9ddf08552 100644 (file)
@@ -505,7 +505,7 @@ print_text_trns_proc (void *trns_, struct ccase **c,
               char *s;
 
               s = data_out (input, var_get_encoding (spec->var),
-                            &spec->format);
+                            &spec->format, settings_get_fmt_settings ());
               len = strlen (s);
               width = u8_width (CHAR_CAST (const uint8_t *, s), len, UTF8);
               x1 = x0 + width;
@@ -619,7 +619,8 @@ print_binary_trns_proc (void *trns_, struct ccase **c,
           const union value *input = case_data (*c, spec->var);
           if (!spec->sysmis_as_spaces || input->f != SYSMIS)
             data_out_recode (input, var_get_encoding (spec->var),
-                             &spec->format, &line, trns->encoding);
+                             &spec->format, settings_get_fmt_settings (),
+                             &line, trns->encoding);
           else
             ds_put_byte_multiple (&line, encoded_space, spec->format.w);
           if (spec->add_space)
index 0fb474631d01b4580bd2419537d3881a59fc664e..a565f4471c3aeef45f34db40c44641b34a620ec9 100644 (file)
@@ -77,7 +77,7 @@ cmd_save_translate (struct lexer *lexer, struct dataset *ds)
   include_var_names = false;
   use_value_labels = false;
   use_print_formats = false;
-  decimal = settings_get_decimal_char (FMT_F);
+  decimal = settings_get_fmt_settings ()->decimal;
   delimiter = 0;
   qualifier = '"';
 
index 4a01ddd49f165c84ed1906bc93e037e14193a4be..5f544766e163703dd2f886c648328df021cd7527 100644 (file)
@@ -421,7 +421,8 @@ parse_group (struct lexer *lexer, struct dictionary *dict,
                       if (!c->warned && utf8_strcasecmp (c->label, label))
                         {
                           char *s = data_out (value, var_get_encoding (var),
-                                              var_get_print_format (var));
+                                              var_get_print_format (var),
+                                              settings_get_fmt_settings ());
                           c->warned = true;
                           msg (SW, _("Variables specified on MCGROUP should "
                                      "have the same categories, but %s and %s "
index c69e440e4bde0f9c8747296884c0cf83e9ce2b45..4a0a01b97b680907b0c1efe33f9bb1010e68891a 100644 (file)
@@ -45,7 +45,8 @@ expr_ymd_to_ofs (double year, double month, double day)
       return SYSMIS;
     }
 
-  ofs = calendar_gregorian_to_offset (y, m, d, &error);
+  ofs = calendar_gregorian_to_offset (y, m, d, settings_get_fmt_settings (),
+                                      &error);
   if (error != NULL)
     {
       msg (SE, "%s", error);
@@ -363,7 +364,8 @@ add_months (double date, int months, enum date_sum_method method)
   if (method == SUM_CLOSEST && d > calendar_days_in_month (y, m))
     d = calendar_days_in_month (y, m);
 
-  output = calendar_gregorian_to_offset (y, m, d, &error);
+  output = calendar_gregorian_to_offset (y, m, d, settings_get_fmt_settings (),
+                                         &error);
   if (output != SYSMIS)
     output = (output * DAY_S) + fmod (date, DAY_S);
   else
index 19bf2b54a8a00063b655d34b4429160ec0575912..df2887044fd377995d378009d9ea75df5d2c7555 100644 (file)
@@ -602,9 +602,11 @@ function NUMBER (string s, ni_format f)
 
   if (s.length > f->w)
     s.length = f->w;
-  error = data_in (s, C_ENCODING, f->type, &out, 0, NULL);
+  error = data_in (s, C_ENCODING, f->type, settings_get_fmt_settings (),
+                   &out, 0, NULL);
   if (error == NULL)
-    data_in_imply_decimals (s, C_ENCODING, f->type, f->d, &out);
+    data_in_imply_decimals (s, C_ENCODING, f->type, f->d,
+                            settings_get_fmt_settings (), &out);
   else
     {
       msg (SE, "Cannot parse `%.*s' as format %s: %s",
@@ -624,7 +626,7 @@ absorb_miss string function STRING (x, no_format f)
   v.f = x;
 
   assert (!fmt_is_string (f->type));
-  s = data_out (&v, C_ENCODING, f);
+  s = data_out (&v, C_ENCODING, f, settings_get_fmt_settings ());
   dst = alloc_string (e, strlen (s));
   strcpy (dst.string, s);
   free (s);
index 55707f6ac576f9f82aba8b390f4b58a34947c3dc..23b4def274cc71191dd3d1018625766500b753eb 100644 (file)
@@ -102,7 +102,8 @@ parse_number (struct lexer *lexer, double *x, const enum fmt_type *format)
 
       assert (fmt_get_category (*format) != FMT_CAT_STRING);
 
-      if (!data_in_msg (lex_tokss (lexer), "UTF-8", *format, &v, 0, NULL))
+      if (!data_in_msg (lex_tokss (lexer), "UTF-8", *format,
+                        settings_get_fmt_settings (), &v, 0, NULL))
         return false;
 
       lex_get (lexer);
index 8c1fe5ba2fe505595212d81fa873288f2d2f5065..50ba4a734239be7091ab1e7335c0166746ed0942 100644 (file)
@@ -1239,7 +1239,8 @@ create_crosstab_table (struct crosstabs_proc *proc, struct crosstabulation *xt,
       ds_put_format (&title, ", %s=", var_to_string (var));
 
       /* Insert the formatted value of VAR without any leading spaces. */
-      s = data_out (value, var_get_encoding (var), var_get_print_format (var));
+      s = data_out (value, var_get_encoding (var), var_get_print_format (var),
+                    settings_get_fmt_settings ());
       ds_put_cstr (&title, s + strspn (s, " "));
       free (s);
     }
index e39e85fd5fe490aa5da7f9797c58d1c67552c93e..216c9d7921c78a15a9a4a06af201178592bae075 100644 (file)
@@ -194,7 +194,7 @@ cmd_flip (struct lexer *lexer, struct dataset *ds)
             {
               name = data_out_pool (value, dict_get_encoding (old_dict),
                                     var_get_write_format (flip->new_names_var),
-                                    flip->pool);
+                                    settings_get_fmt_settings (), flip->pool);
             }
           var_names_add (flip->pool, &flip->new_names, name);
         }
@@ -421,7 +421,8 @@ flip_casereader_read (struct casereader *reader, void *flip_)
 
   c = case_create (casereader_get_proto (reader));
   data_in (ss_cstr (flip->old_names.names[flip->cases_read]), flip->encoding,
-           FMT_A, case_data_rw_idx (c, 0), 8, flip->encoding);
+           FMT_A, settings_get_fmt_settings (), case_data_rw_idx (c, 0),
+           8, flip->encoding);
 
   for (i = 0; i < flip->n_cases; i++)
     {
index ddc7fc629da3b671a85b25f435999371aee0647c..4bdd910390d55d91b1beb9b2be737e16b13c84b6 100644 (file)
@@ -672,7 +672,8 @@ format_cc (struct string *out, const char *in, char grouping)
 static char *
 show_cc (enum fmt_type type)
 {
-  const struct fmt_number_style *cc = settings_get_style (type);
+  const struct fmt_number_style *cc = fmt_settings_get_style (
+    settings_get_fmt_settings (), type);
   struct string out;
 
   ds_init_empty (&out);
@@ -720,7 +721,7 @@ show_cce (const struct dataset *ds UNUSED)
 static char *
 show_decimals (const struct dataset *ds UNUSED)
 {
-  return xasprintf ("`%c'", settings_get_decimal_char (FMT_F));
+  return xasprintf ("`%c'", settings_get_fmt_settings ()->decimal);
 }
 
 static char *
index 94c5e4c7f220873858700de101462f075b8f1a2d..b5e0e3fcdec34f8ffb4e0f4575aaea939ea30f75 100644 (file)
@@ -667,7 +667,8 @@ find_src_string (struct recode_trns *trns, const uint8_t *value,
             char *error;
 
             error = data_in (ss_buffer (CHAR_CAST_BUG (char *, value), width),
-                             C_ENCODING, FMT_F, &uv, 0, encoding);
+                             C_ENCODING, FMT_F, settings_get_fmt_settings (),
+                             &uv, 0, encoding);
             match = error == NULL;
             free (error);
 
index 53831824a09a32d0b5025607628983f7e1bba22e..3e501ccaeb7501da327eb145337290786b6ef7b9 100644 (file)
@@ -94,8 +94,9 @@ acc (struct statistic *s, const struct ccase *cx,
   if (bw->id_var)
     {
       char *s = data_out (case_data_idx (cx, bw->id_idx),
-                           var_get_encoding (bw->id_var),
-                           var_get_print_format (bw->id_var));
+                          var_get_encoding (bw->id_var),
+                          var_get_print_format (bw->id_var),
+                          settings_get_fmt_settings ());
 
       ds_put_cstr (&o->label, s);
       free (s);
index 9e45f244e061f6e162873e5c7a2f71e9ee304cf8..1fd136a57717f8d8ba56e4d0855cd7166523d627 100644 (file)
@@ -1964,7 +1964,7 @@ pivot_table_dump (const struct pivot_table *table, int indentation)
 
   pivot_table_assign_label_depth (CONST_CAST (struct pivot_table *, table));
 
-  int old_decimal = settings_get_decimal_char (FMT_COMMA);
+  int old_decimal = settings_get_fmt_settings ()->decimal;
   if (table->decimal == '.' || table->decimal == ',')
     settings_set_decimal_char (table->decimal);
 
@@ -2299,7 +2299,8 @@ pivot_value_format_body (const struct pivot_value *value,
       if (show & SETTINGS_VALUE_SHOW_VALUE)
         {
           char *s = data_out (&(union value) { .f = value->numeric.x },
-                              "UTF-8", &value->numeric.format);
+                              "UTF-8", &value->numeric.format,
+                              settings_get_fmt_settings ());
           ds_put_cstr (out, s + strspn (s, " "));
           free (s);
         }
index b90d6b0ab39492a9fffd7e67d80088edfbfe0694..b8005de5be890d3412c39090f68c557f58c44a0f 100644 (file)
@@ -203,7 +203,9 @@ spv_map_insert (struct hmap *map, double from, const char *to,
       else
         {
           union value v = { .f = mapping->to.d };
-          mapping->to.s = data_out_stretchy (&v, NULL, format, NULL);
+          mapping->to.s = data_out_stretchy (&v, NULL, format,
+                                             settings_get_fmt_settings (),
+                                             NULL);
           mapping->to.width = strlen (mapping->to.s);
         }
     }
@@ -803,7 +805,8 @@ decode_spvdx_source_variable (const struct spvxml_node *node,
             if (label_series->values[i].width < 0)
               {
                 union value v = { .f = label_series->values[i].d };
-                dest = data_out_stretchy (&v, "UTF-8", &s->format, NULL);
+                dest = data_out_stretchy (&v, "UTF-8", &s->format,
+                                          settings_get_fmt_settings (), NULL);
               }
             else
               dest = label_series->values[i].s;
@@ -965,8 +968,8 @@ pivot_value_from_data_value (const struct spv_data_value *data,
               && len == 23
               && data->s[len] == '\0')
             {
-              double date = calendar_gregorian_to_offset (year, month, day,
-                                                          NULL);
+              double date = calendar_gregorian_to_offset (
+                year, month, day, settings_get_fmt_settings (), NULL);
               if (date != SYSMIS)
                 {
                   v->type = PIVOT_VALUE_NUMERIC;
index 0737d2fb7b08a8401b46a167a866eccac6afa818..4e9cdfb418187f2454ef3434513e0f4f2b01b440 100644 (file)
@@ -75,7 +75,8 @@ value_to_text__ (union value v,
 {
   gchar *s;
 
-  s = data_out_stretchy (&v, encoding, format, NULL);
+  s = data_out_stretchy (&v, encoding, format, settings_get_fmt_settings (),
+                         NULL);
   if (fmt_is_numeric (format->type))
     g_strchug (s);
   else
@@ -135,7 +136,8 @@ text_to_value__ (const gchar *text,
     }
 
   value_init (val, width);
-  char *err = data_in (ss_cstr (text), UTF8, format->type, val, width, encoding);
+  char *err = data_in (ss_cstr (text), UTF8, format->type,
+                       settings_get_fmt_settings (), val, width, encoding);
 
   if (err)
     {
index d21facefe7bda7fb89850a2e3ada4a670052c037..d6f38a2d8f8e0dc3d8213ac62c78367f5fcb4050 100644 (file)
@@ -201,7 +201,8 @@ try_missing_value(const PsppireMissingValDialog *dialog, const gchar *text, unio
 
   value_init(vp, var_width);
   error_txt = data_in (ss_cstr(text), "UTF-8", dialog->format.type,
-                      vp, var_width, dialog->encoding);
+                       settings_get_fmt_settings (), vp, var_width,
+                       dialog->encoding);
   if (error_txt)
     {
       err_dialog (error_txt, GTK_WINDOW (dialog));
index cff30e3bf25f7f6f8a44f08790c1f5200022a379..b3cc11334c880cad3534101915b9c1ddd72d575c 100644 (file)
@@ -164,7 +164,8 @@ psppire_data_store_string_to_value (GtkTreeModel *model, gint col, gint row,
   if (vp == NULL)
     {
       xx = data_in (ss_cstr (in), psppire_dict_encoding (store->dict),
-                   fmt->type, &val, width, "UTF-8");
+                   fmt->type, settings_get_fmt_settings (),
+                    &val, width, "UTF-8");
     }
 
   GVariant *vrnt = value_variant_new (&val, width);
@@ -388,11 +389,13 @@ resize_datum (const union value *old, union value *new, const void *aux_)
   int new_width = var_get_width (aux->new_variable);
   const char *enc = dict_get_encoding (aux->dict);
   const struct fmt_spec *newfmt = var_get_print_format (aux->new_variable);
-  char *s = data_out (old, enc, var_get_print_format (aux->old_variable));
+  char *s = data_out (old, enc, var_get_print_format (aux->old_variable),
+                      settings_get_fmt_settings ());
   enum fmt_type type = (fmt_usable_for_input (newfmt->type)
                         ? newfmt->type
                         : FMT_DOLLAR);
-  free (data_in (ss_cstr (s), enc, type, new, new_width, enc));
+  free (data_in (ss_cstr (s), enc, type, settings_get_fmt_settings (),
+                 new, new_width, enc));
   free (s);
 }
 
@@ -838,8 +841,8 @@ psppire_data_store_data_in (PsppireDataStore *ds, casenumber casenum, gint idx,
                         FALSE);
   value_init (&value, width);
   ok = (datasheet_get_value (ds->datasheet, casenum, idx, &value)
-        && data_in_msg (input, UTF8, fmt->type, &value, width,
-                        dict_get_encoding (dict->dict))
+        && data_in_msg (input, UTF8, fmt->type, settings_get_fmt_settings (),
+                        &value, width, dict_get_encoding (dict->dict))
         && datasheet_put_value (ds->datasheet, casenum, idx, &value));
   value_destroy (&value, width);
 
index 4c0e9bc9cdd58ba86e1d01617f635ecf60f394cd..5ef83fcd2a3e63e216c870446df3a67c029d84fe 100644 (file)
@@ -721,6 +721,7 @@ my_read (struct casereader *reader, void *aux, casenumber idx)
              char *xx = data_in (ss_cstr (ss),
                                  "UTF-8",
                                  var_get_write_format (var)->type,
+                                  settings_get_fmt_settings (),
                                  v, var_get_width (var), "UTF-8");
 
              free (xx);
index 650fed8c144e2cdd0d2654f669cf4e4c71c6868d..2ff858e3328c94e5b7823a0fbf8568c8115f0db9 100644 (file)
@@ -517,7 +517,7 @@ psppire_value_entry_get_value (PsppireValueEntry *obj,
 
       new_text = gtk_entry_get_text (entry);
       return data_in_msg (ss_cstr (new_text), UTF8,
-                          obj->format.type,
+                          obj->format.type, settings_get_fmt_settings (),
                           value, width, obj->encoding);
     }
 }
index c6e0ca24d2ec9965b6bdd25d797bddbe2cecc166..bc5f11904e0cd358b34efb464151d0b31430a86e 100644 (file)
@@ -444,12 +444,14 @@ preview_custom (GtkWidget *w, gpointer data)
       union value v;
       v.f = 1234.56;
 
-      sample_text = g_strchug (data_out (&v, NULL, &dialog->fmt_l));
+      sample_text = g_strchug (data_out (&v, NULL, &dialog->fmt_l,
+                                         settings_get_fmt_settings ()));
       gtk_label_set_text (GTK_LABEL (dialog->label_psample), sample_text);
       g_free (sample_text);
 
       v.f = -v.f;
-      sample_text = g_strchug (data_out (&v, NULL, &dialog->fmt_l));
+      sample_text = g_strchug (data_out (&v, NULL, &dialog->fmt_l,
+                                         settings_get_fmt_settings ()));
       gtk_label_set_text (GTK_LABEL (dialog->label_nsample), sample_text);
       g_free (sample_text);
     }
index 27e61e4253b476607f37ef4f3ddecfb005db9e19..b338bdf9c4c742dc07dc81d393a37accdc9281ec 100644 (file)
@@ -29,6 +29,7 @@
 #include "libpspp/cast.h"
 #include "libpspp/i18n.h"
 #include "libpspp/message.h"
+#include "data/settings.h"
 #include "libpspp/str.h"
 #include "libpspp/misc.h"
 
@@ -156,10 +157,11 @@ syntax_gen_number (struct string *output,
       bool ok;
 
       v_in.f = number;
-      s = data_out (&v_in, "FIXME",  format);
+      s = data_out (&v_in, "FIXME", format, settings_get_fmt_settings ());
 
       /* FIXME: UTF8 encoded strings will fail here */
-      error = data_in (ss_cstr (s), C_ENCODING, format->type, &v_out, 0, NULL);
+      error = data_in (ss_cstr (s), C_ENCODING, format->type,
+                       settings_get_fmt_settings (), &v_out, 0, NULL);
       ok = error == NULL;
       free (error);