version 1.87, 2017/01/04 15:30:58 |
version 1.88, 2019/05/13 17:00:12 |
|
|
bool debug_sort; |
bool debug_sort; |
bool need_hint; |
bool need_hint; |
|
|
static bool gnusort_numeric_compatibility; |
|
|
|
static struct sort_mods default_sort_mods_object; |
static struct sort_mods default_sort_mods_object; |
struct sort_mods * const default_sort_mods = &default_sort_mods_object; |
struct sort_mods * const default_sort_mods = &default_sort_mods_object; |
|
|
static bool print_symbols_on_debug; |
|
|
|
/* |
/* |
* Arguments from file (when file0-from option is used: |
* Arguments from file (when file0-from option is used: |
*/ |
*/ |
|
|
} |
} |
|
|
/* |
/* |
* Convert "plain" symbol to wide symbol, with default value. |
|
*/ |
|
static void |
|
conv_mbtowc(wchar_t *wc, const char *c, const wchar_t def) |
|
{ |
|
int res; |
|
|
|
res = mbtowc(wc, c, MB_CUR_MAX); |
|
if (res < 1) |
|
*wc = def; |
|
} |
|
|
|
/* |
|
* Set current locale symbols. |
* Set current locale symbols. |
*/ |
*/ |
static void |
static void |
set_locale(void) |
set_locale(void) |
{ |
{ |
struct lconv *lc; |
|
const char *locale; |
const char *locale; |
|
|
setlocale(LC_ALL, ""); |
setlocale(LC_CTYPE, ""); |
|
|
/* Obtain LC_NUMERIC info */ |
|
lc = localeconv(); |
|
|
|
/* Convert to wide char form */ |
|
conv_mbtowc(&symbol_decimal_point, lc->decimal_point, |
|
symbol_decimal_point); |
|
conv_mbtowc(&symbol_thousands_sep, lc->thousands_sep, |
|
symbol_thousands_sep); |
|
conv_mbtowc(&symbol_positive_sign, lc->positive_sign, |
|
symbol_positive_sign); |
|
conv_mbtowc(&symbol_negative_sign, lc->negative_sign, |
|
symbol_negative_sign); |
|
|
|
if (getenv("GNUSORT_NUMERIC_COMPATIBILITY")) |
|
gnusort_numeric_compatibility = true; |
|
|
|
locale = setlocale(LC_COLLATE, NULL); |
locale = setlocale(LC_COLLATE, NULL); |
if (locale != NULL) { |
if (locale != NULL) { |
char *tmpl; |
char *tmpl; |
|
|
case 'n': |
case 'n': |
sm->nflag = true; |
sm->nflag = true; |
need_hint = true; |
need_hint = true; |
print_symbols_on_debug = true; |
|
break; |
break; |
case 'r': |
case 'r': |
sm->rflag = true; |
sm->rflag = true; |
|
|
case 'h': |
case 'h': |
sm->hflag = true; |
sm->hflag = true; |
need_hint = true; |
need_hint = true; |
print_symbols_on_debug = true; |
|
break; |
break; |
default: |
default: |
return false; |
return false; |
|
|
errno = EINVAL; |
errno = EINVAL; |
err(2, NULL); |
err(2, NULL); |
} |
} |
if (!gnusort_numeric_compatibility) { |
|
if (symbol_decimal_point == sort_opts_vals.field_sep) |
|
symbol_decimal_point = WEOF; |
|
if (symbol_thousands_sep == sort_opts_vals.field_sep) |
|
symbol_thousands_sep = WEOF; |
|
if (symbol_negative_sign == sort_opts_vals.field_sep) |
|
symbol_negative_sign = WEOF; |
|
if (symbol_positive_sign == sort_opts_vals.field_sep) |
|
symbol_positive_sign = WEOF; |
|
} |
|
break; |
break; |
case 'u': |
case 'u': |
sort_opts_vals.uflag = true; |
sort_opts_vals.uflag = true; |
|
|
setlocale(LC_COLLATE, NULL)); |
setlocale(LC_COLLATE, NULL)); |
if (byte_sort) |
if (byte_sort) |
printf("Byte sort is used\n"); |
printf("Byte sort is used\n"); |
if (print_symbols_on_debug) { |
|
printf("Decimal Point: <%lc>\n", symbol_decimal_point); |
|
if (symbol_thousands_sep) |
|
printf("Thousands separator: <%lc>\n", |
|
symbol_thousands_sep); |
|
printf("Positive sign: <%lc>\n", symbol_positive_sign); |
|
printf("Negative sign: <%lc>\n", symbol_negative_sign); |
|
} |
|
} |
} |
|
|
if (sort_opts_vals.cflag) |
if (sort_opts_vals.cflag) |