1 Index: busybox-1.4.2/editors/awk.c
2 ===================================================================
3 --- busybox-1.4.2.orig/editors/awk.c 2007-06-15 23:43:26.460690280 +0200
4 +++ busybox-1.4.2/editors/awk.c 2007-06-15 23:45:26.283474448 +0200
5 @@ -2639,14 +2639,13 @@
7 int awk_main(int argc, char **argv)
10 - char *opt_F, *opt_v, *opt_W;
15 char *vnames = (char *)vNames; /* cheat */
16 char *vvalues = (char *)vValues;
19 /* Undo busybox.c, or else strtod may eat ','! This breaks parsing:
20 * $1,$2 == '$1,' '$2', NOT '$1' ',' '$2' */
21 @@ -2694,40 +2693,56 @@
25 - opt = getopt32(argc, argv, "F:v:f:W:", &opt_F, &opt_v, &programname, &opt_W);
28 - if (opt & 0x1) setvar_s(V[FS], opt_F); // -F
29 - if (opt & 0x2) if (!is_assignment(opt_v)) bb_show_usage(); // -v
30 - if (opt & 0x4) { // -f
31 - char *s = s; /* die, gcc, die */
32 - FILE *from_file = afopen(programname, "r");
33 - /* one byte is reserved for some trick in next_token */
34 - if (fseek(from_file, 0, SEEK_END) == 0) {
35 - flen = ftell(from_file);
36 - s = xmalloc(flen + 4);
37 - fseek(from_file, 0, SEEK_SET);
38 - i = 1 + fread(s + 1, 1, flen, from_file);
40 - for (i = j = 1; j > 0; i += j) {
41 - s = xrealloc(s, i + 4096);
42 - j = fread(s + i, 1, 4094, from_file);
44 + while((c = getopt(argc, argv, "F:v:f:W:")) != EOF) {
47 + setvar_s(V[FS], optarg);
50 + if (! is_assignment(optarg))
54 + FILE *F = afopen(programname = optarg, "r");
56 + /* one byte is reserved for some trick in next_token */
57 + if (fseek(F, 0, SEEK_END) == 0) {
59 + s = (char *)xmalloc(flen+4);
60 + fseek(F, 0, SEEK_SET);
61 + i = 1 + fread(s+1, 1, flen, F);
63 + for (i=j=1; j>0; i+=j) {
64 + s = (char *)xrealloc(s, i+4096);
65 + j = fread(s+i, 1, 4094, F);
75 + bb_error_msg("Warning: unrecognized option '-W %s' ignored\n", optarg);
83 - parse_program(s + 1);
85 - } else { // no -f: take program from 1st parameter
93 programname = "cmd. line";
94 parse_program(*argv++);
97 - if (opt & 0x8) // -W
98 - bb_error_msg("warning: unrecognized option '-W %s' ignored", opt_W);
101 /* fill in ARGV array */
102 setvar_i(V[ARGC], argc + 1);
103 setari_u(V[ARGV], 0, "awk");