summaryrefslogtreecommitdiff
path: root/ext/intl/grapheme/grapheme_util.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/intl/grapheme/grapheme_util.c')
-rw-r--r--ext/intl/grapheme/grapheme_util.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/ext/intl/grapheme/grapheme_util.c b/ext/intl/grapheme/grapheme_util.c
index 8633fddf5b..2625a93263 100644
--- a/ext/intl/grapheme/grapheme_util.c
+++ b/ext/intl/grapheme/grapheme_util.c
@@ -126,6 +126,17 @@ int32_t grapheme_strpos_utf16(char *haystack, size_t haystack_len, char *needle,
ubrk_setText(bi, uhaystack, uhaystack_len, &status);
STRPOS_CHECK_STATUS(status, "Failed to set up iterator");
+ if (uneedle_len == 0) {
+ offset_pos = grapheme_get_haystack_offset(bi, last && offset >= 0 ? uhaystack_len : offset);
+ if (offset_pos == -1) {
+ zend_argument_value_error(3, "must be contained in argument #1 ($haystack)");
+ ret_pos = -1;
+ goto finish;
+ }
+ ret_pos = offset_pos;
+ goto finish;
+ }
+
status = U_ZERO_ERROR;
src = usearch_open(uneedle, uneedle_len, uhaystack, uhaystack_len, "", bi, &status);
STRPOS_CHECK_STATUS(status, "Error creating search object");