find: add zeroing of G.xxx; ftpd - remove extraneous zeroing of G.xxx
[oweals/busybox.git] / coreutils / ls.c
index 20b979db6bb9d91571dd893ce978cf0f91af5128..19d38049cc0af3e9f0d59f4b4724982a4109962d 100644 (file)
@@ -264,15 +264,15 @@ struct globals {
 };
 #define G (*(struct globals*)&bb_common_bufsiz1)
 #if ENABLE_FEATURE_LS_COLOR
-#define show_color     (G.show_color    )
+# define show_color     (G.show_color    )
 #else
 enum { show_color = 0 };
 #endif
-#define exit_code      (G.exit_code     )
-#define all_fmt        (G.all_fmt       )
+#define exit_code       (G.exit_code     )
+#define all_fmt         (G.all_fmt       )
 #if ENABLE_FEATURE_AUTOWIDTH
-#define tabstops       (G.tabstops      )
-#define terminal_width (G.terminal_width)
+# define tabstops       (G.tabstops      )
+# define terminal_width (G.terminal_width)
 #else
 enum {
        tabstops = COLUMN_GAP,
@@ -280,8 +280,8 @@ enum {
 };
 #endif
 #define current_time_t (G.current_time_t)
-/* memset: we have to zero it out because of NOEXEC */
 #define INIT_G() do { \
+       /* we have to zero it out because of NOEXEC */ \
        memset(&G, 0, sizeof(G)); \
        IF_FEATURE_AUTOWIDTH(tabstops = COLUMN_GAP;) \
        IF_FEATURE_AUTOWIDTH(terminal_width = TERMINAL_WIDTH;) \
@@ -289,20 +289,6 @@ enum {
 } while (0)
 
 
-#if ENABLE_FEATURE_ASSUME_UNICODE
-/* libbb candidate */
-static size_t mbstrlen(const char *string)
-{
-       size_t width = mbstowcs(NULL, string, INT_MAX);
-       if (width == (size_t)-1L)
-               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;
@@ -570,7 +556,7 @@ static void showfiles(struct dnode **dn, int nfiles)
        } 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;
                }
@@ -717,7 +703,7 @@ static int print_name(const char *name)
 {
        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
@@ -737,7 +723,7 @@ static int print_name(const char *name)
        /* No -Q: */
 #if ENABLE_FEATURE_ASSUME_UNICODE
        fputs(name, stdout);
-       return mbstrlen(name);
+       return bb_mbstrlen(name);
 #else
        return printf("%s", name);
 #endif