Module Name: src
Committed By: christos
Date: Sun Oct 17 22:12:23 UTC 2010
Modified Files:
src/external/historical/nawk/dist: main.c
Log Message:
PR/43981: Aleksey Cheusov: awk too small limit on number -f options
remove the limit
should we pullup to 5.x?
To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/external/historical/nawk/dist/main.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/external/historical/nawk/dist/main.c
diff -u src/external/historical/nawk/dist/main.c:1.2 src/external/historical/nawk/dist/main.c:1.3
--- src/external/historical/nawk/dist/main.c:1.2 Thu Aug 26 10:55:20 2010
+++ src/external/historical/nawk/dist/main.c Sun Oct 17 18:12:22 2010
@@ -51,9 +51,10 @@
#define MAX_PFILE 20 /* max number of -f's */
-char *pfile[MAX_PFILE]; /* program filenames from -f's */
-int npfile = 0; /* number of filenames */
-int curpfile = 0; /* current filename */
+static char **pfile = NULL; /* program filenames from -f's */
+static size_t maxpfile = 0; /* max program filenames */
+static size_t npfile = 0; /* number of filenames */
+static size_t curpfile = 0; /* current filename */
int safe = 0; /* 1 => "safe" mode */
@@ -146,8 +147,14 @@
argv++;
if (argc <= 1)
FATAL("no program filename");
- if (npfile >= MAX_PFILE - 1)
- FATAL("too many -f options");
+ if (npfile >= maxpfile) {
+ maxpfile += 20;
+ pfile = realloc(pfile,
+ maxpfile * sizeof(*pfile));
+ if (pfile == NULL)
+ FATAL("error allocating space for "
+ "-f options");
+ }
pfile[npfile++] = argv[1];
break;
case 'F': /* set field separator */