diff --git a/changelog.txt b/changelog.txt
index 05e17f4..e017bd1 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -1,3 +1,7 @@
+Version: 2024.11.6
+
+ Git issue 546: Partial match not working in some instances with non-greedy capture
+
Version: 2024.9.14
Reverted to actions/download-artifact@v3 and actions/upload-artifact@v3 in main.yml because GitHub Actions failed when using them.
diff --git a/regex_3/_regex.c b/regex_3/_regex.c
index 9164e75..7a84294 100644
--- a/regex_3/_regex.c
+++ b/regex_3/_regex.c
@@ -16535,9 +16535,6 @@ Py_LOCAL_INLINE(int) basic_match(RE_State* state, BOOL search) {
RE_PARTIAL_RIGHT)
return RE_ERROR_PARTIAL;
- if (pos >= limit)
- break;
-
/* Look for the tail string. */
found = string_search(state, test, pos + 1, limit +
length, TRUE, &is_partial);
@@ -16593,9 +16590,6 @@ Py_LOCAL_INLINE(int) basic_match(RE_State* state, BOOL search) {
RE_PARTIAL_RIGHT)
return RE_ERROR_PARTIAL;
- if (pos >= limit)
- break;
-
/* Look for the tail string. */
found = string_search_fld(state, test, pos + 1, limit,
&new_pos, &is_partial);
@@ -16651,9 +16645,6 @@ Py_LOCAL_INLINE(int) basic_match(RE_State* state, BOOL search) {
if (pos <= state->text_start && state->partial_side == RE_PARTIAL_LEFT)
return RE_ERROR_PARTIAL;
- if (pos <= limit)
- break;
-
/* Look for the tail string. */
found = string_search_fld_rev(state, test, pos - 1,
limit, &new_pos, &is_partial);
@@ -16713,9 +16704,6 @@ Py_LOCAL_INLINE(int) basic_match(RE_State* state, BOOL search) {
RE_PARTIAL_RIGHT)
return RE_ERROR_PARTIAL;
- if (pos >= limit)
- break;
-
/* Look for the tail string. */
found = string_search_ign(state, test, pos + 1, limit +
length, TRUE, &is_partial);
@@ -16773,9 +16761,6 @@ Py_LOCAL_INLINE(int) basic_match(RE_State* state, BOOL search) {
if (pos <= state->text_start && state->partial_side == RE_PARTIAL_LEFT)
return RE_ERROR_PARTIAL;
- if (pos <= limit)
- break;
-
/* Look for the tail string. */
found = string_search_ign_rev(state, test, pos - 1,
limit - length, TRUE, &is_partial);
@@ -16833,9 +16818,6 @@ Py_LOCAL_INLINE(int) basic_match(RE_State* state, BOOL search) {
if (pos <= state->text_start && state->partial_side == RE_PARTIAL_LEFT)
return RE_ERROR_PARTIAL;
- if (pos <= limit)
- break;
-
/* Look for the tail string. */
found = string_search_rev(state, test, pos - 1, limit -
length, TRUE, &is_partial);
diff --git a/regex_3/regex.py b/regex_3/regex.py
index 3019c38..0fdb4da 100644
--- a/regex_3/regex.py
+++ b/regex_3/regex.py
@@ -241,7 +241,7 @@
"VERSION1", "X", "VERBOSE", "W", "WORD", "error", "Regex", "__version__",
"__doc__", "RegexFlag"]
-__version__ = "2.5.147"
+__version__ = "2.5.148"
# --------------------------------------------------------------------
# Public interface.
diff --git a/regex_3/test_regex.py b/regex_3/test_regex.py
index dc72f26..bce5a87 100644
--- a/regex_3/test_regex.py
+++ b/regex_3/test_regex.py
@@ -4346,6 +4346,16 @@ def test_hg_bugs(self):
self.assertEqual(regex.match(r"(?i)[^/]*b/xyz", "b/xy", partial=True).span(), (0, 4))
self.assertEqual(regex.match(r"(?i)[^/]*b/xyz", "b/yz", partial=True), None)
+ # Git issue 546: Partial match not working in some instances with non-greedy capture
+ self.assertEqual(bool(regex.match(r'.*?', '<', partial=True)), True)
+ self.assertEqual(bool(regex.match(r'.*?', '.*?', '', partial=True)), True)
+ self.assertEqual(bool(regex.match(r'.*?', 'x', partial=True)), True)
+ self.assertEqual(bool(regex.match(r'.*?', 'xyz abc', partial=True)), True)
+ self.assertEqual(bool(regex.match(r'.*?', 'xyz abc foo', partial=True)), True)
+ self.assertEqual(bool(regex.match(r'.*?', 'xyz abc foo ', partial=True)), True)
+ self.assertEqual(bool(regex.match(r'.*?', 'xyz abc foo bar', partial=True)), True)
+
def test_fuzzy_ext(self):
self.assertEqual(bool(regex.fullmatch(r'(?r)(?:a){e<=1:[a-z]}', 'e')),
True)
diff --git a/setup.py b/setup.py
index 55ae8ce..ba64e5f 100644
--- a/setup.py
+++ b/setup.py
@@ -8,7 +8,7 @@
setup(
name='regex',
- version='2024.9.11',
+ version='2024.11.6',
description='Alternative regular expression module, to replace re.',
long_description=long_description,
long_description_content_type='text/x-rst',