[Coldstuff] patch to fix segfault in regexp/match_regexp
coldstuff@cold.org
coldstuff@cold.org
Wed, 10 Apr 2002 22:47:20 -0400
On Wed, 10 Apr 2002 Brad Roberts wrote:
> Great.. I had looking at this on my todo list and just haven't had a
> chance yet. Can I ask you to write a new test (see genesis/tests/) that
> demonstrates the bug?
Here's some tests for regexp() and match_regexp() which will test literal
matching (1), special character matching (2), case sensitivity (3-4), and
error handling (5-6).
--- test.in.old Wed Apr 10 20:51:59 2002
+++ test.in Wed Apr 10 22:30:37 2002
@@ -2408,9 +2408,27 @@
// Output
String test 12
+ 1 - ["Aa0\^$|()[].*+?"]
+ 2 - ["a"]
+ 3 - ["FOO"]
+ 4 - 0
+ 5 - regexp error resulted
+ 6 - regexp error resulted
eval {
dblog("String test 12");
+ dblog(" 1 - " + regexp("Aa0\\^$|()[].*+?", "Aa0\\\\\^\$\|\(\)\[\]\.\*\+\?"));
+ dblog(" 2 - " + regexp("\\abdeeefffg", "^\\\\(a)[bc].e*f+g?$|_"));
+ dblog(" 3 - " + regexp("FOO", "foo"));
+ dblog(" 4 - " + regexp("FOO", "foo", 1));
+ catch ~regexp
+ dblog(" 5 - " + regexp("", "("));
+ with
+ dblog(" 5 - regexp error resulted");
+ catch ~regexp
+ dblog(" 6 - " + regexp("", "["));
+ with
+ dblog(" 6 - regexp error resulted");
};
// String test 13
@@ -2523,9 +2541,27 @@
// Output
String matching test 5
+ 1 - [[1, 15], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]
+ 2 - [[1, 11], [2, 1], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]
+ 3 - [[1, 3], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]
+ 4 - 0
+ 5 - regexp error resulted
+ 6 - regexp error resulted
eval {
dblog("String matching test 5");
+ dblog(" 1 - " + match_regexp("Aa0\\^$|()[].*+?", "Aa0\\\\\^\$\|\(\)\[\]\.\*\+\?"));
+ dblog(" 2 - " + match_regexp("\\abdeeefffg", "^\\\\(a)[bc].e*f+g?$|_"));
+ dblog(" 3 - " + match_regexp("FOO", "foo"));
+ dblog(" 4 - " + match_regexp("FOO", "foo", 1));
+ catch ~regexp
+ dblog(" 5 - " + match_regexp("", "("));
+ with
+ dblog(" 5 - regexp error resulted");
+ catch ~regexp
+ dblog(" 6 - " + match_regexp("", "["));
+ with
+ dblog(" 6 - regexp error resulted");
};
// Numeric test 1