summaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorru <ru@FreeBSD.org>2004-02-08 21:32:21 +0000
committerru <ru@FreeBSD.org>2004-02-08 21:32:21 +0000
commit90fe2c86f7f5001762e4c3af00a323f801d8b737 (patch)
treea4aeceb1822c31fd30a3fff6c51686bbbbbed3de /contrib
parenta1d941195d09954508ee356f30d7989bb1d426c4 (diff)
downloadFreeBSD-src-90fe2c86f7f5001762e4c3af00a323f801d8b737.zip
FreeBSD-src-90fe2c86f7f5001762e4c3af00a323f801d8b737.tar.gz
Vendor import of bwk's 7-Feb-2004 release.
Diffstat (limited to 'contrib')
-rw-r--r--contrib/one-true-awk/FIXES18
-rw-r--r--contrib/one-true-awk/b.c14
-rw-r--r--contrib/one-true-awk/main.c2
-rw-r--r--contrib/one-true-awk/run.c9
4 files changed, 39 insertions, 4 deletions
diff --git a/contrib/one-true-awk/FIXES b/contrib/one-true-awk/FIXES
index 296a2c9..cfd60e4 100644
--- a/contrib/one-true-awk/FIXES
+++ b/contrib/one-true-awk/FIXES
@@ -25,6 +25,24 @@ THIS SOFTWARE.
This file lists all bug fixes, changes, etc., made since the AWK book
was sent to the printers in August, 1987.
+Nov 22, 2003:
+ fixed a bug in regular expressions that dates (so help me) from 1977;
+ it's been there from the beginning. an anchored longest match that
+ was longer than the number of states triggered a failure to initialize
+ the machine properly. many thanks to moinak ghosh for not only finding
+ this one but for providing a fix, in some of the most mysterious
+ code known to man.
+
+ fixed a storage leak in call() that appears to have been there since
+ 1983 or so -- a function without an explicit return that assigns a
+ string to a parameter leaked a Cell. thanks to moinak ghosh for
+ spotting this very subtle one.
+
+Jul 31, 2003:
+ fixed, thanks to andrey chernov and ruslan ermilov, a bug in lex.c
+ that mis-handled the character 255 in input. (it was being compared
+ to EOF with a signed comparison.)
+
Jul 29, 2003:
fixed (i think) the long-standing botch that included the beginning of
line state ^ for RE's in the set of valid characters; this led to a
diff --git a/contrib/one-true-awk/b.c b/contrib/one-true-awk/b.c
index 0f949be..e6e4cc9 100644
--- a/contrib/one-true-awk/b.c
+++ b/contrib/one-true-awk/b.c
@@ -482,7 +482,12 @@ int pmatch(fa *f, const char *p0) /* longest match, for sub */
uschar *q;
int i, k;
- s = f->reset ? makeinit(f,1) : f->initstat;
+ /* s = f->reset ? makeinit(f,1) : f->initstat; */
+ if (f->reset) {
+ f->initstat = s = makeinit(f,1);
+ } else {
+ s = f->initstat;
+ }
patbeg = (char *) p;
patlen = -1;
do {
@@ -535,7 +540,12 @@ int nematch(fa *f, const char *p0) /* non-empty match, for sub */
uschar *q;
int i, k;
- s = f->reset ? makeinit(f,1) : f->initstat;
+ /* s = f->reset ? makeinit(f,1) : f->initstat; */
+ if (f->reset) {
+ f->initstat = s = makeinit(f,1);
+ } else {
+ s = f->initstat;
+ }
patlen = -1;
while (*p) {
q = p;
diff --git a/contrib/one-true-awk/main.c b/contrib/one-true-awk/main.c
index 5ca7c6c..2c061bb 100644
--- a/contrib/one-true-awk/main.c
+++ b/contrib/one-true-awk/main.c
@@ -22,7 +22,7 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
****************************************************************/
-const char *version = "version 20030731";
+const char *version = "version 20040207";
#define DEBUG
#include <stdio.h>
diff --git a/contrib/one-true-awk/run.c b/contrib/one-true-awk/run.c
index 066cb01..4648c83 100644
--- a/contrib/one-true-awk/run.c
+++ b/contrib/one-true-awk/run.c
@@ -219,6 +219,7 @@ Cell *call(Node **a, int n) /* function call. very kludgy and fragile */
{
static Cell newcopycell = { OCELL, CCOPY, 0, "", 0.0, NUM|STR|DONTFREE };
int i, ncall, ndef;
+ int freed = 0; /* handles potential double freeing when fcn & param share a tempcell */
Node *x;
Cell *args[NARGS], *oargs[NARGS]; /* BUG: fixed size arrays */
Cell *y, *z, *fcn;
@@ -296,12 +297,18 @@ Cell *call(Node **a, int n) /* function call. very kludgy and fragile */
} else if (t != y) { /* kludge to prevent freeing twice */
t->csub = CTEMP;
tempfree(t);
+ } else if (t == y && t->csub == CCOPY) {
+ t->csub = CTEMP;
+ tempfree(t);
+ freed = 1;
}
}
tempfree(fcn);
if (isexit(y) || isnext(y))
return y;
- tempfree(y); /* this can free twice! */
+ if (freed == 0) {
+ tempfree(y); /* don't free twice! */
+ }
z = fp->retval; /* return value */
dprintf( ("%s returns %g |%s| %o\n", s, getfval(z), getsval(z), z->tval) );
fp--;
OpenPOWER on IntegriCloud