'simple' error message functions by Loic Grenie <loic.grenie@gmail.com>.
[oweals/busybox.git] / coreutils / ls.c
index 8545edda934cce187d9fc999fb3d6349f431ab30..92a9a289dc9dbae829b121e0143349938b1ed99e 100644 (file)
@@ -120,9 +120,9 @@ SPLIT_SUBDIR    = 2,
 static smallint show_color;
 /* long option entry used only for --color, which has no short option
  * equivalent */
-static const char ls_color_opt[] =
+static const char ls_color_opt[] ALIGN1 =
        "color\0" Optional_argument "\xff" /* no short equivalent */
-       "\0";
+       ;
 #else
 enum { show_color = 0 };
 #endif
@@ -171,7 +171,7 @@ static struct dnode *my_stat(const char *fullname, const char *name, int force_f
                }
 #endif
                if (stat(fullname, &dstat)) {
-                       bb_perror_msg("%s", fullname);
+                       bb_simple_perror_msg(fullname);
                        status = EXIT_FAILURE;
                        return 0;
                }
@@ -182,7 +182,7 @@ static struct dnode *my_stat(const char *fullname, const char *name, int force_f
                }
 #endif
                if (lstat(fullname, &dstat)) {
-                       bb_perror_msg("%s", fullname);
+                       bb_simple_perror_msg(fullname);
                        status = EXIT_FAILURE;
                        return 0;
                }
@@ -451,7 +451,7 @@ static void showdirs(struct dnode **dn, int ndirs, int first)
        for (i = 0; i < ndirs; i++) {
                if (all_fmt & (DISP_DIRNAME | DISP_RECURSIVE)) {
                        if (!first)
-                               puts("");
+                               bb_putchar('\n');
                        first = 0;
                        printf("%s:\n", dn[i]->fullname);
                }
@@ -710,7 +710,8 @@ static int list_single(struct dnode *dn)
 /* "[-]SXvThw", GNU options, busybox optionally supports */
 /* "[-]K", SELinux mandated options, busybox optionally supports */
 /* "[-]e", I think we made this one up */
-static const char ls_options[] = "Cadil1gnsxAk"
+static const char ls_options[] ALIGN1 =
+       "Cadil1gnsxAk"
        USE_FEATURE_LS_TIMESTAMPS("cetu")
        USE_FEATURE_LS_SORTFILES("SXrv")
        USE_FEATURE_LS_FILETYPES("Fp")
@@ -811,7 +812,7 @@ int ls_main(int argc, char **argv)
 
 #if ENABLE_FEATURE_AUTOWIDTH
        /* Obtain the terminal width */
-       get_terminal_width_height(STDOUT_FILENO, &terminal_width, NULL);
+       get_terminal_width_height(STDIN_FILENO, &terminal_width, NULL);
        /* Go one less... */
        terminal_width--;
 #endif
@@ -819,14 +820,14 @@ int ls_main(int argc, char **argv)
        /* process options */
        USE_FEATURE_LS_COLOR(applet_long_options = ls_color_opt;)
 #if ENABLE_FEATURE_AUTOWIDTH
-       opt = getopt32(argc, argv, ls_options, &tabstops_str, &terminal_width_str
+       opt = getopt32(argv, ls_options, &tabstops_str, &terminal_width_str
                                USE_FEATURE_LS_COLOR(, &color_opt));
        if (tabstops_str)
                tabstops = xatou(tabstops_str);
        if (terminal_width_str)
                terminal_width = xatou(terminal_width_str);
 #else
-       opt = getopt32(argc, argv, ls_options USE_FEATURE_LS_COLOR(, &color_opt));
+       opt = getopt32(argv, ls_options USE_FEATURE_LS_COLOR(, &color_opt));
 #endif
        for (i = 0; opt_flags[i] != (1U<<31); i++) {
                if (opt & (1 << i)) {