From: Ben Pfaff Date: Thu, 7 Jan 2021 00:24:46 +0000 (-0800) Subject: Make data input and output take a fmt_settings structure. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=07da9f454c17fb961cae09f6d7d505f7abb281c0;p=pspp Make data input and output take a fmt_settings structure. This will allow pivot_table formatting to supply its own. --- diff --git a/src/data/calendar.c b/src/data/calendar.c index a2bb7e6000..e07e7d63ac 100644 --- a/src/data/calendar.c +++ b/src/data/calendar.c @@ -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; } diff --git a/src/data/calendar.h b/src/data/calendar.h index be1e5cb828..02a9de28ac 100644 --- a/src/data/calendar.h +++ b/src/data/calendar.h @@ -19,7 +19,11 @@ along with this program. If not, see . #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); diff --git a/src/data/csv-file-writer.c b/src/data/csv-file-writer.c index 0e521a9744..d8c3e000ef 100644 --- a/src/data/csv-file-writer.c +++ b/src/data/csv-file-writer.c @@ -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 (" ")); diff --git a/src/data/data-in.c b/src/data/data-in.c index caf196ed4e..d734eb911d 100644 --- a/src/data/data-in.c +++ b/src/data/data-in.c @@ -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); } @@ -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.; diff --git a/src/data/data-in.h b/src/data/data-in.h index 7434905259..6540004d23 100644 --- a/src/data/data-in.h +++ b/src/data/data-in.h @@ -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 */ diff --git a/src/data/data-out.c b/src/data/data-out.c index cbd114b8e5..37a25a2672 100644 --- a/src/data/data-out.c +++ b/src/data/data-out.c @@ -66,14 +66,16 @@ static void rounder_format (const struct rounder *, int decimals, 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); } @@ -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; diff --git a/src/data/data-out.h b/src/data/data-out.h index 65ac60544f..f0bc9b24c8 100644 --- a/src/data/data-out.h +++ b/src/data/data-out.h @@ -21,21 +21,24 @@ #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 */ diff --git a/src/data/format-guesser.c b/src/data/format-guesser.c index 189320d293..7475b2946f 100644 --- a/src/data/format-guesser.c +++ b/src/data/format-guesser.c @@ -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) { diff --git a/src/data/format.c b/src/data/format.c index d0b87a503f..12939c5dce 100644 --- a/src/data/format.c +++ b/src/data/format.c @@ -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) diff --git a/src/data/format.h b/src/data/format.h index 8cc1b8718a..223ce1533d 100644 --- a/src/data/format.h +++ b/src/data/format.h @@ -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. */ diff --git a/src/data/gnumeric-reader.c b/src/data/gnumeric-reader.c index c1bf389d26..1378469c8a 100644 --- a/src/data/gnumeric-reader.c +++ b/src/data/gnumeric-reader.c @@ -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) diff --git a/src/data/ods-reader.c b/src/data/ods-reader.c index cac060f81d..bb72e2437c 100644 --- a/src/data/ods-reader.c +++ b/src/data/ods-reader.c @@ -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) { diff --git a/src/data/psql-reader.c b/src/data/psql-reader.c index a6062a0941..f4c44a177f 100644 --- a/src/data/psql-reader.c +++ b/src/data/psql-reader.c @@ -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); diff --git a/src/data/settings.c b/src/data/settings.c index 776cd51957..2479431b55 100644 --- a/src/data/settings.c +++ b/src/data/settings.c @@ -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, diff --git a/src/data/settings.h b/src/data/settings.h index 8ab7357d0a..f485ce152c 100644 --- a/src/data/settings.h +++ b/src/data/settings.h @@ -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); diff --git a/src/data/variable.c b/src/data/variable.c index 593e23ca72..4859b1303f 100644 --- a/src/data/variable.c +++ b/src/data/variable.c @@ -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); diff --git a/src/language/data-io/data-list.c b/src/language/data-io/data-list.c index 754341ccac..58224baa2d 100644 --- a/src/language/data-io/data-list.c +++ b/src/language/data-io/data-list.c @@ -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 { diff --git a/src/language/data-io/data-parser.c b/src/language/data-io/data-parser.c index 2f24b8a238..818c15a30f 100644 --- a/src/language/data-io/data-parser.c +++ b/src/language/data-io/data-parser.c @@ -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) diff --git a/src/language/data-io/get-data.c b/src/language/data-io/get-data.c index 66dd19f239..cdc8674005 100644 --- a/src/language/data-io/get-data.c +++ b/src/language/data-io/get-data.c @@ -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) diff --git a/src/language/data-io/matrix-reader.c b/src/language/data-io/matrix-reader.c index f1dbae184f..fbebb922fb 100644 --- a/src/language/data-io/matrix-reader.c +++ b/src/language/data-io/matrix-reader.c @@ -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; diff --git a/src/language/data-io/print.c b/src/language/data-io/print.c index 7111c03c65..1c63f9c2ce 100644 --- a/src/language/data-io/print.c +++ b/src/language/data-io/print.c @@ -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) diff --git a/src/language/data-io/save-translate.c b/src/language/data-io/save-translate.c index 0fb474631d..a565f4471c 100644 --- a/src/language/data-io/save-translate.c +++ b/src/language/data-io/save-translate.c @@ -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 = '"'; diff --git a/src/language/dictionary/mrsets.c b/src/language/dictionary/mrsets.c index 4a01ddd49f..5f544766e1 100644 --- a/src/language/dictionary/mrsets.c +++ b/src/language/dictionary/mrsets.c @@ -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 " diff --git a/src/language/expressions/helpers.c b/src/language/expressions/helpers.c index c69e440e4b..4a0a01b97b 100644 --- a/src/language/expressions/helpers.c +++ b/src/language/expressions/helpers.c @@ -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 diff --git a/src/language/expressions/operations.def b/src/language/expressions/operations.def index 19bf2b54a8..df2887044f 100644 --- a/src/language/expressions/operations.def +++ b/src/language/expressions/operations.def @@ -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); diff --git a/src/language/lexer/value-parser.c b/src/language/lexer/value-parser.c index 55707f6ac5..23b4def274 100644 --- a/src/language/lexer/value-parser.c +++ b/src/language/lexer/value-parser.c @@ -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); diff --git a/src/language/stats/crosstabs.q b/src/language/stats/crosstabs.q index 8c1fe5ba2f..50ba4a7342 100644 --- a/src/language/stats/crosstabs.q +++ b/src/language/stats/crosstabs.q @@ -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); } diff --git a/src/language/stats/flip.c b/src/language/stats/flip.c index e39e85fd5f..216c9d7921 100644 --- a/src/language/stats/flip.c +++ b/src/language/stats/flip.c @@ -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++) { diff --git a/src/language/utilities/set.q b/src/language/utilities/set.q index ddc7fc629d..4bdd910390 100644 --- a/src/language/utilities/set.q +++ b/src/language/utilities/set.q @@ -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 * diff --git a/src/language/xforms/recode.c b/src/language/xforms/recode.c index 94c5e4c7f2..b5e0e3fcde 100644 --- a/src/language/xforms/recode.c +++ b/src/language/xforms/recode.c @@ -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); diff --git a/src/math/box-whisker.c b/src/math/box-whisker.c index 53831824a0..3e501ccaeb 100644 --- a/src/math/box-whisker.c +++ b/src/math/box-whisker.c @@ -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); diff --git a/src/output/pivot-table.c b/src/output/pivot-table.c index 9e45f244e0..1fd136a577 100644 --- a/src/output/pivot-table.c +++ b/src/output/pivot-table.c @@ -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); } diff --git a/src/output/spv/spv-legacy-decoder.c b/src/output/spv/spv-legacy-decoder.c index b90d6b0ab3..b8005de5be 100644 --- a/src/output/spv/spv-legacy-decoder.c +++ b/src/output/spv/spv-legacy-decoder.c @@ -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; diff --git a/src/ui/gui/helper.c b/src/ui/gui/helper.c index 0737d2fb7b..4e9cdfb418 100644 --- a/src/ui/gui/helper.c +++ b/src/ui/gui/helper.c @@ -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) { diff --git a/src/ui/gui/missing-val-dialog.c b/src/ui/gui/missing-val-dialog.c index d21facefe7..d6f38a2d8f 100644 --- a/src/ui/gui/missing-val-dialog.c +++ b/src/ui/gui/missing-val-dialog.c @@ -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)); diff --git a/src/ui/gui/psppire-data-store.c b/src/ui/gui/psppire-data-store.c index cff30e3bf2..b3cc11334c 100644 --- a/src/ui/gui/psppire-data-store.c +++ b/src/ui/gui/psppire-data-store.c @@ -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); diff --git a/src/ui/gui/psppire-import-textfile.c b/src/ui/gui/psppire-import-textfile.c index 4c0e9bc9cd..5ef83fcd2a 100644 --- a/src/ui/gui/psppire-import-textfile.c +++ b/src/ui/gui/psppire-import-textfile.c @@ -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); diff --git a/src/ui/gui/psppire-value-entry.c b/src/ui/gui/psppire-value-entry.c index 650fed8c14..2ff858e332 100644 --- a/src/ui/gui/psppire-value-entry.c +++ b/src/ui/gui/psppire-value-entry.c @@ -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); } } diff --git a/src/ui/gui/var-type-dialog.c b/src/ui/gui/var-type-dialog.c index c6e0ca24d2..bc5f11904e 100644 --- a/src/ui/gui/var-type-dialog.c +++ b/src/ui/gui/var-type-dialog.c @@ -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); } diff --git a/src/ui/syntax-gen.c b/src/ui/syntax-gen.c index 27e61e4253..b338bdf9c4 100644 --- a/src/ui/syntax-gen.c +++ b/src/ui/syntax-gen.c @@ -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);