Simplified interface a bit.

This commit is contained in:
shivers 1995-10-27 08:58:58 +00:00
parent bd91c003cc
commit 79ee1de13c
2 changed files with 17 additions and 15 deletions

View File

@ -69,8 +69,7 @@
(define (%regexp-match regexp string start start-vec end-vec)
(receive (err match?) (%regexp-match/errno regexp string start
start-vec end-vec)
(if (not (equal? err "")) (error err %regexp-match)
match?)))
(if err (error err %regexp-match regexp string start) match?)))
;;; I do this one in C, I'm not sure why:

View File

@ -27,9 +27,11 @@ void regerror(char *msg) {regexp_error = msg;}
char *reg_match(const char *re, const char *string, int start,
scheme_value start_vec, scheme_value end_vec, int *hit)
{
regexp *prog = regcomp(re);
regexp *prog;
regexp_error = 0;
*hit = 0;
prog = regcomp(re);
if( !prog ) return regexp_error;
if( VECTOR_LENGTH(start_vec) != NSUBEXP ) {
@ -42,7 +44,6 @@ char *reg_match(const char *re, const char *string, int start,
return "Illegal end vector";
}
regexp_error = "";
if( regexec(prog, string+start) ) {
int i;
for(i=0; i<NSUBEXP; i++) {
@ -59,18 +60,20 @@ char *reg_match(const char *re, const char *string, int start,
char *filter_stringvec(const char *re, char const **stringvec, int *nummatch)
{
regexp *prog = regcomp(re);
regexp *prog;
regexp_error = 0;
if( prog=regcomp(re) ) {
char const **p = stringvec;
char const **q = p;
if( !prog ) return regexp_error;
while(*p) {
if( regexec(prog, *p) ) *q++ = *p;
p++;
}
Free(prog);
*nummatch = q-stringvec;
return NULL;
}
return regexp_error;
}