add some more checks to the telnet init script
[openwrt.git] / package / busybox / patches / 400-revert_awk_getopt.patch
1 diff -ur busybox.old/editors/awk.c busybox.dev/editors/awk.c
2 --- busybox.old/editors/awk.c 2006-12-27 05:56:50.000000000 +0100
3 +++ busybox.dev/editors/awk.c 2007-01-01 23:12:04.000000000 +0100
4 @@ -2634,8 +2634,6 @@
5
6 int awk_main(int argc, char **argv)
7 {
8 - unsigned opt;
9 - char *opt_F, *opt_v, *opt_W;
10 char *s, *s1;
11 int i, j, c, flen;
12 var *v;
13 @@ -2691,32 +2689,44 @@
14 free(s);
15 }
16
17 - opt = getopt32(argc, argv, "F:v:f:W:", &opt_F, &opt_v, &programname, &opt_W);
18 - if (opt & 0x1) setvar_s(V[FS], opt_F); // -F
19 - if (opt & 0x2) if (!is_assignment(opt_v)) bb_show_usage(); // -v
20 - if (opt & 0x4) { // -f
21 - from_file = TRUE;
22 - F = afopen(programname, "r");
23 - s = NULL;
24 - /* one byte is reserved for some trick in next_token */
25 - if (fseek(F, 0, SEEK_END) == 0) {
26 - flen = ftell(F);
27 - s = (char *)xmalloc(flen+4);
28 - fseek(F, 0, SEEK_SET);
29 - i = 1 + fread(s+1, 1, flen, F);
30 - } else {
31 - for (i=j=1; j>0; i+=j) {
32 - s = (char *)xrealloc(s, i+4096);
33 - j = fread(s+i, 1, 4094, F);
34 - }
35 + while((c = getopt(argc, argv, "F:v:f:W:")) != EOF) {
36 + switch (c) {
37 + case 'F':
38 + setvar_s(V[FS], optarg);
39 + break;
40 + case 'v':
41 + if (! is_assignment(optarg))
42 + bb_show_usage();
43 + break;
44 + case 'f':
45 + from_file = TRUE;
46 + F = afopen(programname = optarg, "r");
47 + s = NULL;
48 + /* one byte is reserved for some trick in next_token */
49 + if (fseek(F, 0, SEEK_END) == 0) {
50 + flen = ftell(F);
51 + s = (char *)xmalloc(flen+4);
52 + fseek(F, 0, SEEK_SET);
53 + i = 1 + fread(s+1, 1, flen, F);
54 + } else {
55 + for (i=j=1; j>0; i+=j) {
56 + s = (char *)xrealloc(s, i+4096);
57 + j = fread(s+i, 1, 4094, F);
58 + }
59 + }
60 + s[i] = '\0';
61 + fclose(F);
62 + parse_program(s+1);
63 + free(s);
64 + break;
65 + case 'W':
66 + bb_error_msg("Warning: unrecognized option '-W %s' ignored\n", optarg);
67 + break;
68 +
69 + default:
70 + bb_show_usage();
71 }
72 - s[i] = '\0';
73 - fclose(F);
74 - parse_program(s+1);
75 - free(s);
76 }
77 - if (opt & 0x8) // -W
78 - bb_error_msg("warning: unrecognized option '-W %s' ignored", opt_W);
79
80 if (!from_file) {
81 if (argc == optind)
This page took 0.044673 seconds and 5 git commands to generate.