Don't return duplicate matches when matching empty strings. (#515944) Add

2008-02-17  Marco Barisione  <marco@barisione.org>

	* glib/gregex.c: (match_info_new), (g_match_info_next): Don't return
	duplicate matches when matching empty strings.  (#515944)
	* tests/regex-test.c: Add tests.

svn path=/trunk/; revision=6527
This commit is contained in:
Marco Barisione
2008-02-17 14:07:32 +00:00
committed by Marco Barisione
parent 521e741d56
commit 7e0677b076
3 changed files with 37 additions and 0 deletions

View File

@@ -1786,6 +1786,7 @@ main (int argc, char *argv[])
TEST_MATCH_NEXT3("a", "aaxa", -1, 0, "a", 0, 1, "a", 1, 2, "a", 3, 4);
TEST_MATCH_NEXT3("a", "aa" OGRAVE "a", -1, 0, "a", 0, 1, "a", 1, 2, "a", 4, 5);
TEST_MATCH_NEXT3("a*", "aax", -1, 0, "aa", 0, 2, "", 2, 2, "", 3, 3);
TEST_MATCH_NEXT3("(?=[A-Z0-9])", "RegExTest", -1, 0, "", 0, 0, "", 3, 3, "", 5, 5);
TEST_MATCH_NEXT4("a*", "aaxa", -1, 0, "aa", 0, 2, "", 2, 2, "a", 3, 4, "", 4, 4);
/* TEST_MATCH_COUNT(pattern, string, start_position, match_opts, expected_count) */
@@ -2047,6 +2048,8 @@ main (int argc, char *argv[])
TEST_REPLACE_LIT("[^-]", "-" EURO "-" AGRAVE "-" HSTROKE, 0, "a", "-a-a-a");
TEST_REPLACE_LIT("[^-]", "-" EURO "-" AGRAVE, 0, "a\\g<0>a", "-a\\g<0>a-a\\g<0>a");
TEST_REPLACE_LIT("-", "-" EURO "-" AGRAVE "-" HSTROKE, 0, "", EURO AGRAVE HSTROKE);
TEST_REPLACE_LIT("(?=[A-Z0-9])", "RegExTest", 0, "_", "_Reg_Ex_Test");
TEST_REPLACE_LIT("(?=[A-Z0-9])", "RegExTest", 1, "_", "Reg_Ex_Test");
/* TEST_GET_STRING_NUMBER(pattern, name, expected_num) */
TEST_GET_STRING_NUMBER("", "A", -1);