|
| 1 | +diff --git a/src/fa.c b/src/fa.c |
| 2 | +index 66ac70784..4de5675b9 100644 |
| 3 | +--- a/src/fa.c |
| 4 | ++++ b/src/fa.c |
| 5 | +@@ -3550,6 +3550,8 @@ static struct re *parse_regexp(struct re_parse *parse) { |
| 6 | + return re; |
| 7 | + |
| 8 | + error: |
| 9 | ++ if (re == NULL && parse->error == REG_NOERROR) |
| 10 | ++ parse->error = _REG_ENOSYS; |
| 11 | + re_unref(re); |
| 12 | + return NULL; |
| 13 | + } |
| 14 | +diff --git a/src/fa.h b/src/fa.h |
| 15 | +index 1fd754ad0..89c9b17e9 100644 |
| 16 | +--- a/src/fa.h |
| 17 | ++++ b/src/fa.h |
| 18 | +@@ -81,7 +81,8 @@ extern int fa_minimization_algorithm; |
| 19 | + * |
| 20 | + * On success, FA points to the newly allocated automaton constructed for |
| 21 | + * RE, and the function returns REG_NOERROR. Otherwise, FA is NULL, and the |
| 22 | +- * return value indicates the error. |
| 23 | ++ * return value indicates the error. Special value _REG_ENOSYS indicates |
| 24 | ++ * fa_compile() couldn't identify the syntax issue with regexp. |
| 25 | + * |
| 26 | + * The FA is case sensitive. Call FA_NOCASE to switch it to |
| 27 | + * case-insensitive. |
| 28 | +diff --git a/tests/fatest.c b/tests/fatest.c |
| 29 | +index 0c9ca7696..6717af8f4 100644 |
| 30 | +--- a/tests/fatest.c |
| 31 | ++++ b/tests/fatest.c |
| 32 | +@@ -589,6 +589,7 @@ static void testExpandNoCase(CuTest *tc) { |
| 33 | + const char *p1 = "aB"; |
| 34 | + const char *p2 = "[a-cUV]"; |
| 35 | + const char *p3 = "[^a-z]"; |
| 36 | ++ const char *wrong_regexp = "{&.{"; |
| 37 | + char *s; |
| 38 | + size_t len; |
| 39 | + int r; |
| 40 | +@@ -607,6 +608,11 @@ static void testExpandNoCase(CuTest *tc) { |
| 41 | + CuAssertIntEquals(tc, 0, r); |
| 42 | + CuAssertStrEquals(tc, "[^A-Za-z]", s); |
| 43 | + free(s); |
| 44 | ++ |
| 45 | ++ /* Test that fa_expand_nocase does return _REG_ENOSYS */ |
| 46 | ++ r = fa_expand_nocase(wrong_regexp, strlen(wrong_regexp), &s, &len); |
| 47 | ++ CuAssertIntEquals(tc, _REG_ENOSYS, r); |
| 48 | ++ free(s); |
| 49 | + } |
| 50 | + |
| 51 | + static void testNoCaseComplement(CuTest *tc) { |
0 commit comments