mirror of https://github.com/tildeclub/ex-vi.git
include regex.h in ex_re.c only
This commit is contained in:
parent
971748839e
commit
6a6d9e4069
22
ex_re.c
22
ex_re.c
|
@ -73,7 +73,7 @@
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
#ifdef DOSCCS
|
#ifdef DOSCCS
|
||||||
static char sccsid[] = "@(#)ex_re.c 1.47 (gritter) 2/19/05";
|
static char sccsid[] = "@(#)ex_re.c 1.48 (gritter) 2/19/05";
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -83,8 +83,12 @@ static char sccsid[] = "@(#)ex_re.c 1.47 (gritter) 2/19/05";
|
||||||
#include "ex_re.h"
|
#include "ex_re.h"
|
||||||
|
|
||||||
#ifdef UXRE
|
#ifdef UXRE
|
||||||
|
|
||||||
|
#include <regex.h>
|
||||||
|
|
||||||
char *braslist[NBRA];
|
char *braslist[NBRA];
|
||||||
char *braelist[NBRA];
|
char *braelist[NBRA];
|
||||||
|
|
||||||
#else /* !UXRE */
|
#else /* !UXRE */
|
||||||
static int regerrno;
|
static int regerrno;
|
||||||
|
|
||||||
|
@ -92,7 +96,7 @@ static int regerrno;
|
||||||
#define GETC() (*sp++)
|
#define GETC() (*sp++)
|
||||||
#define PEEKC() (*sp)
|
#define PEEKC() (*sp)
|
||||||
#define UNGETC(c) (--sp)
|
#define UNGETC(c) (--sp)
|
||||||
#define RETURN(c) return (c);
|
#define RETURN(c) return(ep);
|
||||||
#define ERROR(c) { regerrno = c; return 0; }
|
#define ERROR(c) { regerrno = c; return 0; }
|
||||||
|
|
||||||
#define compile(a, b, c, d) _compile(a, b, c, d)
|
#define compile(a, b, c, d) _compile(a, b, c, d)
|
||||||
|
@ -881,7 +885,7 @@ refree(struct regexp *rp)
|
||||||
if ((r1->Re_used == 0 || rp->Re_ident != r1->Re_ident) &&
|
if ((r1->Re_used == 0 || rp->Re_ident != r1->Re_ident) &&
|
||||||
(r2->Re_used == 0 || rp->Re_ident != r2->Re_ident))
|
(r2->Re_used == 0 || rp->Re_ident != r2->Re_ident))
|
||||||
#ifdef UXRE
|
#ifdef UXRE
|
||||||
regfree(&rp->Expbuf);
|
regfree(rp->Expbuf);
|
||||||
#else /* !UXRE */
|
#else /* !UXRE */
|
||||||
free(rp->Expbuf);
|
free(rp->Expbuf);
|
||||||
#endif /* !UXRE */
|
#endif /* !UXRE */
|
||||||
|
@ -1131,26 +1135,28 @@ complex: cerror(catgets(catd, 1, 139,
|
||||||
#endif /* !NO_BE_BACKSLASH */
|
#endif /* !NO_BE_BACKSLASH */
|
||||||
if (value(IGNORECASE))
|
if (value(IGNORECASE))
|
||||||
c |= REG_ICASE;
|
c |= REG_ICASE;
|
||||||
if ((i = regcomp(&re.Expbuf, re.Patbuf, c)) != 0) {
|
if (re.Expbuf == NULL)
|
||||||
|
re.Expbuf = calloc(1, sizeof (regex_t));
|
||||||
|
if ((i = regcomp(re.Expbuf, re.Patbuf, c)) != 0) {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case REG_EBRACK:
|
case REG_EBRACK:
|
||||||
miss: cerror(catgets(catd, 1, 154, "Missing ]"));
|
miss: cerror(catgets(catd, 1, 154, "Missing ]"));
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
regerror(i, &re.Expbuf, &re.Patbuf[1],
|
regerror(i, re.Expbuf, &re.Patbuf[1],
|
||||||
sizeof re.Patbuf - 1);
|
sizeof re.Patbuf - 1);
|
||||||
cerror(&re.Patbuf[1]);
|
cerror(&re.Patbuf[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((re.Nbra = re.Expbuf.re_nsub) > NBRA)
|
if ((re.Nbra = ((regex_t *)re.Expbuf)->re_nsub) > NBRA)
|
||||||
re.Nbra = NBRA;
|
re.Nbra = NBRA;
|
||||||
#else /* !UXRE */
|
#else /* !UXRE */
|
||||||
if ((re.Expbuf = malloc(n = rcnt*32 + 2*(p-re.Patbuf) + 5)) == NULL)
|
if ((re.Expbuf = malloc(n = rcnt*32 + 2*(p-re.Patbuf) + 5)) == NULL)
|
||||||
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, &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) {
|
||||||
|
@ -1232,7 +1238,7 @@ execute(int gf, line *addr)
|
||||||
* so don't fetch them otherwise (enables use of DFA).
|
* so don't fetch them otherwise (enables use of DFA).
|
||||||
*/
|
*/
|
||||||
nsub = (re.Re_ident == subre.Re_ident ? NBRA : 0);
|
nsub = (re.Re_ident == subre.Re_ident ? NBRA : 0);
|
||||||
switch (regexec(&re.Expbuf, p, nsub + 1, bralist, eflags)) {
|
switch (regexec(re.Expbuf, p, nsub + 1, bralist, eflags)) {
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
case REG_NOMATCH:
|
case REG_NOMATCH:
|
||||||
|
|
12
ex_re.h
12
ex_re.h
|
@ -72,13 +72,9 @@
|
||||||
*
|
*
|
||||||
* from ex_re.h 7.3 (Berkeley) 5/31/85
|
* from ex_re.h 7.3 (Berkeley) 5/31/85
|
||||||
*
|
*
|
||||||
* @(#)ex_re.h 1.19 (gritter) 2/19/05
|
* @(#)ex_re.h 1.20 (gritter) 2/19/05
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef UXRE
|
|
||||||
#include <regex.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Regular expression definitions.
|
* Regular expression definitions.
|
||||||
* The regular expressions in ex are similar to those in ed,
|
* The regular expressions in ex are similar to those in ed,
|
||||||
|
@ -92,11 +88,7 @@ struct regexp {
|
||||||
char Patbuf[2*LBSIZE + 1];
|
char Patbuf[2*LBSIZE + 1];
|
||||||
long Re_ident;
|
long Re_ident;
|
||||||
bool Re_used;
|
bool Re_used;
|
||||||
#ifdef UXRE
|
void *Expbuf;
|
||||||
regex_t Expbuf;
|
|
||||||
#else /* !UXRE */
|
|
||||||
char *Expbuf;
|
|
||||||
#endif /* !UXRE */
|
|
||||||
bool Circfl;
|
bool Circfl;
|
||||||
short Nbra;
|
short Nbra;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue