version 1.12, 1999/09/16 11:45:20 |
version 1.12.10.2, 2002/08/01 03:28:15 |
|
|
#define print sprint |
#define print sprint |
#define at sat |
#define at sat |
#define match smat |
#define match smat |
|
#define nope snope |
#endif |
#endif |
#ifdef LNAMES |
#ifdef LNAMES |
#define matcher lmatcher |
#define matcher lmatcher |
|
|
#define print lprint |
#define print lprint |
#define at lat |
#define at lat |
#define match lmat |
#define match lmat |
|
#define nope lnope |
#endif |
#endif |
|
|
/* another structure passed up and down to avoid zillions of parameters */ |
/* another structure passed up and down to avoid zillions of parameters */ |
Line 126 static char *pchar __P((int ch)); |
|
Line 128 static char *pchar __P((int ch)); |
|
#define SP(t, s, c) print(m, t, s, c, stdout) |
#define SP(t, s, c) print(m, t, s, c, stdout) |
#define AT(t, p1, p2, s1, s2) at(m, t, p1, p2, s1, s2) |
#define AT(t, p1, p2, s1, s2) at(m, t, p1, p2, s1, s2) |
#define NOTE(str) { if (m->eflags®_TRACE) printf("=%s\n", (str)); } |
#define NOTE(str) { if (m->eflags®_TRACE) printf("=%s\n", (str)); } |
|
static int nope = 0; |
#else |
#else |
#define SP(t, s, c) /* nothing */ |
#define SP(t, s, c) /* nothing */ |
#define AT(t, p1, p2, s1, s2) /* nothing */ |
#define AT(t, p1, p2, s1, s2) /* nothing */ |
|
|
const sopno gl = g->laststate; |
const sopno gl = g->laststate; |
char *start; |
char *start; |
char *stop; |
char *stop; |
|
int error = 0; |
|
|
_DIAGASSERT(g != NULL); |
_DIAGASSERT(g != NULL); |
_DIAGASSERT(string != NULL); |
_DIAGASSERT(string != NULL); |
|
|
for (;;) { |
for (;;) { |
endp = fast(m, start, stop, gf, gl); |
endp = fast(m, start, stop, gf, gl); |
if (endp == NULL) { /* a miss */ |
if (endp == NULL) { /* a miss */ |
STATETEARDOWN(m); |
error = REG_NOMATCH; |
return(REG_NOMATCH); |
goto done; |
} |
} |
if (nmatch == 0 && !g->backrefs) |
if (nmatch == 0 && !g->backrefs) |
break; /* no further info needed */ |
break; /* no further info needed */ |
|
|
m->pmatch = (regmatch_t *)malloc((m->g->nsub + 1) * |
m->pmatch = (regmatch_t *)malloc((m->g->nsub + 1) * |
sizeof(regmatch_t)); |
sizeof(regmatch_t)); |
if (m->pmatch == NULL) { |
if (m->pmatch == NULL) { |
STATETEARDOWN(m); |
error = REG_ESPACE; |
return(REG_ESPACE); |
goto done; |
} |
} |
for (i = 1; i <= m->g->nsub; i++) |
for (i = 1; i <= m->g->nsub; i++) |
m->pmatch[i].rm_so = m->pmatch[i].rm_eo = (regoff_t)-1; |
m->pmatch[i].rm_so = m->pmatch[i].rm_eo = (regoff_t)-1; |
|
|
m->lastpos = (char **)malloc((g->nplus+1) * |
m->lastpos = (char **)malloc((g->nplus+1) * |
sizeof(char *)); |
sizeof(char *)); |
if (g->nplus > 0 && m->lastpos == NULL) { |
if (g->nplus > 0 && m->lastpos == NULL) { |
free(m->pmatch); |
error = REG_ESPACE; |
STATETEARDOWN(m); |
goto done; |
return(REG_ESPACE); |
|
} |
} |
NOTE("backref dissect"); |
NOTE("backref dissect"); |
dp = backref(m, m->coldp, endp, gf, gl, (sopno)0); |
dp = backref(m, m->coldp, endp, gf, gl, (sopno)0); |
|
|
} |
} |
} |
} |
|
|
if (m->pmatch != NULL) |
done: |
|
if (m->pmatch != NULL) { |
free(m->pmatch); |
free(m->pmatch); |
if (m->lastpos != NULL) |
m->pmatch = NULL; |
|
} |
|
if (m->lastpos != NULL) { |
free(m->lastpos); |
free(m->lastpos); |
|
m->lastpos = NULL; |
|
} |
STATETEARDOWN(m); |
STATETEARDOWN(m); |
return(0); |
return error; |
} |
} |
|
|
/* |
/* |
|
|
#undef print |
#undef print |
#undef at |
#undef at |
#undef match |
#undef match |
|
#undef nope |