Back out part of the last change. This broke on the alpha (or wherever

sizeof(u_int32_t) != sizeof(*)), at least in cases with re->re_g->nstates
between 32 and 64.
Primary reason for the breakage was that the "states1" definition didn't
work as expected. (It didn't work before either, but this was not noticed
due to sizeof(long)==sizeof(*).)
The alpha can handle larger problems with the "small" state machine model
if a "long" is used as state variable, so it is better to keep the old
definition here. (u_int32_t is left for the "operator" variables.)
Use "int" as "sopno" - this is used as index into the states field, there
is no point in using a fized-size type.
This commit is contained in:
drochner 1998-12-08 13:41:42 +00:00
parent 997074f17c
commit c300f8f462
2 changed files with 22 additions and 21 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: regex2.h,v 1.7 1998/11/14 16:43:49 christos Exp $ */
/* $NetBSD: regex2.h,v 1.8 1998/12/08 13:41:42 drochner Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994 Henry Spencer.
@ -78,14 +78,15 @@
* immediately *preceding* "execution" of that operator.
*/
typedef u_int32_t sop; /* strip operator */
typedef int32_t sopno;
typedef int sopno;
#define OPRMASK ((u_int32_t)0xf8000000UL)
#define OPDMASK ((u_int32_t)0x07ffffffUL)
#define OPSHIFT ((u_int32_t)27)
#define OPC(n) (((u_int32_t)(n))<<OPSHIFT)
#define OPSHIFT ((unsigned)27)
#define OP(n) ((n)&OPRMASK)
#define OPND(n) ((int32_t)((n)&OPDMASK))
#define OPND(n) ((int)((n)&OPDMASK))
#define SOP(op, opnd) ((op)|(opnd))
#define OPC(n) (((u_int32_t)(n))<<OPSHIFT)
/* operators meaning operand */
/* (back, fwd are offsets) */
#define OEND OPC(1) /* endmarker - */

View File

@ -1,4 +1,4 @@
/* $NetBSD: regexec.c,v 1.11 1998/11/14 16:43:49 christos Exp $ */
/* $NetBSD: regexec.c,v 1.12 1998/12/08 13:41:43 drochner Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994 Henry Spencer.
@ -44,7 +44,7 @@
#if 0
static char sccsid[] = "@(#)regexec.c 8.3 (Berkeley) 3/20/94";
#else
__RCSID("$NetBSD: regexec.c,v 1.11 1998/11/14 16:43:49 christos Exp $");
__RCSID("$NetBSD: regexec.c,v 1.12 1998/12/08 13:41:43 drochner Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@ -72,27 +72,27 @@ __weak_alias(regexec,_regexec);
#include "regex2.h"
/* macros for manipulating states, small version */
#define states int32_t
#define states1 states /* for later use in regexec() decision */
#define states unsigned long
#define states1 unsigned long /* for later use in regexec() decision */
#define CLEAR(v) ((v) = 0)
#define SET0(v, n) ((v) &= ~((u_int32_t)1 << (n)))
#define SET1(v, n) ((v) |= (u_int32_t)1 << (n))
#define ISSET(v, n) (((v) & ((u_int32_t)1 << (n))) != 0)
#define SET0(v, n) ((v) &= ~((unsigned long)1 << (n)))
#define SET1(v, n) ((v) |= (unsigned long)1 << (n))
#define ISSET(v, n) (((v) & ((unsigned long)1 << (n))) != 0)
#define ASSIGN(d, s) ((d) = (s))
#define EQ(a, b) ((a) == (b))
#define STATEVARS int32_t dummy /* dummy version */
#define STATEVARS int dummy /* dummy version */
#define STATESETUP(m, n) /* nothing */
#define STATETEARDOWN(m) /* nothing */
#define SETUP(v) ((v) = 0)
#define onestate int32_t
#define INIT(o, n) ((o) = (u_int32_t)1 << (n))
#define onestate unsigned long
#define INIT(o, n) ((o) = (unsigned long)1 << (n))
#define INC(o) ((o) <<= 1)
#define ISSTATEIN(v, o) (((v) & (o)) != 0)
/* some abbreviations; note that some of these know variable names! */
/* do "if I'm here, I can also be there" etc without branches */
#define FWD(dst, src, n) ((dst) |= ((u_int32_t)(src)&(here)) << (n))
#define BACK(dst, src, n) ((dst) |= ((u_int32_t)(src)&(here)) >> (n))
#define ISSETBACK(v, n) (((v) & ((u_int32_t)here >> (n))) != 0)
#define FWD(dst, src, n) ((dst) |= ((unsigned long)(src)&(here)) << (n))
#define BACK(dst, src, n) ((dst) |= ((unsigned long)(src)&(here)) >> (n))
#define ISSETBACK(v, n) (((v) & ((unsigned long)here >> (n))) != 0)
/* function names */
#define SNAMES /* engine.c looks after details */
@ -127,13 +127,13 @@ __weak_alias(regexec,_regexec);
#define ISSET(v, n) ((v)[n])
#define ASSIGN(d, s) memcpy(d, s, (size_t)m->g->nstates)
#define EQ(a, b) (memcmp(a, b, (size_t)m->g->nstates) == 0)
#define STATEVARS int32_t vn; char *space
#define STATESETUP(m, nv) { (m)->space = malloc((size_t)((nv)*(m)->g->nstates)); \
#define STATEVARS int vn; char *space
#define STATESETUP(m, nv) { (m)->space = malloc((size_t)((nv)*(m)->g->nstates)); \
if ((m)->space == NULL) return(REG_ESPACE); \
(m)->vn = 0; }
#define STATETEARDOWN(m) { free((m)->space); }
#define SETUP(v) ((v) = &m->space[(size_t)(m->vn++ * m->g->nstates)])
#define onestate int32_t
#define onestate int
#define INIT(o, n) ((o) = (n))
#define INC(o) ((o)++)
#define ISSTATEIN(v, o) ((v)[o])