Vendor import of bwk's 7-Feb-2004 release.

This commit is contained in:
Ruslan Ermilov 2004-02-08 21:32:21 +00:00
parent 2e454f23fa
commit 62ebc626e6
4 changed files with 39 additions and 4 deletions

View File

@ -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

View File

@ -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;

View File

@ -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>

View File

@ -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--;