diff options
author | stefan <stefan@FreeBSD.org> | 2008-10-20 22:52:28 +0800 |
---|---|---|
committer | stefan <stefan@FreeBSD.org> | 2008-10-20 22:52:28 +0800 |
commit | 14b958ba17f57356efac03f34384b0052da8a2b0 (patch) | |
tree | 3f99e34ef5a79f62e5cde46efd4c3ce57e788c20 /lang/nawk | |
parent | e9fcf60c148ef2c6ba7efe1ca29d14847266f962 (diff) | |
download | freebsd-ports-gnome-14b958ba17f57356efac03f34384b0052da8a2b0.tar.gz freebsd-ports-gnome-14b958ba17f57356efac03f34384b0052da8a2b0.tar.zst freebsd-ports-gnome-14b958ba17f57356efac03f34384b0052da8a2b0.zip |
Add patches:
- replace sprintf with snprintf
- use calloc() to avoid malloc(n * m) overflows
- NetBSD PR 36831: In setfval(), ensure that arithmetic never yields a negative
zero result.
- Restore the traditional (FreeBSD <= 2.x) behavior of trapping FPEs. With this
patch we pass mawk's fpe_test.
PR: 125348
Submitted by: "Pedro F. Giffuni" <pfgshield-freebsd@yahoo.com>
Diffstat (limited to 'lang/nawk')
-rw-r--r-- | lang/nawk/Makefile | 1 | ||||
-rw-r--r-- | lang/nawk/files/patch-b.c | 67 | ||||
-rw-r--r-- | lang/nawk/files/patch-lib.c | 29 | ||||
-rw-r--r-- | lang/nawk/files/patch-main.c | 19 | ||||
-rw-r--r-- | lang/nawk/files/patch-tran.c | 23 |
5 files changed, 139 insertions, 0 deletions
diff --git a/lang/nawk/Makefile b/lang/nawk/Makefile index b27362d50e0f..fad4ffdace4c 100644 --- a/lang/nawk/Makefile +++ b/lang/nawk/Makefile @@ -8,6 +8,7 @@ PORTNAME= nawk PORTVERSION= 20071023 +PORTREVISION= 1 CATEGORIES= lang MASTER_SITES= http://www.cs.princeton.edu/~bwk/btl.mirror/ DISTNAME= awk diff --git a/lang/nawk/files/patch-b.c b/lang/nawk/files/patch-b.c new file mode 100644 index 000000000000..6ed634861b0b --- /dev/null +++ b/lang/nawk/files/patch-b.c @@ -0,0 +1,67 @@ +--- b.c.orig 2007-03-31 15:56:18.000000000 -0500 ++++ b.c 2008-07-07 08:44:50.000000000 -0500 +@@ -84,8 +84,8 @@ + + if (setvec == 0) { /* first time through any RE */ + maxsetvec = MAXLIN; +- setvec = (int *) malloc(maxsetvec * sizeof(int)); +- tmpset = (int *) malloc(maxsetvec * sizeof(int)); ++ setvec = (int *) calloc(maxsetvec, sizeof(int)); ++ tmpset = (int *) calloc(maxsetvec, sizeof(int)); + if (setvec == 0 || tmpset == 0) + overflo("out of space initializing makedfa"); + } +@@ -137,7 +137,7 @@ + f->accept = poscnt-1; /* penter has computed number of positions in re */ + cfoll(f, p1); /* set up follow sets */ + freetr(p1); +- if ((f->posns[0] = (int *) calloc(1, *(f->re[0].lfollow)*sizeof(int))) == NULL) ++ if ((f->posns[0] = (int *) calloc(*(f->re[0].lfollow), sizeof(int))) == NULL) + overflo("out of space in makedfa"); + if ((f->posns[1] = (int *) calloc(1, sizeof(int))) == NULL) + overflo("out of space in makedfa"); +@@ -157,7 +157,7 @@ + f->reset = 0; + k = *(f->re[0].lfollow); + xfree(f->posns[2]); +- if ((f->posns[2] = (int *) calloc(1, (k+1)*sizeof(int))) == NULL) ++ if ((f->posns[2] = (int *) calloc(k+1, sizeof(int))) == NULL) + overflo("out of space in makeinit"); + for (i=0; i <= k; i++) { + (f->posns[2])[i] = (f->re[0].lfollow)[i]; +@@ -357,7 +357,7 @@ + setvec[i] = 0; + setcnt = 0; + follow(v); /* computes setvec and setcnt */ +- if ((p = (int *) calloc(1, (setcnt+1)*sizeof(int))) == NULL) ++ if ((p = (int *) calloc(setcnt+1, sizeof(int))) == NULL) + overflo("out of space building follow set"); + f->re[info(v)].lfollow = p; + *p = setcnt; +@@ -531,7 +531,7 @@ + for (i = 2; i <= f->curstat; i++) + xfree(f->posns[i]); + k = *f->posns[0]; +- if ((f->posns[2] = (int *) calloc(1, (k+1)*sizeof(int))) == NULL) ++ if ((f->posns[2] = (int *) calloc(k+1, sizeof(int))) == NULL) + overflo("out of space in pmatch"); + for (i = 0; i <= k; i++) + (f->posns[2])[i] = (f->posns[0])[i]; +@@ -588,7 +588,7 @@ + for (i = 2; i <= f->curstat; i++) + xfree(f->posns[i]); + k = *f->posns[0]; +- if ((f->posns[2] = (int *) calloc(1, (k+1)*sizeof(int))) == NULL) ++ if ((f->posns[2] = (int *) calloc(k+1, sizeof(int))) == NULL) + overflo("out of state space"); + for (i = 0; i <= k; i++) + (f->posns[2])[i] = (f->posns[0])[i]; +@@ -920,7 +920,7 @@ + for (i = 0; i < NCHARS; i++) + f->gototab[f->curstat][i] = 0; + xfree(f->posns[f->curstat]); +- if ((p = (int *) calloc(1, (setcnt+1)*sizeof(int))) == NULL) ++ if ((p = (int *) calloc(setcnt+1, sizeof(int))) == NULL) + overflo("out of space in cgoto"); + + f->posns[f->curstat] = p; diff --git a/lang/nawk/files/patch-lib.c b/lang/nawk/files/patch-lib.c new file mode 100644 index 000000000000..242068fd485e --- /dev/null +++ b/lang/nawk/files/patch-lib.c @@ -0,0 +1,29 @@ +--- lib.c.orig 2007-10-22 18:17:52.000000000 -0500 ++++ lib.c 2008-07-07 09:38:58.000000000 -0500 +@@ -59,7 +59,7 @@ + { + if ( (record = (char *) malloc(n)) == NULL + || (fields = (char *) malloc(n+1)) == NULL +- || (fldtab = (Cell **) malloc((nfields+1) * sizeof(Cell *))) == NULL ++ || (fldtab = (Cell **) calloc((nfields+1), sizeof(Cell *))) == NULL + || (fldtab[0] = (Cell *) malloc(sizeof(Cell))) == NULL ) + FATAL("out of space for $0 and fields"); + *fldtab[0] = dollar0; +@@ -78,7 +78,7 @@ + if (fldtab[i] == NULL) + FATAL("out of space in makefields %d", i); + *fldtab[i] = dollar1; +- sprintf(temp, "%d", i); ++ snprintf(temp, sizeof temp, "%d", i); + fldtab[i]->nval = tostring(temp); + } + } +@@ -226,7 +226,7 @@ + char *s, temp[50]; + extern Array *ARGVtab; + +- sprintf(temp, "%d", n); ++ snprintf(temp, sizeof temp, "%d", n); + x = setsymtab(temp, "", 0.0, STR, ARGVtab); + s = getsval(x); + dprintf( ("getargv(%d) returns |%s|\n", n, s) ); diff --git a/lang/nawk/files/patch-main.c b/lang/nawk/files/patch-main.c new file mode 100644 index 000000000000..216f75e8d550 --- /dev/null +++ b/lang/nawk/files/patch-main.c @@ -0,0 +1,19 @@ +--- main.c.orig 2007-05-01 16:05:28.000000000 -0500 ++++ main.c 2008-07-08 15:33:37.000000000 -0500 +@@ -34,6 +34,8 @@ + #include "awk.h" + #include "ytab.h" + ++#include <fenv.h> ++ + extern char **environ; + extern int nfields; + +@@ -67,6 +69,7 @@ + exit(1); + } + signal(SIGFPE, fpecatch); ++ feenableexcept(FE_DIVBYZERO|FE_INEXACT|FE_OVERFLOW); + yyin = NULL; + symtab = makesymtab(NSYMTAB/NSYMTAB); + while (argc > 1 && argv[1][0] == '-' && argv[1][1] != '\0') { diff --git a/lang/nawk/files/patch-tran.c b/lang/nawk/files/patch-tran.c new file mode 100644 index 000000000000..94ae657a6eca --- /dev/null +++ b/lang/nawk/files/patch-tran.c @@ -0,0 +1,23 @@ +diff -u -p -r1.6 -r1.9.10.1 +--- tran.c.orig 2005/07/03 15:18:11 1.6 ++++ tran.c 2007/11/06 23:07:52 1.9.10.1 +@@ -210,7 +210,10 @@ Cell *setsymtab(const char *n, const cha + int h; + Cell *p; + +- if (n != NULL && (p = lookup(n, tp)) != NULL) { ++ if (n == NULL) ++ n = ""; ++ ++ if ((p = lookup(n, tp)) != NULL) { + dprintf( ("setsymtab found %p: n=%s s=\"%s\" f=%g t=%o\n", + p, NN(p->nval), NN(p->sval), p->fval, p->tval) ); + return(p); +@@ -282,6 +285,7 @@ Awkfloat setfval(Cell *vp, Awkfloat f) / + { + int fldno; + ++ f += 0.0; /* normalise negative zero to positive zero */ + if ((vp->tval & (NUM | STR)) == 0) + funnyvar(vp, "assign to"); + if (isfld(vp)) { |