diff --git a/Examples/test-suite/rename_pcre_encoder.i b/Examples/test-suite/rename_pcre_encoder.i index 568a2a82d..1bee1dca8 100644 --- a/Examples/test-suite/rename_pcre_encoder.i +++ b/Examples/test-suite/rename_pcre_encoder.i @@ -3,9 +3,14 @@ // strip the wx prefix from all identifiers except those starting with wxEVT %rename("%(regex:/wx(?!EVT)(.*)/\\1/)s") ""; +// Replace "Set" prefix with "put" in all functions +%rename("%(regex:/^Set(.*)/put\\1/)s", %$isfunction) ""; + %inline %{ -class wxSomeWidget { +struct wxSomeWidget { + void SetBorderWidth(int); + void SetSize(int, int); }; struct wxAnotherWidget { diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c index b3c647546..2105f0c51 100644 --- a/Source/Swig/misc.c +++ b/Source/Swig/misc.c @@ -1188,6 +1188,8 @@ String *Swig_string_regex(String *s) { int captures[30]; if (split_regex_pattern_subst(s, &pattern, &subst, &input)) { + int rc; + compiled_pat = pcre_compile( Char(pattern), pcre_options, &pcre_error, &pcre_errorpos, NULL); if (!compiled_pat) { @@ -1195,8 +1197,15 @@ String *Swig_string_regex(String *s) { pcre_error, Char(pattern), pcre_errorpos); exit(1); } - pcre_exec(compiled_pat, NULL, input, strlen(input), 0, 0, captures, 30); - res = replace_captures(input, subst, captures); + rc = pcre_exec(compiled_pat, NULL, input, strlen(input), 0, 0, captures, 30); + if (rc >= 0) { + res = replace_captures(input, subst, captures); + } + else if (rc != PCRE_ERROR_NOMATCH) { + Swig_error("SWIG", Getline(s), "PCRE execution failed: error %d while matching \"%s\" in \"%s\".\n", + rc, Char(pattern), input); + exit(1); + } } DohDelete(pattern);