Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/historical/nawk/dist PR/43981: Aleksey Cheusov: awk...
details: https://anonhg.NetBSD.org/src/rev/2810b9d133b9
branches: trunk
changeset: 758090:2810b9d133b9
user: christos <christos%NetBSD.org@localhost>
date: Sun Oct 17 22:12:22 2010 +0000
description:
PR/43981: Aleksey Cheusov: awk too small limit on number -f options
remove the limit
should we pullup to 5.x?
diffstat:
external/historical/nawk/dist/main.c | 17 ++++++++++++-----
1 files changed, 12 insertions(+), 5 deletions(-)
diffs (34 lines):
diff -r 8993bf71429c -r 2810b9d133b9 external/historical/nawk/dist/main.c
--- a/external/historical/nawk/dist/main.c Sun Oct 17 17:10:44 2010 +0000
+++ b/external/historical/nawk/dist/main.c Sun Oct 17 22:12:22 2010 +0000
@@ -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 */
Home |
Main Index |
Thread Index |
Old Index