summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2010-06-13 17:58:20 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2010-06-13 17:58:20 +0000
commite1944808d62d45bb05963968faa0fde7ab36feed (patch)
treee1eab458bf1c3c4ed0086fd00a545d5fb37f6a34 /usr.bin
parent8f4c1ffb8acb761c9d473f9b615bf9056ed164a0 (diff)
Update awk to May 23, 2010 version. OK miod@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/awk/FIXES30
-rw-r--r--usr.bin/awk/b.c4
-rw-r--r--usr.bin/awk/lib.c3
-rw-r--r--usr.bin/awk/main.c6
-rw-r--r--usr.bin/awk/maketab.c4
-rw-r--r--usr.bin/awk/proto.h4
-rw-r--r--usr.bin/awk/run.c13
7 files changed, 48 insertions, 16 deletions
diff --git a/usr.bin/awk/FIXES b/usr.bin/awk/FIXES
index b318e2a1a72..fe3273c9647 100644
--- a/usr.bin/awk/FIXES
+++ b/usr.bin/awk/FIXES
@@ -1,4 +1,4 @@
-/* $OpenBSD: FIXES,v 1.14 2008/10/06 20:38:33 millert Exp $ */
+/* $OpenBSD: FIXES,v 1.15 2010/06/13 17:58:19 millert Exp $ */
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
@@ -26,6 +26,34 @@ THIS SOFTWARE.
This file lists all bug fixes, changes, etc., made since the AWK book
was sent to the printers in August, 1987.
+May 23, 2010:
+ fixed long-standing overflow bug in run.c; many thanks to
+ nelson beebe for spotting it and providing the fix.
+
+ fixed bug that didn't parse -vd=1 properly; thanks to santiago
+ vila for spotting it.
+
+Feb 8, 2010:
+ i give up. replaced isblank with isspace in b.c; there are
+ no consistent header files.
+
+Nov 26, 2009:
+ fixed a long-standing issue with when FS takes effect. a
+ change to FS is now noticed immediately for subsequent splits.
+
+ changed the name getline() to awkgetline() to avoid yet another
+ name conflict somewhere.
+
+Feb 11, 2009:
+ temporarily for now defined HAS_ISBLANK, since that seems to
+ be the best way through the thicket. isblank arrived in C99,
+ but seems to be arriving at different systems at different
+ times.
+
+Oct 8, 2008:
+ fixed typo in b.c that set tmpvec wrongly. no one had ever
+ run into the problem, apparently. thanks to alistair crooks.
+
Oct 23, 2007:
minor fix in lib.c: increase inputFS to 100, change malloc
for fields to n+1.
diff --git a/usr.bin/awk/b.c b/usr.bin/awk/b.c
index 03018c10012..cc7ac3559b1 100644
--- a/usr.bin/awk/b.c
+++ b/usr.bin/awk/b.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: b.c,v 1.15 2008/10/06 20:38:33 millert Exp $ */
+/* $OpenBSD: b.c,v 1.16 2010/06/13 17:58:19 millert Exp $ */
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
@@ -877,7 +877,7 @@ int cgoto(fa *f, int s, int c)
if (q[j] >= maxsetvec) {
maxsetvec *= 4;
setvec = (int *) realloc(setvec, maxsetvec * sizeof(int));
- tmpset = (int *) realloc(setvec, maxsetvec * sizeof(int));
+ tmpset = (int *) realloc(tmpset, maxsetvec * sizeof(int));
if (setvec == 0 || tmpset == 0)
overflo("cgoto overflow");
}
diff --git a/usr.bin/awk/lib.c b/usr.bin/awk/lib.c
index afbac925c73..bd3bbddd816 100644
--- a/usr.bin/awk/lib.c
+++ b/usr.bin/awk/lib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lib.c,v 1.18 2008/10/06 20:38:33 millert Exp $ */
+/* $OpenBSD: lib.c,v 1.19 2010/06/13 17:58:19 millert Exp $ */
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
@@ -276,6 +276,7 @@ void fldbld(void) /* create fields from current record */
}
fr = fields;
i = 0; /* number of fields accumulated here */
+ strlcpy(inputFS, *FS, sizeof(inputFS));
if (strlen(inputFS) > 1) { /* it's a regular expression */
i = refldbld(r, inputFS);
} else if ((sep = *inputFS) == ' ') { /* default whitespace */
diff --git a/usr.bin/awk/main.c b/usr.bin/awk/main.c
index d4e52329b43..b000be6f381 100644
--- a/usr.bin/awk/main.c
+++ b/usr.bin/awk/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.15 2008/10/06 20:38:33 millert Exp $ */
+/* $OpenBSD: main.c,v 1.16 2010/06/13 17:58:19 millert Exp $ */
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
@@ -23,7 +23,7 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
****************************************************************/
-const char *version = "version 20071023";
+const char *version = "version 20100523";
#define DEBUG
#include <stdio.h>
@@ -112,6 +112,8 @@ int main(int argc, char *argv[])
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]);
break;
case 'd':
dbg = atoi(&argv[1][2]);
diff --git a/usr.bin/awk/maketab.c b/usr.bin/awk/maketab.c
index 01e9aff4be6..84aef727031 100644
--- a/usr.bin/awk/maketab.c
+++ b/usr.bin/awk/maketab.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: maketab.c,v 1.10 2008/10/06 20:38:33 millert Exp $ */
+/* $OpenBSD: maketab.c,v 1.11 2010/06/13 17:58:19 millert Exp $ */
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
@@ -103,7 +103,7 @@ struct xx
{ CALL, "call", "call" },
{ ARG, "arg", "arg" },
{ VARNF, "getnf", "NF" },
- { GETLINE, "getline", "getline" },
+ { GETLINE, "awkgetline", "getline" },
{ 0, "", "" },
};
diff --git a/usr.bin/awk/proto.h b/usr.bin/awk/proto.h
index 934200d300a..07c558b7633 100644
--- a/usr.bin/awk/proto.h
+++ b/usr.bin/awk/proto.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: proto.h,v 1.7 2002/12/19 21:24:28 millert Exp $ */
+/* $OpenBSD: proto.h,v 1.8 2010/06/13 17:58:19 millert Exp $ */
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
@@ -150,7 +150,7 @@ extern Cell *call(Node **, int);
extern Cell *copycell(Cell *);
extern Cell *arg(Node **, int);
extern Cell *jump(Node **, int);
-extern Cell *getline(Node **, int);
+extern Cell *awkgetline(Node **, int);
extern Cell *getnf(Node **, int);
extern Cell *array(Node **, int);
extern Cell *awkdelete(Node **, int);
diff --git a/usr.bin/awk/run.c b/usr.bin/awk/run.c
index 8f19cf7d680..f92dd503276 100644
--- a/usr.bin/awk/run.c
+++ b/usr.bin/awk/run.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: run.c,v 1.30 2008/10/06 20:38:33 millert Exp $ */
+/* $OpenBSD: run.c,v 1.31 2010/06/13 17:58:19 millert Exp $ */
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
@@ -391,7 +391,7 @@ Cell *jump(Node **a, int n) /* break, continue, next, nextfile, return */
return 0; /* not reached */
}
-Cell *getline(Node **a, int n) /* get next line from specific input */
+Cell *awkgetline(Node **a, int n) /* get next line from specific input */
{ /* a[0] is variable, a[1] is operator, a[2] is filename */
Cell *r, *x;
extern Cell **fldtab;
@@ -1167,11 +1167,11 @@ Cell *cat(Node **a, int q) /* a[0] cat a[1] */
x->sval, y->sval);
strlcpy(s, x->sval, len);
strlcpy(s+n1, y->sval, len - n1);
+ tempfree(x);
tempfree(y);
z = gettemp();
z->sval = s;
z->tval = STR;
- tempfree(x);
return(z);
}
@@ -1956,9 +1956,10 @@ Cell *gsub(Node **a, int nnn) /* global substitute */
adjbuf(&buf, &bufsz, 1+strlen(sptr)+pb-buf, 0, &pb, "gsub");
while ((*pb++ = *sptr++) != 0)
;
- done: if (pb > buf + bufsz)
- FATAL("gsub result2 %.30s too big; can't happen", buf);
- *pb = '\0';
+ done: if (pb < buf + bufsz)
+ *pb = '\0';
+ else if (*(pb-1) != '\0')
+ FATAL("gsub result2 %.30s truncated; can't happen", buf);
setsval(x, buf); /* BUG: should be able to avoid copy + free */
pfa->initstat = tempstat;
}