/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1985-2011 AT&T Intellectual Property *
* and is licensed under the *
* Common Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* David Korn <dgk@research.att.com> *
* Phong Vo <kpv@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* posix regex record executor
* multiple record sized-buffer interface
*/
#include "reglib.h"
/*
* call regnexec() on records selected by Boyer-Moore
*/
int
regrexec(const regex_t* p, const char* s, size_t len, size_t nmatch, regmatch_t* match, regflags_t flags, int sep, void* handle, regrecord_t record)
{
register unsigned char* buf = (unsigned char*)s;
register unsigned char* beg;
register unsigned char* l;
register unsigned char* r;
register unsigned char* x;
register int n;
unsigned char* end;
int complete;
int exactlen;
int leftlen;
int rightlen;
int inv;
Bm_mask_t m;
Rex_t* e;
return REG_BADPAT;
for (;;)
{
goto impossible;
do
{
if (!n--)
goto possible;
continue;
if (inv)
{
goto invert;
}
n = 0;
goto done;
while (l > beg)
if (*--l == sep)
{
l++;
break;
}
if ((r - l) < leftlen)
goto spanned;
r++;
goto spanned;
if (complete || (env->rex = ((r - l) > 128) ? e : e->next) && !(n = regnexec(p, (char*)l, r - l, nmatch, match, flags)))
{
if (inv)
{
x = beg;
while (beg < l)
{
while (x < l && *x != sep)
x++;
goto done;
beg = ++x;
}
}
goto done;
{
goto done;
}
beg = r + 1;
}
else if (n != REG_NOMATCH)
goto done;
else
{
goto impossible;
}
}
done:
return n;
}