home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
278.lha
/
RegexLibrary_v1.0
/
lib1.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-08-06
|
1KB
|
67 lines
/*
* BSD style entry points for the GNU regular expression package.
* Edwin Hoogerbeets 18/07/89
*
* This file may be copied and distributed under the GNU Public
* Licence. See the comment at the top of regex.c for details.
*
* Adapted from Elib by Jim Mackraz, mklib by Edwin Hoogerbeets, and the
* GNU regular expression package by the Free Software Foundation.
*/
#include "regex.h"
/* Entry points compatible with bsd4.2 regex library.
* These must be in a .lib file since they use a global variable
* to store the "previous regular expression" that vi is fond of.
*/
static struct re_pattern_buffer re_comp_buf;
extern char *malloc();
char *re_BSD_initialize()
{
return(re_initialize_buffer(&re_comp_buf,__Upcase));
}
void re_BSD_terminate()
{
re_terminate_buffer(&re_comp_buf);
}
char *
re_comp(s)
char *s;
{
if ( !s ) {
if ( !(re_comp_buf.buffer) )
return ("No previous regular expression");
return((char *)0L);
}
if ( !re_comp_buf.buffer ) {
register char *result;
if ( (result = re_BSD_initialize()) ) {
return( result );
}
}
return( (char *) re_compile_pattern(s, (long) strlen(s), &re_comp_buf,
RE_SYNTAX_GREP) );
}
LONG
re_exec(s)
char *s;
{
long len = strlen (s);
return( (long) 0 <= re_search(&re_comp_buf, s, len, 0L, len, 0L) );
}