1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-11-05 11:20:39 +02:00
openwrt-xburst/package/busybox/patches/360-awk_multi_f.patch
pavlov b0c94d7f56 refresh busybox patches
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@9463 3c298f89-4303-0410-b956-a3cf2f4a3e73
2007-10-30 20:36:25 +00:00

73 lines
2.0 KiB
Diff

Index: busybox-1.7.2/editors/awk.c
===================================================================
--- busybox-1.7.2.orig/editors/awk.c 2007-10-30 15:34:59.000000000 -0500
+++ busybox-1.7.2/editors/awk.c 2007-10-30 15:35:03.000000000 -0500
@@ -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();