Simplified interface a bit.
This commit is contained in:
parent
bd91c003cc
commit
79ee1de13c
|
@ -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:
|
||||
|
|
29
scsh/re1.c
29
scsh/re1.c
|
@ -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);
|
||||
char const **p = stringvec;
|
||||
char const **q = p;
|
||||
|
||||
if( !prog ) return regexp_error;
|
||||
regexp *prog;
|
||||
regexp_error = 0;
|
||||
|
||||
while(*p) {
|
||||
if( regexec(prog, *p) ) *q++ = *p;
|
||||
p++;
|
||||
if( prog=regcomp(re) ) {
|
||||
char const **p = stringvec;
|
||||
char const **q = p;
|
||||
|
||||
while(*p) {
|
||||
if( regexec(prog, *p) ) *q++ = *p;
|
||||
p++;
|
||||
}
|
||||
Free(prog);
|
||||
*nummatch = q-stringvec;
|
||||
}
|
||||
|
||||
Free(prog);
|
||||
*nummatch = q-stringvec;
|
||||
return NULL;
|
||||
return regexp_error;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue