#define _GNU_SOURCE /* ask glibc for C99 lconv fields */ #include SCM_DEFINE (scm_localeconv, "localeconv", 0, 0, 0, (), "Return an ``lconv'' object representing current locale specific\n" "information.") #define FUNC_NAME s_scm_localtime { SCM result; const struct lconv *l; #define LCONV_STR(idx, field) \ SCM_VECTOR_SET (result, idx, scm_makfrom0str (l->field)) #define LCONV_INT(idx, field) \ SCM_VECTOR_SET (result, idx, SCM_MAKINUM (l->field)) /* group array ends with either 0 or CHAR_MAX */ #define LCONV_GRP(idx, field) \ do { \ SCM vec; \ int n, i; \ for (i = 0; l->field[i] != 0 && l->field[i] != CHAR_MAX; i++) \ ; \ n = i + 1; /* number of elements */ \ vec = scm_c_make_vector (n, SCM_BOOL_F); \ for (i = 0; i < n; i++) \ SCM_VECTOR_SET (result, idx, SCM_MAKINUM (l->field[i])); \ SCM_VECTOR_SET (result, idx, vec); \ } while (0) result = scm_c_make_vector (11, SCM_BOOL_F); SCM_DEFER_INTS; LCONV_STR ( 0, decimal_point); LCONV_STR ( 1, thousands_sep); LCONV_GRP ( 2, grouping); LCONV_STR ( 3, int_curr_symbol); LCONV_STR ( 4, currency_symbol); LCONV_STR ( 5, mon_decimal_point); LCONV_STR ( 6, mon_thousands_sep); LCONV_GRP ( 7, mon_grouping); LCONV_STR ( 8, positive_sign); LCONV_STR ( 9, negative_sign); LCONV_INT (10, int_frac_digits); LCONV_INT (11, frac_digits); LCONV_INT (12, p_cs_precedes); LCONV_INT (13, p_sep_by_space); LCONV_INT (14, n_cs_precedes); LCONV_INT (15, n_sep_by_space); LCONV_INT (16, p_sign_posn); LCONV_INT (17, n_sign_posn); /* C99 extras, apparently */ #if HAVE_LCONV_INT_P_CS_PRECEDES LCONV_INT (18, int_p_cs_precedes); LCONV_INT (19, int_p_sep_by_space); LCONV_INT (20, int_n_cs_precedes); LCONV_INT (21, int_n_sep_by_space); LCONV_INT (22, int_p_sign_posn); LCONV_INT (23, int_n_sign_posn); #endif return result; }