aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
Diffstat (limited to 'editors')
-rw-r--r--editors/awk.c8
-rw-r--r--editors/cmp.c10
-rw-r--r--editors/diff.c12
-rw-r--r--editors/ed.c6
-rw-r--r--editors/patch_bbox.c3
-rw-r--r--editors/sed.c18
6 files changed, 32 insertions, 25 deletions
diff --git a/editors/awk.c b/editors/awk.c
index 56688d72c..2fc7d6102 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -70,7 +70,11 @@
70#endif 70#endif
71 71
72 72
73#define OPTSTR_AWK \ 73/* "+": stop on first non-option:
74 * $ awk 'BEGIN { for(i=1; i<ARGC; ++i) { print i ": " ARGV[i] }}' -argz
75 * 1: -argz
76 */
77#define OPTSTR_AWK "+" \
74 "F:v:*f:*" \ 78 "F:v:*f:*" \
75 IF_FEATURE_AWK_GNU_EXTENSIONS("e:*") \ 79 IF_FEATURE_AWK_GNU_EXTENSIONS("e:*") \
76 "W:" 80 "W:"
@@ -230,7 +234,7 @@ typedef struct tsplitter_s {
230 */ 234 */
231#define TC_LENGTH (1 << 20) 235#define TC_LENGTH (1 << 20)
232#define TC_GETLINE (1 << 21) 236#define TC_GETLINE (1 << 21)
233#define TC_FUNCDECL (1 << 22) /* `function' `func' */ 237#define TC_FUNCDECL (1 << 22) /* 'function' 'func' */
234#define TC_BEGIN (1 << 23) 238#define TC_BEGIN (1 << 23)
235#define TC_END (1 << 24) 239#define TC_END (1 << 24)
236#define TC_EOF (1 << 25) 240#define TC_EOF (1 << 25)
diff --git a/editors/cmp.c b/editors/cmp.c
index f53d9603c..ec86c0ce2 100644
--- a/editors/cmp.c
+++ b/editors/cmp.c
@@ -36,7 +36,7 @@ static const char fmt_differ[] ALIGN1 = "%s %s differ: char %"OFF_FMT"u, line %u
36// This fmt_l_opt uses gnu-isms. SUSv3 would be "%.0s%.0s%"OFF_FMT"u %o %o\n" 36// This fmt_l_opt uses gnu-isms. SUSv3 would be "%.0s%.0s%"OFF_FMT"u %o %o\n"
37static const char fmt_l_opt[] ALIGN1 = "%.0s%.0s%"OFF_FMT"u %3o %3o\n"; 37static const char fmt_l_opt[] ALIGN1 = "%.0s%.0s%"OFF_FMT"u %3o %3o\n";
38 38
39static const char opt_chars[] ALIGN1 = "sl"; 39#define OPT_STR "sl"
40#define CMP_OPT_s (1<<0) 40#define CMP_OPT_s (1<<0)
41#define CMP_OPT_l (1<<1) 41#define CMP_OPT_l (1<<1)
42 42
@@ -52,11 +52,13 @@ int cmp_main(int argc UNUSED_PARAM, char **argv)
52 unsigned opt; 52 unsigned opt;
53 int retval = 0; 53 int retval = 0;
54 54
55 opt_complementary = "-1" 55 opt = getopt32(argv, "^"
56 OPT_STR
57 "\0" "-1"
56 IF_DESKTOP(":?4") 58 IF_DESKTOP(":?4")
57 IF_NOT_DESKTOP(":?2") 59 IF_NOT_DESKTOP(":?2")
58 ":l--s:s--l"; 60 ":l--s:s--l"
59 opt = getopt32(argv, opt_chars); 61 );
60 argv += optind; 62 argv += optind;
61 63
62 filename1 = *argv; 64 filename1 = *argv;
diff --git a/editors/diff.c b/editors/diff.c
index 62f558944..1ff399ffb 100644
--- a/editors/diff.c
+++ b/editors/diff.c
@@ -988,6 +988,11 @@ static const char diff_longopts[] ALIGN1 =
988 "starting-file\0" Required_argument "S" 988 "starting-file\0" Required_argument "S"
989 "minimal\0" No_argument "d" 989 "minimal\0" No_argument "d"
990 ; 990 ;
991# define GETOPT32 getopt32long
992# define LONGOPTS ,diff_longopts
993#else
994# define GETOPT32 getopt32
995# define LONGOPTS
991#endif 996#endif
992 997
993int diff_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 998int diff_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
@@ -1000,11 +1005,8 @@ int diff_main(int argc UNUSED_PARAM, char **argv)
1000 INIT_G(); 1005 INIT_G();
1001 1006
1002 /* exactly 2 params; collect multiple -L <label>; -U N */ 1007 /* exactly 2 params; collect multiple -L <label>; -U N */
1003 opt_complementary = "=2"; 1008 GETOPT32(argv, "^" "abdiL:*NqrsS:tTU:+wupBE" "\0" "=2"
1004#if ENABLE_FEATURE_DIFF_LONG_OPTIONS 1009 LONGOPTS,
1005 applet_long_options = diff_longopts;
1006#endif
1007 getopt32(argv, "abdiL:*NqrsS:tTU:+wupBE",
1008 &L_arg, &s_start, &opt_U_context); 1010 &L_arg, &s_start, &opt_U_context);
1009 argv += optind; 1011 argv += optind;
1010 while (L_arg) 1012 while (L_arg)
diff --git a/editors/ed.c b/editors/ed.c
index 7f21ded92..05797692c 100644
--- a/editors/ed.c
+++ b/editors/ed.c
@@ -360,7 +360,7 @@ static void addLines(int num)
360 * 0 on ctrl-C, 360 * 0 on ctrl-C,
361 * >0 length of input string, including terminating '\n' 361 * >0 length of input string, including terminating '\n'
362 */ 362 */
363 len = read_line_input(NULL, "", buf, sizeof(buf), /*timeout*/ -1); 363 len = read_line_input(NULL, "", buf, sizeof(buf));
364 if (len <= 0) { 364 if (len <= 0) {
365 /* Previously, ctrl-C was exiting to shell. 365 /* Previously, ctrl-C was exiting to shell.
366 * Now we exit to ed prompt. Is in important? */ 366 * Now we exit to ed prompt. Is in important? */
@@ -789,7 +789,7 @@ static void doCommands(void)
789 * 0 on ctrl-C, 789 * 0 on ctrl-C,
790 * >0 length of input string, including terminating '\n' 790 * >0 length of input string, including terminating '\n'
791 */ 791 */
792 len = read_line_input(NULL, ": ", buf, sizeof(buf), /*timeout*/ -1); 792 len = read_line_input(NULL, ": ", buf, sizeof(buf));
793 if (len <= 0) 793 if (len <= 0)
794 return; 794 return;
795 while (len && isspace(buf[--len])) 795 while (len && isspace(buf[--len]))
@@ -892,7 +892,7 @@ static void doCommands(void)
892 } 892 }
893 if (!dirty) 893 if (!dirty)
894 return; 894 return;
895 len = read_line_input(NULL, "Really quit? ", buf, 16, /*timeout*/ -1); 895 len = read_line_input(NULL, "Really quit? ", buf, 16);
896 /* read error/EOF - no way to continue */ 896 /* read error/EOF - no way to continue */
897 if (len < 0) 897 if (len < 0)
898 return; 898 return;
diff --git a/editors/patch_bbox.c b/editors/patch_bbox.c
index aae7b7987..8e09ef488 100644
--- a/editors/patch_bbox.c
+++ b/editors/patch_bbox.c
@@ -111,10 +111,9 @@ int patch_main(int argc UNUSED_PARAM, char **argv)
111 "no-backup-if-mismatch\0" No_argument "\xff" /*ignored*/ 111 "no-backup-if-mismatch\0" No_argument "\xff" /*ignored*/
112# endif 112# endif
113 ; 113 ;
114 applet_long_options = patch_longopts;
115#endif 114#endif
116 /* -f,-E,-g are ignored */ 115 /* -f,-E,-g are ignored */
117 opt = getopt32(argv, "p:i:RN""fEg:", &p, &i, NULL); 116 opt = getopt32long(argv, "p:i:RN""fEg:", patch_longopts, &p, &i, NULL);
118 if (opt & OPT_R) 117 if (opt & OPT_R)
119 plus = '-'; 118 plus = '-';
120 patch_level = xatoi(p); /* can be negative! */ 119 patch_level = xatoi(p); /* can be negative! */
diff --git a/editors/sed.c b/editors/sed.c
index e10078b7c..d6e25aedc 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -68,8 +68,8 @@
68//applet:IF_SED(APPLET(sed, BB_DIR_BIN, BB_SUID_DROP)) 68//applet:IF_SED(APPLET(sed, BB_DIR_BIN, BB_SUID_DROP))
69 69
70//usage:#define sed_trivial_usage 70//usage:#define sed_trivial_usage
71//usage: "[-inrE] [-f FILE]... [-e CMD]... [FILE]...\n" 71//usage: "[-i[SFX]] [-nrE] [-f FILE]... [-e CMD]... [FILE]...\n"
72//usage: "or: sed [-inrE] CMD [FILE]..." 72//usage: "or: sed [-i[SFX]] [-nrE] CMD [FILE]..."
73//usage:#define sed_full_usage "\n\n" 73//usage:#define sed_full_usage "\n\n"
74//usage: " -e CMD Add CMD to sed commands to be executed" 74//usage: " -e CMD Add CMD to sed commands to be executed"
75//usage: "\n -f FILE Add FILE contents to sed commands to be executed" 75//usage: "\n -f FILE Add FILE contents to sed commands to be executed"
@@ -1512,21 +1512,21 @@ int sed_main(int argc UNUSED_PARAM, char **argv)
1512 /* do normal option parsing */ 1512 /* do normal option parsing */
1513 opt_e = opt_f = NULL; 1513 opt_e = opt_f = NULL;
1514 opt_i = NULL; 1514 opt_i = NULL;
1515 opt_complementary = "nn"; /* count -n */
1516
1517 IF_LONG_OPTS(applet_long_options = sed_longopts);
1518
1519 /* -i must be first, to match OPT_in_place definition */ 1515 /* -i must be first, to match OPT_in_place definition */
1520 /* -E is a synonym of -r: 1516 /* -E is a synonym of -r:
1521 * GNU sed 4.2.1 mentions it in neither --help 1517 * GNU sed 4.2.1 mentions it in neither --help
1522 * nor manpage, but does recognize it. 1518 * nor manpage, but does recognize it.
1523 */ 1519 */
1524 opt = getopt32(argv, "i::rEne:*f:*", &opt_i, &opt_e, &opt_f, 1520 opt = getopt32long(argv, "^"
1525 &G.be_quiet); /* counter for -n */ 1521 "i::rEne:*f:*"
1522 "\0" "nn"/*count -n*/,
1523 sed_longopts,
1524 &opt_i, &opt_e, &opt_f,
1525 &G.be_quiet); /* counter for -n */
1526 //argc -= optind; 1526 //argc -= optind;
1527 argv += optind; 1527 argv += optind;
1528 if (opt & OPT_in_place) { // -i 1528 if (opt & OPT_in_place) { // -i
1529 atexit(cleanup_outname); 1529 die_func = cleanup_outname;
1530 } 1530 }
1531 if (opt & (2|4)) 1531 if (opt & (2|4))
1532 G.regex_type |= REG_EXTENDED; // -r or -E 1532 G.regex_type |= REG_EXTENDED; // -r or -E