aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn L McGrath <bug1@ihug.co.nz>2005-12-11 03:09:05 +0000
committerGlenn L McGrath <bug1@ihug.co.nz>2005-12-11 03:09:05 +0000
commit0bd0257fe0fb3835af056ec933b010aad2722f93 (patch)
treec6410295b7270b93ffab84419419b9b05586e370
parentd77b781c1f0f0913b252c8f207f5518e77733dc3 (diff)
downloadbusybox-w32-0bd0257fe0fb3835af056ec933b010aad2722f93.tar.gz
busybox-w32-0bd0257fe0fb3835af056ec933b010aad2722f93.tar.bz2
busybox-w32-0bd0257fe0fb3835af056ec933b010aad2722f93.zip
Add build options to control SuS compatability, allows numeric
option handling to be disabled. Defaults to enabled, so no changes in default behaviour
-rw-r--r--coreutils/fold.c3
-rw-r--r--coreutils/head.c3
-rw-r--r--coreutils/tail.c2
-rw-r--r--include/usage.h2
-rw-r--r--sysdeps/linux/Config.in15
5 files changed, 24 insertions, 1 deletions
diff --git a/coreutils/fold.c b/coreutils/fold.c
index 8f74ed88d..ee0fdc250 100644
--- a/coreutils/fold.c
+++ b/coreutils/fold.c
@@ -52,6 +52,8 @@ extern int fold_main(int argc, char **argv)
52 int i; 52 int i;
53 int errs = 0; 53 int errs = 0;
54 54
55
56#ifdef CONFIG_FEATURE_SUSv2_OBSOLETE
55 /* Turn any numeric options into -w options. */ 57 /* Turn any numeric options into -w options. */
56 for (i = 1; i < argc; i++) { 58 for (i = 1; i < argc; i++) {
57 char const *a = argv[i]; 59 char const *a = argv[i];
@@ -69,6 +71,7 @@ extern int fold_main(int argc, char **argv)
69 } 71 }
70 } 72 }
71 } 73 }
74#endif
72 75
73 flags = bb_getopt_ulflags(argc, argv, "bsw:", &w_opt); 76 flags = bb_getopt_ulflags(argc, argv, "bsw:", &w_opt);
74 if (flags & FLAG_WIDTH) 77 if (flags & FLAG_WIDTH)
diff --git a/coreutils/head.c b/coreutils/head.c
index dab4de11b..a20873333 100644
--- a/coreutils/head.c
+++ b/coreutils/head.c
@@ -56,6 +56,7 @@ int head_main(int argc, char **argv)
56 int c; 56 int c;
57 int retval = EXIT_SUCCESS; 57 int retval = EXIT_SUCCESS;
58 58
59#if defined CONFIG_FEATURE_SUSv2 || defined CONFIG_FEATURE_FANCY_HEAD
59 /* Allow legacy syntax of an initial numeric option without -n. */ 60 /* Allow legacy syntax of an initial numeric option without -n. */
60 if ((argc > 1) && (argv[1][0] == '-') 61 if ((argc > 1) && (argv[1][0] == '-')
61 /* && (isdigit)(argv[1][1]) */ 62 /* && (isdigit)(argv[1][1]) */
@@ -66,7 +67,9 @@ int head_main(int argc, char **argv)
66 p = (*argv) + 1; 67 p = (*argv) + 1;
67 goto GET_COUNT; 68 goto GET_COUNT;
68 } 69 }
70#endif
69 71
72 /* No size benefit in converting this to bb_getopt_ulflags */
70 while ((opt = getopt(argc, argv, head_opts)) > 0) { 73 while ((opt = getopt(argc, argv, head_opts)) > 0) {
71 switch(opt) { 74 switch(opt) {
72#ifdef CONFIG_FEATURE_FANCY_HEAD 75#ifdef CONFIG_FEATURE_FANCY_HEAD
diff --git a/coreutils/tail.c b/coreutils/tail.c
index 1db1e2b0f..cc1517a7e 100644
--- a/coreutils/tail.c
+++ b/coreutils/tail.c
@@ -121,6 +121,7 @@ int tail_main(int argc, char **argv)
121 char *s, *buf; 121 char *s, *buf;
122 const char *fmt; 122 const char *fmt;
123 123
124#ifdef CONFIG_FEATURE_SUSv2
124 /* Allow legacy syntax of an initial numeric option without -n. */ 125 /* Allow legacy syntax of an initial numeric option without -n. */
125 if (argc >=2 && ((argv[1][0] == '+') || ((argv[1][0] == '-') 126 if (argc >=2 && ((argv[1][0] == '+') || ((argv[1][0] == '-')
126 /* && (isdigit)(argv[1][1]) */ 127 /* && (isdigit)(argv[1][1]) */
@@ -130,6 +131,7 @@ int tail_main(int argc, char **argv)
130 optarg = argv[1]; 131 optarg = argv[1];
131 goto GET_COUNT; 132 goto GET_COUNT;
132 } 133 }
134#endif
133 135
134 while ((opt = getopt(argc, argv, tail_opts)) > 0) { 136 while ((opt = getopt(argc, argv, tail_opts)) > 0) {
135 switch (opt) { 137 switch (opt) {
diff --git a/include/usage.h b/include/usage.h
index 53832b987..2cfd2b0c1 100644
--- a/include/usage.h
+++ b/include/usage.h
@@ -766,7 +766,7 @@
766 "/etc/passwd\n" 766 "/etc/passwd\n"
767 767
768#define fold_trivial_usage \ 768#define fold_trivial_usage \
769 "[-bsw] [FILE]" 769 "[-bs] [-w WIDTH] [FILE]"
770#define fold_full_usage \ 770#define fold_full_usage \
771 "Wrap input lines in each FILE (standard input by default), writing to\n" \ 771 "Wrap input lines in each FILE (standard input by default), writing to\n" \
772 "standard output.\n\n" \ 772 "standard output.\n\n" \
diff --git a/sysdeps/linux/Config.in b/sysdeps/linux/Config.in
index 95491c9a0..fb97c8f05 100644
--- a/sysdeps/linux/Config.in
+++ b/sysdeps/linux/Config.in
@@ -203,6 +203,21 @@ config EXTRA_CFLAGS_OPTIONS
203 if you want to add some simple compiler switches (like -march=i686), 203 if you want to add some simple compiler switches (like -march=i686),
204 or check for warnings using -Werror, just those options here. 204 or check for warnings using -Werror, just those options here.
205 205
206config CONFIG_FEATURE_SUSv2
207 bool "Enable features that are in SuSv2 but not SuSv3?"
208 default y
209 help
210 This option will enable backwards compatability with SuSv2,
211 specifically, numeric options such as 'head -1 <file>' will be
212 supported.
213
214config CONFIG_FEATURE_SUSv2_OBSOLETE
215 bool "Enable features that are obsolete in SuSv2"
216 depends on CONFIG_FEATURE_SUSv2
217 default y
218 help
219 Disables support for numeric arguments in fold.
220
206endmenu 221endmenu
207 222
208menu 'Installation Options' 223menu 'Installation Options'