/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1985-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* 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 decompiler
*/
#include "reglib.h"
static void
{
register Trie_node_t* y;
char* o;
int k;
o = p;
k = 1;
do
{
if (k)
{
o = p;
if (p < e)
*p++ = x->c;
}
{
}
{
p = o;
}
} while (x = x->son);
}
static int
{
Rex_t* q;
unsigned char* s;
unsigned char* t;
int c;
int m;
int cb;
int cd;
int cr;
int ib;
int ie;
int nb;
int ne;
do
{
switch (e->type)
{
case REX_ALT:
return 1;
if (e->re.group.expr.binary.right && decomp(e->re.group.expr.binary.right, sp, type, delimiter, flags))
return 1;
break;
case REX_BACK:
break;
case REX_BEG:
break;
case REX_END:
break;
case REX_WBEG:
break;
case REX_WEND:
break;
case REX_WORD:
break;
case REX_CLASS:
case REX_COLL_CLASS:
case REX_ONECHAR:
case REX_DOT:
case REX_REP:
{
c = ')';
if (e->hi == RE_DUP_INF)
{
if (!e->lo)
else if (e->lo == 1)
else
}
else if (e->hi != 1)
else if (e->lo == 0)
else
c = 0;
}
switch (e->type)
{
case REX_REP:
return 1;
break;
case REX_CLASS:
s = nc;
t = ic;
for (m = 0; m <= UCHAR_MAX; m++)
{
if (m == ']')
cb = 1;
else if (m == '-')
cr = 1;
else if (m == delimiter)
cd = 1;
else if (nb < 0)
else if (ne == (m - 1))
ne = m;
else
{
*s++ = ne;
else
{
*s++ = nb;
*s++ = '-';
*s++ = ne;
}
}
}
else
{
if (m == ']')
cb = -1;
else if (m == '-')
cr = -1;
else if (m == delimiter)
cd = -1;
else if (ib < 0)
else if (ie == (m - 1))
ie = m;
else
{
*t++ = ie;
else
{
*t++ = ib;
*t++ = '-';
*t++ = ie;
}
}
}
if (nb >= 0)
{
*s++ = nb;
{
*s++ = '-';
*s++ = ne;
}
}
if (ib >= 0)
{
*t++ = ib;
{
*t++ = '-';
*t++ = ie;
}
}
{
if (cb < 0)
if (cr < 0)
{
if (flags & REG_ESCAPE)
}
}
else
{
if (cb > 0)
if (cr > 0)
{
if (flags & REG_ESCAPE)
}
if (nc[0] == '^')
{
}
else
}
break;
case REX_COLL_CLASS:
break;
case REX_ONECHAR:
break;
case REX_DOT:
break;
}
{
if (e->hi == RE_DUP_INF)
{
if (!e->lo)
else
{
}
}
{
}
else if (e->lo == 0)
}
else if (c)
break;
case REX_STRING:
case REX_KMP:
while (s < t)
{
c = *s++;
}
break;
case REX_TRIE:
ib = 0;
for (c = 0; c <= UCHAR_MAX; c++)
{
if (ib)
else
ib = 1;
}
break;
case REX_NEG:
return 1;
else
break;
case REX_CONJ:
return 1;
return 1;
break;
case REX_GROUP:
return 1;
break;
case REX_GROUP_AHEAD:
case REX_GROUP_AHEAD_NOT:
case REX_GROUP_BEHIND:
case REX_GROUP_BEHIND_NOT:
return 1;
break;
case REX_GROUP_COND:
if (e->re.group.expr.binary.left && decomp(e->re.group.expr.binary.left, sp, type, delimiter, flags))
return 1;
{
if (q->re.group.expr.binary.left && decomp(q->re.group.expr.binary.left, sp, type, delimiter, flags))
return 1;
if (q->re.group.expr.binary.right && decomp(q->re.group.expr.binary.right, sp, type, delimiter, flags))
return 1;
}
break;
case REX_GROUP_CUT:
return 1;
break;
case REX_BM:
break;
default:
break;
}
} while (e = e->next);
return 0;
}
/*
* reconstruct pattern from compiled re p into sp
*/
{
char* s;
int type;
int delimiter;
size_t r;
return 0;
if (flags == (regflags_t)~0)
{
case 0:
break;
case REG_AUGMENTED:
case REG_AUGMENTED|REG_EXTENDED:
break;
case REG_EXTENDED:
break;
case REG_SHELL:
break;
default:
break;
}
if (flags & REG_DELIMITED)
{
delimiter = '/';
}
else
delimiter = -1;
r = 0;
else
{
if (delimiter > 0)
{
r = 0;
else
}
}
sfstrclose(sp);
return r;
}