aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-08-02 20:18:29 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-08-02 20:18:29 +0200
commit4cd4eb43320de6ecccb3b69087daee325d0bbfc1 (patch)
tree44db952d0feea229c4359bd5a2f8dc59db5ee07d /coreutils
parent6a98f95373d60d48001299797f52b1f19c7ffecd (diff)
downloadbusybox-w32-4cd4eb43320de6ecccb3b69087daee325d0bbfc1.tar.gz
busybox-w32-4cd4eb43320de6ecccb3b69087daee325d0bbfc1.tar.bz2
busybox-w32-4cd4eb43320de6ecccb3b69087daee325d0bbfc1.zip
apply post-1.14.2 patches
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to '')
-rw-r--r--coreutils/df.c7
-rw-r--r--coreutils/ls.c63
-rw-r--r--coreutils/test.c13
3 files changed, 56 insertions, 27 deletions
diff --git a/coreutils/df.c b/coreutils/df.c
index dfd6e0b41..e9a865c19 100644
--- a/coreutils/df.c
+++ b/coreutils/df.c
@@ -44,7 +44,6 @@ int df_main(int argc, char **argv)
44 FILE *mount_table; 44 FILE *mount_table;
45 struct mntent *mount_entry; 45 struct mntent *mount_entry;
46 struct statfs s; 46 struct statfs s;
47 static const char ignored_mounts[] ALIGN1 = "rootfs\0";
48 47
49 enum { 48 enum {
50 OPT_KILO = (1 << 0), 49 OPT_KILO = (1 << 0),
@@ -120,7 +119,7 @@ int df_main(int argc, char **argv)
120 mount_point = *argv++; 119 mount_point = *argv++;
121 if (!mount_point) 120 if (!mount_point)
122 break; 121 break;
123 mount_entry = find_mount_point(mount_point, bb_path_mtab_file); 122 mount_entry = find_mount_point(mount_point);
124 if (!mount_entry) { 123 if (!mount_entry) {
125 bb_error_msg("%s: can't find mount point", mount_point); 124 bb_error_msg("%s: can't find mount point", mount_point);
126 set_error: 125 set_error:
@@ -154,8 +153,8 @@ int df_main(int argc, char **argv)
154 ) / (blocks_used + s.f_bavail); 153 ) / (blocks_used + s.f_bavail);
155 } 154 }
156 155
157 /* GNU coreutils 6.10 skip certain mounts, try to be compatible. */ 156 /* GNU coreutils 6.10 skips certain mounts, try to be compatible. */
158 if (index_in_strings(device, ignored_mounts) != -1) 157 if (strcmp(device, "rootfs") == 0)
159 continue; 158 continue;
160 159
161#ifdef WHY_WE_DO_IT_FOR_DEV_ROOT_ONLY 160#ifdef WHY_WE_DO_IT_FOR_DEV_ROOT_ONLY
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 61baa9a11..38957e93d 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -144,8 +144,7 @@ static const char ls_options[] ALIGN1 =
144 USE_FEATURE_LS_FOLLOWLINKS("L") /* 1, 24 */ 144 USE_FEATURE_LS_FOLLOWLINKS("L") /* 1, 24 */
145 USE_FEATURE_LS_RECURSIVE("R") /* 1, 25 */ 145 USE_FEATURE_LS_RECURSIVE("R") /* 1, 25 */
146 USE_FEATURE_HUMAN_READABLE("h") /* 1, 26 */ 146 USE_FEATURE_HUMAN_READABLE("h") /* 1, 26 */
147 USE_SELINUX("K") /* 1, 27 */ 147 USE_SELINUX("KZ") /* 2, 28 */
148 USE_SELINUX("Z") /* 1, 28 */
149 USE_FEATURE_AUTOWIDTH("T:w:") /* 2, 30 */ 148 USE_FEATURE_AUTOWIDTH("T:w:") /* 2, 30 */
150 ; 149 ;
151enum { 150enum {
@@ -162,6 +161,16 @@ enum {
162 OPT_Q = (1 << 10), 161 OPT_Q = (1 << 10),
163 //OPT_A = (1 << 11), 162 //OPT_A = (1 << 11),
164 //OPT_k = (1 << 12), 163 //OPT_k = (1 << 12),
164 OPTBIT_color = 13
165 + 4 * ENABLE_FEATURE_LS_TIMESTAMPS
166 + 4 * ENABLE_FEATURE_LS_SORTFILES
167 + 2 * ENABLE_FEATURE_LS_FILETYPES
168 + 1 * ENABLE_FEATURE_LS_FOLLOWLINKS
169 + 1 * ENABLE_FEATURE_LS_RECURSIVE
170 + 1 * ENABLE_FEATURE_HUMAN_READABLE
171 + 2 * ENABLE_SELINUX
172 + 2 * ENABLE_FEATURE_AUTOWIDTH,
173 OPT_color = 1 << OPTBIT_color,
165}; 174};
166 175
167enum { 176enum {
@@ -889,16 +898,6 @@ static int list_single(const struct dnode *dn)
889} 898}
890 899
891 900
892/* colored LS support by JaWi, janwillem.janssen@lxtreme.nl */
893#if ENABLE_FEATURE_LS_COLOR
894/* long option entry used only for --color, which has no short option
895 * equivalent */
896static const char ls_color_opt[] ALIGN1 =
897 "color\0" Optional_argument "\xff" /* no short equivalent */
898 ;
899#endif
900
901
902int ls_main(int argc UNUSED_PARAM, char **argv) 901int ls_main(int argc UNUSED_PARAM, char **argv)
903{ 902{
904 struct dnode **dnd; 903 struct dnode **dnd;
@@ -911,8 +910,25 @@ int ls_main(int argc UNUSED_PARAM, char **argv)
911 int dnfiles; 910 int dnfiles;
912 int dndirs; 911 int dndirs;
913 int i; 912 int i;
913#if ENABLE_FEATURE_LS_COLOR
914 /* colored LS support by JaWi, janwillem.janssen@lxtreme.nl */
915 /* coreutils 6.10:
916 * # ls --color=BOGUS
917 * ls: invalid argument 'BOGUS' for '--color'
918 * Valid arguments are:
919 * 'always', 'yes', 'force'
920 * 'never', 'no', 'none'
921 * 'auto', 'tty', 'if-tty'
922 * (and substrings: "--color=alwa" work too)
923 */
924 static const char ls_longopts[] ALIGN1 =
925 "color\0" Optional_argument "\xff"; /* no short equivalent */
926 static const char color_str[] ALIGN1 =
927 "always\0""yes\0""force\0"
928 "auto\0""tty\0""if-tty\0";
914 /* need to initialize since --color has _an optional_ argument */ 929 /* need to initialize since --color has _an optional_ argument */
915 USE_FEATURE_LS_COLOR(const char *color_opt = "always";) 930 const char *color_opt = color_str; /* "always" */
931#endif
916 932
917 INIT_G(); 933 INIT_G();
918 934
@@ -927,7 +943,7 @@ int ls_main(int argc UNUSED_PARAM, char **argv)
927#endif 943#endif
928 944
929 /* process options */ 945 /* process options */
930 USE_FEATURE_LS_COLOR(applet_long_options = ls_color_opt;) 946 USE_FEATURE_LS_COLOR(applet_long_options = ls_longopts;)
931#if ENABLE_FEATURE_AUTOWIDTH 947#if ENABLE_FEATURE_AUTOWIDTH
932 opt_complementary = "T+:w+"; /* -T N, -w N */ 948 opt_complementary = "T+:w+"; /* -T N, -w N */
933 opt = getopt32(argv, ls_options, &tabstops, &terminal_width 949 opt = getopt32(argv, ls_options, &tabstops, &terminal_width
@@ -966,13 +982,20 @@ int ls_main(int argc UNUSED_PARAM, char **argv)
966 if (!p || (p[0] && strcmp(p, "none") != 0)) 982 if (!p || (p[0] && strcmp(p, "none") != 0))
967 show_color = 1; 983 show_color = 1;
968 } 984 }
969 if (opt & (1 << i)) { /* next flag after short options */ 985 if (opt & OPT_color) {
970 if (strcmp("always", color_opt) == 0) 986 if (color_opt[0] == 'n')
971 show_color = 1;
972 else if (strcmp("never", color_opt) == 0)
973 show_color = 0; 987 show_color = 0;
974 else if (strcmp("auto", color_opt) == 0 && isatty(STDOUT_FILENO)) 988 else switch (index_in_substrings(color_str, color_opt)) {
975 show_color = 1; 989 case 3:
990 case 4:
991 case 5:
992 if (isatty(STDOUT_FILENO)) {
993 case 0:
994 case 1:
995 case 2:
996 show_color = 1;
997 }
998 }
976 } 999 }
977#endif 1000#endif
978 1001
diff --git a/coreutils/test.c b/coreutils/test.c
index ae40192a2..ab7b41684 100644
--- a/coreutils/test.c
+++ b/coreutils/test.c
@@ -571,7 +571,14 @@ static number_t nexpr(enum token n)
571 571
572 nest_msg(">nexpr(%s)\n", TOKSTR[n]); 572 nest_msg(">nexpr(%s)\n", TOKSTR[n]);
573 if (n == UNOT) { 573 if (n == UNOT) {
574 res = !nexpr(check_operator(*++args)); 574 n = check_operator(*++args);
575 if (n == EOI) {
576 /* special case: [ ! ], [ a -a ! ] are valid */
577 /* IOW, "! ARG" may miss ARG */
578 unnest_msg("<nexpr:1 (!EOI)\n");
579 return 1;
580 }
581 res = !nexpr(n);
575 unnest_msg("<nexpr:%lld\n", res); 582 unnest_msg("<nexpr:%lld\n", res);
576 return res; 583 return res;
577 } 584 }
@@ -742,7 +749,7 @@ int test_main(int argc, char **argv)
742 check_operator(argv[1]); 749 check_operator(argv[1]);
743 if (last_operator->op_type == BINOP) { 750 if (last_operator->op_type == BINOP) {
744 /* "test [!] arg1 <binary_op> arg2" */ 751 /* "test [!] arg1 <binary_op> arg2" */
745 args = &argv[0]; 752 args = argv;
746 res = (binop() == 0); 753 res = (binop() == 0);
747 goto ret; 754 goto ret;
748 } 755 }
@@ -755,7 +762,7 @@ int test_main(int argc, char **argv)
755 argv--; 762 argv--;
756 } 763 }
757#endif 764#endif
758 args = &argv[0]; 765 args = argv;
759 res = !oexpr(check_operator(*args)); 766 res = !oexpr(check_operator(*args));
760 767
761 if (*args != NULL && *++args != NULL) { 768 if (*args != NULL && *++args != NULL) {