summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2018-11-12 09:44:16 -0800
committerKaz Kylheku <kaz@kylheku.com>2018-11-12 09:44:16 -0800
commit156004248adbb220505567309dfb1fc22f7ab5e4 (patch)
treed77bc96e3e4e1fd7cbd1c2d58e243d465984fe45
parentcbbc5ef781ae63626a3d8775ec3d45384fd2c1e4 (diff)
downloadtxr-156004248adbb220505567309dfb1fc22f7ab5e4.tar.gz
txr-156004248adbb220505567309dfb1fc22f7ab5e4.tar.bz2
txr-156004248adbb220505567309dfb1fc22f7ab5e4.zip
regex: relocate unlikely case after other tests.
* regex.c (reg_derivative): When classifying the regex's operator, don't check for vanishingly unlikely internal error cases first; that should be done at the end.
-rw-r--r--regex.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/regex.c b/regex.c
index a911bf80..cb8e391d 100644
--- a/regex.c
+++ b/regex.c
@@ -1844,9 +1844,7 @@ static val reg_derivative(val exp, val ch)
val sym = first(exp);
val args = rest(exp);
- if (sym == set_s || sym == cset_s) {
- uw_throwf(error_s, lit("uncompiled regex passed to reg_derivative"), nao);
- } else if (sym == compound_s) {
+ if (sym == compound_s) {
return reg_derivative_list(args, ch);
} else if (sym == optional_s) {
return reg_derivative(first(args), ch);
@@ -1901,6 +1899,8 @@ static val reg_derivative(val exp, val ch)
return t;
return cons(and_s, cons(d_arg1, cons(d_arg2, nil)));
+ } else if (sym == set_s || sym == cset_s) {
+ uw_throwf(error_s, lit("uncompiled regex passed to reg_derivative"), nao);
} else {
uw_throwf(error_s, lit("bad operator in regex syntax: ~s"), sym, nao);
}