summaryrefslogtreecommitdiff
path: root/package/busybox/patches/360-awk_multi_f.patch
diff options
context:
space:
mode:
Diffstat (limited to 'package/busybox/patches/360-awk_multi_f.patch')
-rw-r--r--package/busybox/patches/360-awk_multi_f.patch72
1 files changed, 72 insertions, 0 deletions
diff --git a/package/busybox/patches/360-awk_multi_f.patch b/package/busybox/patches/360-awk_multi_f.patch
new file mode 100644
index 0000000..8f738a6
--- /dev/null
+++ b/package/busybox/patches/360-awk_multi_f.patch
@@ -0,0 +1,72 @@
+Index: busybox-1.7.2/editors/awk.c
+===================================================================
+--- busybox-1.7.2.orig/editors/awk.c 2007-10-04 19:57:46.859742242 +0200
++++ busybox-1.7.2/editors/awk.c 2007-10-05 02:20:02.910793305 +0200
+@@ -2757,6 +2757,7 @@
+ {
+ unsigned opt;
+ char *opt_F, *opt_W;
++ llist_t *opt_f = NULL;
+ llist_t *opt_v = NULL;
+ int i, j, flen;
+ var *v;
+@@ -2816,8 +2817,8 @@
+ *s1 = '=';
+ }
+ }
+- opt_complementary = "v::";
+- opt = getopt32(argv, "F:v:f:W:", &opt_F, &opt_v, &g_progname, &opt_W);
++ opt_complementary = "v::f::";
++ opt = getopt32(argv, "F:v:f:W:", &opt_F, &opt_v, &opt_f, &opt_W);
+ argv += optind;
+ argc -= optind;
+ if (opt & 0x1)
+@@ -2826,25 +2827,31 @@
+ if (!is_assignment(llist_pop(&opt_v)))
+ bb_show_usage();
+ }
+- if (opt & 0x4) { // -f
+- char *s = s; /* die, gcc, die */
+- FILE *from_file = afopen(g_progname, "r");
+- /* one byte is reserved for some trick in next_token */
+- if (fseek(from_file, 0, SEEK_END) == 0) {
+- flen = ftell(from_file);
+- s = xmalloc(flen + 4);
+- fseek(from_file, 0, SEEK_SET);
+- i = 1 + fread(s + 1, 1, flen, from_file);
+- } else {
+- for (i = j = 1; j > 0; i += j) {
+- s = xrealloc(s, i + 4096);
+- j = fread(s + i, 1, 4094, from_file);
++ if (opt_f != NULL) { // -f
++ while (opt_f != NULL) {
++ char *s = NULL;
++ FILE *from_file;
++
++ g_progname = opt_f->data;
++ from_file = afopen(g_progname, "r");
++ /* one byte is reserved for some trick in next_token */
++ if (fseek(from_file, 0, SEEK_END) == 0) {
++ flen = ftell(from_file);
++ s = xmalloc(flen + 4);
++ fseek(from_file, 0, SEEK_SET);
++ i = 1 + fread(s + 1, 1, flen, from_file);
++ } else {
++ for (i = j = 1; j > 0; i += j) {
++ s = xrealloc(s, i + 4096);
++ j = fread(s + i, 1, 4094, from_file);
++ }
+ }
++ s[i] = '\0';
++ fclose(from_file);
++ parse_program(s + 1);
++ free(s);
++ opt_f = opt_f->link;
+ }
+- s[i] = '\0';
+- fclose(from_file);
+- parse_program(s + 1);
+- free(s);
+ } else { // no -f: take program from 1st parameter
+ if (!argc)
+ bb_show_usage();