- assert (is_fmt_type (type));
- return &settings->styles[type];
-}
-
-/* Sets the number style for TYPE to have the given DECIMAL and GROUPING
- characters, negative prefix NEG_PREFIX, prefix PREFIX, suffix SUFFIX, and
- negative suffix NEG_SUFFIX. All of the strings are UTF-8 encoded. */
-void
-fmt_settings_set_style (struct fmt_settings *settings, enum fmt_type type,
- char decimal, char grouping,
- const char *neg_prefix, const char *prefix,
- const char *suffix, const char *neg_suffix)
-{
- struct fmt_number_style *style = &settings->styles[type];
- int total_bytes, total_width;
+ verify (FMT_F < 6);
+ verify (FMT_COMMA < 6);
+ verify (FMT_DOT < 6);
+ verify (FMT_DOLLAR < 6);
+ verify (FMT_PCT < 6);
+ verify (FMT_E < 6);
+
+#define OPPOSITE(C) ((C) == ',' ? '.' : ',')
+#define AFFIX(S) { .s = (char *) (S), .width = sizeof (S) - 1 }
+#define NS(PREFIX, SUFFIX, DECIMAL, GROUPING) { \
+ .neg_prefix = AFFIX ("-"), \
+ .prefix = AFFIX (PREFIX), \
+ .suffix = AFFIX (SUFFIX), \
+ .neg_suffix = AFFIX (""), \
+ .decimal = DECIMAL, \
+ .grouping = GROUPING, \
+ }
+#define ANS(DECIMAL, GROUPING) { \
+ [FMT_F] = NS( "", "", DECIMAL, 0), \
+ [FMT_E] = NS( "", "", DECIMAL, 0), \
+ [FMT_COMMA] = NS( "", "", DECIMAL, GROUPING), \
+ [FMT_DOT] = NS( "", "", GROUPING, DECIMAL), \
+ [FMT_DOLLAR] = NS("$", "", DECIMAL, GROUPING), \
+ [FMT_PCT] = NS( "", "%", DECIMAL, 0), \
+ }
+
+ static const struct fmt_number_style period_styles[6] = ANS ('.', ',');
+ static const struct fmt_number_style comma_styles[6] = ANS (',', '.');
+ static const struct fmt_number_style default_style = NS ("", "", '.', 0);