aboutsummaryrefslogtreecommitdiff
path: root/coreutils/ls.c
diff options
context:
space:
mode:
Diffstat (limited to 'coreutils/ls.c')
-rw-r--r--coreutils/ls.c20
1 files changed, 3 insertions, 17 deletions
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 20b979db6..827b35089 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -289,20 +289,6 @@ enum {
289} while (0) 289} while (0)
290 290
291 291
292#if ENABLE_FEATURE_ASSUME_UNICODE
293/* libbb candidate */
294static size_t mbstrlen(const char *string)
295{
296 size_t width = mbstowcs(NULL, string, INT_MAX);
297 if (width == (size_t)-1L)
298 return strlen(string);
299 return width;
300}
301#else
302#define mbstrlen(string) strlen(string)
303#endif
304
305
306static struct dnode *my_stat(const char *fullname, const char *name, int force_follow) 292static struct dnode *my_stat(const char *fullname, const char *name, int force_follow)
307{ 293{
308 struct stat dstat; 294 struct stat dstat;
@@ -570,7 +556,7 @@ static void showfiles(struct dnode **dn, int nfiles)
570 } else { 556 } else {
571 /* find the longest file name, use that as the column width */ 557 /* find the longest file name, use that as the column width */
572 for (i = 0; i < nfiles; i++) { 558 for (i = 0; i < nfiles; i++) {
573 int len = mbstrlen(dn[i]->name); 559 int len = bb_mbstrlen(dn[i]->name);
574 if (column_width < len) 560 if (column_width < len)
575 column_width = len; 561 column_width = len;
576 } 562 }
@@ -717,7 +703,7 @@ static int print_name(const char *name)
717{ 703{
718 if (option_mask32 & OPT_Q) { 704 if (option_mask32 & OPT_Q) {
719#if ENABLE_FEATURE_ASSUME_UNICODE 705#if ENABLE_FEATURE_ASSUME_UNICODE
720 int len = 2 + mbstrlen(name); 706 int len = 2 + bb_mbstrlen(name);
721#else 707#else
722 int len = 2; 708 int len = 2;
723#endif 709#endif
@@ -737,7 +723,7 @@ static int print_name(const char *name)
737 /* No -Q: */ 723 /* No -Q: */
738#if ENABLE_FEATURE_ASSUME_UNICODE 724#if ENABLE_FEATURE_ASSUME_UNICODE
739 fputs(name, stdout); 725 fputs(name, stdout);
740 return mbstrlen(name); 726 return bb_mbstrlen(name);
741#else 727#else
742 return printf("%s", name); 728 return printf("%s", name);
743#endif 729#endif