got rid of Re_used

This commit is contained in:
Gunnar Ritter 2005-02-19 19:38:24 +00:00
parent 12f5e52169
commit 773cc81104
2 changed files with 10 additions and 12 deletions

19
ex_re.c
View File

@ -73,7 +73,7 @@
#ifndef lint #ifndef lint
#ifdef DOSCCS #ifdef DOSCCS
static char sccsid[] = "@(#)ex_re.c 1.49 (gritter) 2/19/05"; static char sccsid[] = "@(#)ex_re.c 1.50 (gritter) 2/19/05";
#endif #endif
#endif #endif
@ -872,7 +872,7 @@ refree(struct regexp *rp)
{ {
struct regexp *r1 = NULL, *r2 = NULL; struct regexp *r1 = NULL, *r2 = NULL;
if (rp->Re_used == 0) if (rp->Expbuf == 0)
return; return;
if (rp == &re) { if (rp == &re) {
r1 = &scanre; r1 = &scanre;
@ -884,14 +884,14 @@ refree(struct regexp *rp)
r1 = &re; r1 = &re;
r2 = &scanre; r2 = &scanre;
} }
if ((r1->Re_used == 0 || rp->Re_ident != r1->Re_ident) && if ((r1->Expbuf == 0 || rp->Re_ident != r1->Re_ident) &&
(r2->Re_used == 0 || rp->Re_ident != r2->Re_ident)) (r2->Expbuf == 0 || rp->Re_ident != r2->Re_ident)) {
#ifdef UXRE #ifdef UXRE
regfree(rp->Expbuf); regfree(rp->Expbuf);
#else /* !UXRE */ #endif /* UXRE */
free(rp->Expbuf); free(rp->Expbuf);
#endif /* !UXRE */ }
rp->Re_used = 0; rp->Expbuf = 0;
} }
struct regexp * struct regexp *
@ -952,7 +952,7 @@ compile(int eof, int oknl)
"Missing closing delimiter@for regular expression")); "Missing closing delimiter@for regular expression"));
if (c != eof) if (c != eof)
ungetchar(c); ungetchar(c);
if (re.Re_used == 0) if (re.Expbuf == 0)
error(catgets(catd, 1, 137, error(catgets(catd, 1, 137,
"No previous re|No previous regular expression")); "No previous re|No previous regular expression"));
return eof; return eof;
@ -1158,7 +1158,7 @@ complex: cerror(catgets(catd, 1, 139,
goto complex; goto complex;
if (value(IGNORECASE)) if (value(IGNORECASE))
loconv(re.Patbuf, re.Patbuf); loconv(re.Patbuf, re.Patbuf);
if (_compile(re.Patbuf, re.Expbuf, &((char *)re.Expbuf)[n], '\0') == 0) { if (_compile(re.Patbuf, re.Expbuf, &((char *)re.Expbuf)[n], '\0')==0) {
char *cp; char *cp;
free(re.Expbuf); free(re.Expbuf);
switch (regerrno) { switch (regerrno) {
@ -1210,7 +1210,6 @@ complex: cerror(catgets(catd, 1, 139,
re.Circfl = circf; re.Circfl = circf;
re.Nbra = nbra; re.Nbra = nbra;
#endif /* !UXRE */ #endif /* !UXRE */
re.Re_used = 1;
re.Re_ident++; re.Re_ident++;
return eof; return eof;
} }

View File

@ -72,7 +72,7 @@
* *
* from ex_re.h 7.3 (Berkeley) 5/31/85 * from ex_re.h 7.3 (Berkeley) 5/31/85
* *
* @(#)ex_re.h 1.20 (gritter) 2/19/05 * @(#)ex_re.h 1.21 (gritter) 2/19/05
*/ */
/* /*
@ -87,7 +87,6 @@
struct regexp { struct regexp {
char Patbuf[2*LBSIZE + 1]; char Patbuf[2*LBSIZE + 1];
long Re_ident; long Re_ident;
bool Re_used;
void *Expbuf; void *Expbuf;
bool Circfl; bool Circfl;
short Nbra; short Nbra;