1 diff -ur busybox.old/editors/awk.c busybox.dev/editors/awk.c
2 --- busybox.old/editors/awk.c 2007-01-19 22:23:12.000000000 +0100
3 +++ busybox.dev/editors/awk.c 2007-01-26 20:09:45.000000000 +0100
4 @@ -2639,14 +2639,13 @@
6 int awk_main(int argc, char **argv)
9 - char *opt_F, *opt_v, *opt_W;
14 char *vnames = (char *)vNames; /* cheat */
15 char *vvalues = (char *)vValues;
18 /* Undo busybox.c, or else strtod may eat ','! This breaks parsing:
19 * $1,$2 == '$1,' '$2', NOT '$1' ',' '$2' */
20 @@ -2694,40 +2693,54 @@
24 - opt = getopt32(argc, argv, "F:v:f:W:", &opt_F, &opt_v, &programname, &opt_W);
27 - if (opt & 0x1) setvar_s(V[FS], opt_F); // -F
28 - if (opt & 0x2) if (!is_assignment(opt_v)) bb_show_usage(); // -v
29 - if (opt & 0x4) { // -f
30 - char *s = s; /* die, gcc, die */
31 - FILE *from_file = afopen(programname, "r");
32 - /* one byte is reserved for some trick in next_token */
33 - if (fseek(from_file, 0, SEEK_END) == 0) {
34 - flen = ftell(from_file);
35 - s = xmalloc(flen + 4);
36 - fseek(from_file, 0, SEEK_SET);
37 - i = 1 + fread(s + 1, 1, flen, from_file);
39 - for (i = j = 1; j > 0; i += j) {
40 - s = xrealloc(s, i + 4096);
41 - j = fread(s + i, 1, 4094, from_file);
43 + while((c = getopt(argc, argv, "F:v:f:W:")) != EOF) {
46 + setvar_s(V[FS], optarg);
49 + if (! is_assignment(optarg))
53 + FILE *F = afopen(programname = optarg, "r");
55 + /* one byte is reserved for some trick in next_token */
56 + if (fseek(F, 0, SEEK_END) == 0) {
58 + s = (char *)xmalloc(flen+4);
59 + fseek(F, 0, SEEK_SET);
60 + i = 1 + fread(s+1, 1, flen, F);
62 + for (i=j=1; j>0; i+=j) {
63 + s = (char *)xrealloc(s, i+4096);
64 + j = fread(s+i, 1, 4094, F);
74 + bb_error_msg("Warning: unrecognized option '-W %s' ignored\n", optarg);
82 - parse_program(s + 1);
84 - } else { // no -f: take program from 1st parameter
92 programname = "cmd. line";
93 parse_program(*argv++);
96 - if (opt & 0x8) // -W
97 - bb_error_msg("warning: unrecognized option '-W %s' ignored", opt_W);
100 /* fill in ARGV array */
101 setvar_i(V[ARGC], argc + 1);
102 setari_u(V[ARGV], 0, "awk");