Changeset View
Changeset View
Standalone View
Standalone View
usr.bin/sort/sort.c
Show First 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | #endif | ||||
"[--version-sort] [--random-sort [--random-source file]] " | "[--version-sort] [--random-sort [--random-source file]] " | ||||
"[--compress-program program] [file ...]\n" }; | "[--compress-program program] [file ...]\n" }; | ||||
struct sort_opts sort_opts_vals; | struct sort_opts sort_opts_vals; | ||||
bool debug_sort; | bool debug_sort; | ||||
bool need_hint; | bool need_hint; | ||||
size_t mb_cur_max; | |||||
markj: This isn't particularly obvious, but the type of MB_CUR_MAX is `size_t`, not `int`, so the type… | |||||
#if defined(SORT_THREADS) | #if defined(SORT_THREADS) | ||||
unsigned int ncpu = 1; | unsigned int ncpu = 1; | ||||
size_t nthreads = 1; | size_t nthreads = 1; | ||||
#endif | #endif | ||||
static bool gnusort_numeric_compatibility; | static bool gnusort_numeric_compatibility; | ||||
static struct sort_mods default_sort_mods_object; | static struct sort_mods default_sort_mods_object; | ||||
▲ Show 20 Lines • Show All 190 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
static void | static void | ||||
conv_mbtowc(wchar_t *wc, const char *c, const wchar_t def) | conv_mbtowc(wchar_t *wc, const char *c, const wchar_t def) | ||||
{ | { | ||||
if (wc && c) { | if (wc && c) { | ||||
int res; | int res; | ||||
res = mbtowc(wc, c, MB_CUR_MAX); | res = mbtowc(wc, c, mb_cur_max); | ||||
if (res < 1) | if (res < 1) | ||||
*wc = def; | *wc = def; | ||||
} | } | ||||
} | } | ||||
/* | /* | ||||
* Set current locale symbols. | * Set current locale symbols. | ||||
*/ | */ | ||||
static void | static void | ||||
set_locale(void) | set_locale(void) | ||||
{ | { | ||||
struct lconv *lc; | struct lconv *lc; | ||||
const char *locale; | const char *locale; | ||||
setlocale(LC_ALL, ""); | setlocale(LC_ALL, ""); | ||||
mb_cur_max = MB_CUR_MAX; | |||||
lc = localeconv(); | lc = localeconv(); | ||||
if (lc) { | if (lc) { | ||||
/* obtain LC_NUMERIC info */ | /* obtain LC_NUMERIC info */ | ||||
/* Convert to wide char form */ | /* Convert to wide char form */ | ||||
conv_mbtowc(&symbol_decimal_point, lc->decimal_point, | conv_mbtowc(&symbol_decimal_point, lc->decimal_point, | ||||
symbol_decimal_point); | symbol_decimal_point); | ||||
▲ Show 20 Lines • Show All 661 Lines • ▼ Show 20 Lines | bool mef_flags[NUMBER_OF_MUTUALLY_EXCLUSIVE_FLAGS] = | ||||
{ false, false, false, false, false, false }; | { false, false, false, false, false, false }; | ||||
result = 0; | result = 0; | ||||
outfile = sort_strdup("-"); | outfile = sort_strdup("-"); | ||||
real_outfile = NULL; | real_outfile = NULL; | ||||
struct sort_mods *sm = &default_sort_mods_object; | struct sort_mods *sm = &default_sort_mods_object; | ||||
init_tmp_files(); | init_tmp_files(); | ||||
Not Done Inline ActionsI believe the assignment should come after the call to set_locale(). I would suggest having the assignment occur at the end of that function. markj: I believe the assignment should come after the call to `set_locale()`. I would suggest having… | |||||
set_signal_handler(); | set_signal_handler(); | ||||
set_hw_params(); | set_hw_params(); | ||||
set_locale(); | set_locale(); | ||||
set_tmpdir(); | set_tmpdir(); | ||||
set_sort_opts(); | set_sort_opts(); | ||||
▲ Show 20 Lines • Show All 334 Lines • Show Last 20 Lines |
This isn't particularly obvious, but the type of MB_CUR_MAX is size_t, not int, so the type of the cached value should match.