aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRuslan Ermilov <ru@FreeBSD.org>2004-02-08 21:32:21 +0000
committerRuslan Ermilov <ru@FreeBSD.org>2004-02-08 21:32:21 +0000
commit62ebc626e60503378c4818b9c70fb090ca6042c8 (patch)
treea4aeceb1822c31fd30a3fff6c51686bbbbbed3de
parent2e454f23faa1040e80182e324d1562560faeb957 (diff)
downloadsrc-62ebc626e60503378c4818b9c70fb090ca6042c8.tar.gz
src-62ebc626e60503378c4818b9c70fb090ca6042c8.zip
Vendor import of bwk's 7-Feb-2004 release.
Notes
Notes: svn path=/vendor/one-true-awk/dist/; revision=125601
-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 296a2c941c99..cfd60e4ebed8 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 0f949be572ce..e6e4cc9cb43a 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 5ca7c6ce011f..2c061bb4bce5 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 066cb011cb3a..4648c834b974 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--;