regcache.c revision da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968
/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
* and is licensed under the *
* Common Public License, Version 1.0 *
* by AT&T Knowledge Ventures *
* *
* 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
/*
* regcomp() regex_t cache
* AT&T Research
*/
#include <ast.h>
#include <regex.h>
#define KEEP 01
#define DROP 02
typedef struct Cache_s
{
unsigned long serial;
int flags;
} Cache_t;
static struct State_s
{
unsigned long serial;
char* locale;
} matchstate;
/*
* flush the cache
*/
static void
flushcache(void)
{
register int i;
{
}
}
/*
* return regcomp() compiled re for pattern and reflags
*/
{
register int i;
char* s;
int empty;
int unused;
int old;
/*
* 0 pattern flushes the cache
*/
if (!pattern)
{
flushcache();
if (status)
*status = 0;
return 0;
}
/*
* flush the cache if the locale changed
* the ast setlocale() intercept maintains
* persistent setlocale() return values
*/
{
matchstate.locale = s;
flushcache();
}
/*
* check if the pattern is in the cache
*/
old = 0;
if (!matchstate.cache[i])
empty = i;
{
{
}
unused = i;
}
break;
old = i;
{
if (unused < 0)
{
if (empty < 0)
else
}
{
if (status)
*status = REG_ESPACE;
return 0;
}
{
}
{
}
else
{
if (status)
*status = i;
return 0;
}
}
else
if (status)
*status = 0;
}