/***********************************************************************
* *
* 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
/*
* regcmp implementation
*/
#include <ast.h>
#include <libgen.h>
#include <regex.h>
#include <align.h>
typedef struct
{
char* cur;
int nsub;
} Regex_t;
__DEFINE__(char*, __loc1, 0);
static void*
{
return 0;
return data;
}
char*
{
register char* s;
register size_t n;
register int c;
register int p;
int b;
int e;
int i;
int j;
int nsub;
e = 1;
else
{
e = 0;
n = 0;
p = -1;
b = 0;
nsub = 0;
s = (char*)pattern;
do
{
while (c = *s++)
{
if (c == '\\')
{
if (!(c = *s++))
break;
}
else if (b)
{
if (c == ']')
b = 0;
}
else if (c == '[')
{
b = 1;
if (*s == '^')
{
c = *s++;
}
if (*s == ']')
{
c = *s++;
}
}
else if (c == '(')
{
/*
* someone explain in one sentence why
* a cast is needed to make this work
*/
p++;
paren[p] = ++n;
}
else if (c == ')' && p >= 0)
{
for (i = p; i > 0; i--)
if (paren[i])
break;
if (*s == '$' && (j = *(s + 1)) >= '0' && j <= '9')
{
s += 2;
j -= '0';
if (nsub <= j)
{
if (!nsub)
nsub = j + 1;
}
}
paren[i] = 0;
}
}
}
if (e)
return 0;
{
sfstrclose(sp);
return 0;
}
re = 0;
n = 0;
do
{
{
if (re)
sfstrclose(sp);
return 0;
}
} while (c == REG_ESPACE);
sfstrclose(sp);
if (c)
{
return 0;
}
return (char*)re;
}
char*
{
register int n;
register int i;
register int k;
k = 1;
else
{
k = 0;
}
if (k)
return 0;
return 0;
{
i--;
*(sub[n] + k) = 0;
}
}