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 merge 2012-12-20
details: https://anonhg.NetBSD.org/src/rev/3a16f1e40d01
branches: trunk
changeset: 783555:3a16f1e40d01
user: christos <christos%NetBSD.org@localhost>
date: Sat Dec 29 02:44:26 2012 +0000
description:
merge 2012-12-20
diffstat:
external/historical/nawk/dist/awkgram.y | 4 +-
external/historical/nawk/dist/b.c | 6 +-
external/historical/nawk/dist/lib.c | 19 ++-
external/historical/nawk/dist/main.c | 38 ++++-
external/historical/nawk/dist/makefile | 18 +-
external/historical/nawk/dist/proctab.c | 188 ++++++++++++++++----------------
external/historical/nawk/dist/proto.h | 8 +-
external/historical/nawk/dist/run.c | 15 ++-
external/historical/nawk/dist/tran.c | 8 +-
9 files changed, 174 insertions(+), 130 deletions(-)
diffs (truncated from 555 to 300 lines):
diff -r 45f2bf5fbdb5 -r 3a16f1e40d01 external/historical/nawk/dist/awkgram.y
--- a/external/historical/nawk/dist/awkgram.y Sat Dec 29 02:14:50 2012 +0000
+++ b/external/historical/nawk/dist/awkgram.y Sat Dec 29 02:44:26 2012 +0000
@@ -179,8 +179,8 @@
pa_stat:
pa_pat { $$ = stat2(PASTAT, $1, stat2(PRINT, rectonode(), NIL)); }
| pa_pat lbrace stmtlist '}' { $$ = stat2(PASTAT, $1, $3); }
- | pa_pat ',' pa_pat { $$ = pa2stat($1, $3, stat2(PRINT, rectonode(), NIL)); }
- | pa_pat ',' pa_pat lbrace stmtlist '}' { $$ = pa2stat($1, $3, $5); }
+ | pa_pat ',' opt_nl pa_pat { $$ = pa2stat($1, $4, stat2(PRINT, rectonode(), NIL)); }
+ | pa_pat ',' opt_nl pa_pat lbrace stmtlist '}' { $$ = pa2stat($1, $4, $6); }
| lbrace stmtlist '}' { $$ = stat2(PASTAT, NIL, $2); }
| XBEGIN lbrace stmtlist '}'
{ beginloc = linkum(beginloc, $3); $$ = 0; }
diff -r 45f2bf5fbdb5 -r 3a16f1e40d01 external/historical/nawk/dist/b.c
--- a/external/historical/nawk/dist/b.c Sat Dec 29 02:14:50 2012 +0000
+++ b/external/historical/nawk/dist/b.c Sat Dec 29 02:44:26 2012 +0000
@@ -843,7 +843,7 @@
* to nelson beebe for the suggestion; let's see if it works everywhere.
*/
-/* #define HAS_ISBLANK */
+#define HAS_ISBLANK
static const struct charclass {
const char *cc_name;
@@ -852,7 +852,11 @@
} charclasses[] = {
{ "alnum", 5, isalnum },
{ "alpha", 5, isalpha },
+#ifndef HAS_ISBLANK
+ { "blank", 5, isspace }, /* was isblank */
+#else
{ "blank", 5, isblank },
+#endif
{ "cntrl", 5, iscntrl },
{ "digit", 5, isdigit },
{ "graph", 5, isgraph },
diff -r 45f2bf5fbdb5 -r 3a16f1e40d01 external/historical/nawk/dist/lib.c
--- a/external/historical/nawk/dist/lib.c Sat Dec 29 02:14:50 2012 +0000
+++ b/external/historical/nawk/dist/lib.c Sat Dec 29 02:44:26 2012 +0000
@@ -97,8 +97,13 @@
char *p;
for (i = 1; i < *ARGC; i++) {
- if (!isclvar(p = getargv(i))) { /* find 1st real filename */
- setsval(lookup("FILENAME", symtab), getargv(i));
+ p = getargv(i); /* find 1st real filename */
+ if (p == NULL || *p == '\0') { /* deleted or zapped */
+ argno++;
+ continue;
+ }
+ if (!isclvar(p)) {
+ setsval(lookup("FILENAME", symtab), p);
return;
}
setclvar(p); /* a commandline assignment before filename */
@@ -133,7 +138,7 @@
dprintf( ("argno=%d, file=|%s|\n", argno, file) );
if (infile == NULL) { /* have to open a new file */
file = getargv(argno);
- if (*file == '\0') { /* it's been zapped */
+ if (file == NULL || *file == '\0') { /* deleted or zapped */
argno++;
continue;
}
@@ -207,6 +212,7 @@
FATAL("field separator %.10s... is too long", *FS);
memcpy(inputFS, *FS, len_inputFS);
}
+ /*fflush(stdout); avoids some buffering problem but makes it 25% slower*/
if (**RS && (*RS)[1]) {
fa *pfa = makedfa(*RS, 1);
if (newflag)
@@ -265,6 +271,8 @@
extern Array *ARGVtab;
snprintf(temp, sizeof(temp), "%d", n);
+ if (lookup(temp, ARGVtab) == NULL)
+ return NULL;
x = setsymtab(temp, "", 0.0, STR, ARGVtab);
s = getsval(x);
dprintf( ("getargv(%d) returns |%s|\n", n, s) );
@@ -294,6 +302,7 @@
{
/* this relies on having fields[] the same length as $0 */
/* the fields are all stored in this one array with \0's */
+ /* possibly with a final trailing \0 not associated with any field */
char *r, *fr, sep;
Cell *p;
int i, j, n;
@@ -306,7 +315,7 @@
n = strlen(r);
if (n > fieldssize) {
xfree(fields);
- if ((fields = malloc(n+1)) == NULL)
+ if ((fields = malloc(n+2)) == NULL) /* possibly 2 final \0s */
FATAL("out of space for fields in fldbld %d", n);
fieldssize = n;
}
@@ -537,7 +546,7 @@
fldtab[0]->tval = REC | STR | DONTFREE;
fldtab[0]->sval = record;
- dprintf( ("in recbld inputFS=%s, fldtab[0]=%p\n", inputFS, fldtab[0]) );
+ dprintf( ("in recbld inputFS=%s, fldtab[0]=%p\n", inputFS, (void*)fldtab[0]) );
dprintf( ("recbld = |%s|\n", record) );
donerec = 1;
}
diff -r 45f2bf5fbdb5 -r 3a16f1e40d01 external/historical/nawk/dist/main.c
--- a/external/historical/nawk/dist/main.c Sat Dec 29 02:14:50 2012 +0000
+++ b/external/historical/nawk/dist/main.c Sat Dec 29 02:44:26 2012 +0000
@@ -22,7 +22,7 @@
THIS SOFTWARE.
****************************************************************/
-const char *version = "version 20100523";
+const char *version = "version 20121220";
#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
@@ -42,7 +42,7 @@
extern int nfields;
int dbg = 0;
-unsigned int srand_seed;
+unsigned int srand_seed = 1;
char *cmdname; /* gets argv[0] for error messages */
extern FILE *yyin; /* lex input file */
char *lexprog; /* points to program argument if it exists */
@@ -101,6 +101,7 @@
int main(int argc, char *argv[])
{
const char *fs = NULL;
+ char *fn;
setlocale(LC_ALL, "");
setlocale(LC_NUMERIC, "C"); /* for parsing cmdline & prog */
@@ -146,10 +147,15 @@
safe = 1;
break;
case 'f': /* next argument is program filename */
- argc--;
- argv++;
- if (argc <= 1)
- FATAL("no program filename");
+ if (argv[1][2] != 0) /* arg is -fsomething */
+ fn = &argv[1][2];
+ else {
+ argc--;
+ argv++;
+ if (argc <= 1)
+ FATAL("no program filename");
+ fn = argv[1];
+ }
if (npfile >= maxpfile) {
maxpfile += 20;
pfile = realloc(pfile,
@@ -158,7 +164,7 @@
FATAL("error allocating space for "
"-f options");
}
- pfile[npfile++] = argv[1];
+ pfile[npfile++] = fn;
break;
case 'F': /* set field separator */
if (argv[1][2] != 0) { /* arg is -Fsomething */
@@ -172,10 +178,20 @@
WARNING("field separator FS is empty");
break;
case 'v': /* -v a=1 to be done NOW. one -v for each */
- if (argv[1][2] == '\0' && --argc > 1 && isclvar((++argv)[1]))
- setclvar(argv[1]);
- else if (argv[1][2] != '\0')
- setclvar(&argv[1][2]);
+ if (argv[1][2] != 0) { /* arg is -vsomething */
+ if (isclvar(&argv[1][2]))
+ setclvar(&argv[1][2]);
+ else
+ FATAL("invalid -v option argument: %s", &argv[1][2]);
+ } else { /* arg is -v something */
+ argc--; argv++;
+ if (argc <= 1)
+ FATAL("no variable name");
+ if (isclvar(argv[1]))
+ setclvar(argv[1]);
+ else
+ FATAL("invalid -v option argument: %s", argv[1]);
+ }
break;
case 'd':
dbg = atoi(&argv[1][2]);
diff -r 45f2bf5fbdb5 -r 3a16f1e40d01 external/historical/nawk/dist/makefile
--- a/external/historical/nawk/dist/makefile Sat Dec 29 02:14:50 2012 +0000
+++ b/external/historical/nawk/dist/makefile Sat Dec 29 02:44:26 2012 +0000
@@ -32,22 +32,24 @@
CC = cc
CC = gcc -Wall -g -Wwrite-strings
CC = gcc -fprofile-arcs -ftest-coverage # then gcov f1.c; cat f1.c.gcov
-CC = gcc -O4
+CC = gcc -g -Wall -pedantic
+CC = gcc -O4 -Wall -pedantic -fno-strict-aliasing
-YACC = bison -y
-YACC = yacc
-YFLAGS = -d
+YACC = bison -d -y
+YACC = yacc -d -S
+#YFLAGS = -d -S
+ # -S uses sprintf in yacc parser instead of sprint
OFILES = b.o main.o parse.o proctab.o tran.o lib.o run.o lex.o
SOURCE = awk.h ytab.c ytab.h proto.h awkgram.y lex.c b.c main.c \
- maketab.c parse.c lib.c run.c tran.c proctab.c missing95.c
+ maketab.c parse.c lib.c run.c tran.c proctab.c
LISTING = awk.h proto.h awkgram.y lex.c b.c main.c maketab.c parse.c \
- lib.c run.c tran.c missing95.c
+ lib.c run.c tran.c
-SHIP = README FIXES $(SOURCE) ytab[ch].bak makefile makefile.win \
- vcvars32.bat buildwin.bat awk.1
+SHIP = README FIXES $(SOURCE) ytab[ch].bak makefile \
+ awk.1
a.out: ytab.o $(OFILES)
$(CC) $(CFLAGS) ytab.o $(OFILES) $(ALLOC) -lm
diff -r 45f2bf5fbdb5 -r 3a16f1e40d01 external/historical/nawk/dist/proctab.c
--- a/external/historical/nawk/dist/proctab.c Sat Dec 29 02:14:50 2012 +0000
+++ b/external/historical/nawk/dist/proctab.c Sat Dec 29 02:44:26 2012 +0000
@@ -7,100 +7,100 @@
#include "awkgram.h"
static const char * const printname[94] = {
- "FIRSTTOKEN", /* 257 */
- "PROGRAM", /* 258 */
- "PASTAT", /* 259 */
- "PASTAT2", /* 260 */
- "XBEGIN", /* 261 */
- "XEND", /* 262 */
- "NL", /* 263 */
- "ARRAY", /* 264 */
- "MATCH", /* 265 */
- "NOTMATCH", /* 266 */
- "MATCHOP", /* 267 */
- "FINAL", /* 268 */
- "DOT", /* 269 */
- "ALL", /* 270 */
- "CCL", /* 271 */
- "NCCL", /* 272 */
- "CHAR", /* 273 */
- "OR", /* 274 */
- "STAR", /* 275 */
- "QUEST", /* 276 */
- "PLUS", /* 277 */
- "EMPTYRE", /* 278 */
- "AND", /* 279 */
- "BOR", /* 280 */
- "APPEND", /* 281 */
- "EQ", /* 282 */
- "GE", /* 283 */
- "GT", /* 284 */
- "LE", /* 285 */
- "LT", /* 286 */
- "NE", /* 287 */
- "IN", /* 288 */
- "ARG", /* 289 */
- "BLTIN", /* 290 */
- "BREAK", /* 291 */
- "CLOSE", /* 292 */
- "CONTINUE", /* 293 */
- "DELETE", /* 294 */
- "DO", /* 295 */
- "EXIT", /* 296 */
- "FOR", /* 297 */
- "FUNC", /* 298 */
- "SUB", /* 299 */
- "GSUB", /* 300 */
- "IF", /* 301 */
- "INDEX", /* 302 */
- "LSUBSTR", /* 303 */
- "MATCHFCN", /* 304 */
- "NEXT", /* 305 */
- "NEXTFILE", /* 306 */
- "ADD", /* 307 */
- "MINUS", /* 308 */
- "MULT", /* 309 */
- "DIVIDE", /* 310 */
- "MOD", /* 311 */
- "ASSIGN", /* 312 */
- "ASGNOP", /* 313 */
- "ADDEQ", /* 314 */
- "SUBEQ", /* 315 */
- "MULTEQ", /* 316 */
- "DIVEQ", /* 317 */
- "MODEQ", /* 318 */
- "POWEQ", /* 319 */
- "PRINT", /* 320 */
- "PRINTF", /* 321 */
Home |
Main Index |
Thread Index |
Old Index