diff --git a/scsh/re.scm b/scsh/re.scm index e4004f7..7411799 100644 --- a/scsh/re.scm +++ b/scsh/re.scm @@ -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: diff --git a/scsh/re1.c b/scsh/re1.c index e640260..fd7a7eb 100644 --- a/scsh/re1.c +++ b/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