diff options
Diffstat (limited to 'coreutils/ls.c')
-rw-r--r-- | coreutils/ls.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/coreutils/ls.c b/coreutils/ls.c index 8a6faf23f..20b979db6 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c | |||
@@ -30,12 +30,9 @@ | |||
30 | * [2009-03] | 30 | * [2009-03] |
31 | * ls sorts listing now, and supports almost all options. | 31 | * ls sorts listing now, and supports almost all options. |
32 | */ | 32 | */ |
33 | |||
34 | #include "libbb.h" | 33 | #include "libbb.h" |
34 | #include "unicode.h" | ||
35 | 35 | ||
36 | #if ENABLE_FEATURE_ASSUME_UNICODE | ||
37 | #include <wchar.h> | ||
38 | #endif | ||
39 | 36 | ||
40 | /* This is a NOEXEC applet. Be very careful! */ | 37 | /* This is a NOEXEC applet. Be very careful! */ |
41 | 38 | ||
@@ -296,9 +293,8 @@ enum { | |||
296 | /* libbb candidate */ | 293 | /* libbb candidate */ |
297 | static size_t mbstrlen(const char *string) | 294 | static size_t mbstrlen(const char *string) |
298 | { | 295 | { |
299 | size_t width = mbsrtowcs(NULL /*dest*/, &string, | 296 | size_t width = mbstowcs(NULL, string, INT_MAX); |
300 | MAXINT(size_t) /*len*/, NULL /*state*/); | 297 | if (width == (size_t)-1L) |
301 | if (width == (size_t)-1) | ||
302 | return strlen(string); | 298 | return strlen(string); |
303 | return width; | 299 | return width; |
304 | } | 300 | } |
@@ -932,6 +928,8 @@ int ls_main(int argc UNUSED_PARAM, char **argv) | |||
932 | 928 | ||
933 | INIT_G(); | 929 | INIT_G(); |
934 | 930 | ||
931 | check_unicode_in_env(); | ||
932 | |||
935 | all_fmt = LIST_SHORT | | 933 | all_fmt = LIST_SHORT | |
936 | (ENABLE_FEATURE_LS_SORTFILES * (SORT_NAME | SORT_FORWARD)); | 934 | (ENABLE_FEATURE_LS_SORTFILES * (SORT_NAME | SORT_FORWARD)); |
937 | 935 | ||