diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2018-11-12 09:44:16 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2018-11-12 09:44:16 -0800 |
commit | 1ea67951e4077a69686b7cbdefc061f33cbb10bc (patch) | |
tree | d77bc96e3e4e1fd7cbd1c2d58e243d465984fe45 | |
parent | 42effdc1d12b62c1ccd37fcaccb480728727abc0 (diff) | |
download | txr-1ea67951e4077a69686b7cbdefc061f33cbb10bc.tar.gz txr-1ea67951e4077a69686b7cbdefc061f33cbb10bc.tar.bz2 txr-1ea67951e4077a69686b7cbdefc061f33cbb10bc.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.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -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); } |