* [2009-03]
* ls sorts listing now, and supports almost all options.
*/
-
#include "libbb.h"
+#include "unicode.h"
-#if ENABLE_FEATURE_ASSUME_UNICODE
-#include <wchar.h>
-#endif
/* This is a NOEXEC applet. Be very careful! */
} while (0)
-#if ENABLE_FEATURE_ASSUME_UNICODE
-/* libbb candidate */
-static size_t mbstrlen(const char *string)
-{
- size_t width = mbsrtowcs(NULL /*dest*/, &string,
- MAXINT(size_t) /*len*/, NULL /*state*/);
- if (width == (size_t)-1)
- return strlen(string);
- return width;
-}
-#else
-#define mbstrlen(string) strlen(string)
-#endif
-
-
static struct dnode *my_stat(const char *fullname, const char *name, int force_follow)
{
struct stat dstat;
} else {
/* find the longest file name, use that as the column width */
for (i = 0; i < nfiles; i++) {
- int len = mbstrlen(dn[i]->name);
+ int len = bb_mbstrlen(dn[i]->name);
if (column_width < len)
column_width = len;
}
{
if (option_mask32 & OPT_Q) {
#if ENABLE_FEATURE_ASSUME_UNICODE
- int len = 2 + mbstrlen(name);
+ int len = 2 + bb_mbstrlen(name);
#else
int len = 2;
#endif
/* No -Q: */
#if ENABLE_FEATURE_ASSUME_UNICODE
fputs(name, stdout);
- return mbstrlen(name);
+ return bb_mbstrlen(name);
#else
return printf("%s", name);
#endif
INIT_G();
+ check_unicode_in_env();
+
all_fmt = LIST_SHORT |
(ENABLE_FEATURE_LS_SORTFILES * (SORT_NAME | SORT_FORWARD));