mirror of
https://github.com/php/php-src.git
synced 2025-08-20 01:14:28 +02:00
MFH (fixed #42085)
This commit is contained in:
parent
1d48a1081c
commit
1d44054407
1 changed files with 8 additions and 2 deletions
|
@ -858,7 +858,7 @@ mbfl_strpos(
|
||||||
int offset,
|
int offset,
|
||||||
int reverse)
|
int reverse)
|
||||||
{
|
{
|
||||||
int n, result;
|
int n, result, negative_offset = 0;
|
||||||
unsigned char *p;
|
unsigned char *p;
|
||||||
mbfl_convert_filter *filter;
|
mbfl_convert_filter *filter;
|
||||||
struct collector_strpos_data pc;
|
struct collector_strpos_data pc;
|
||||||
|
@ -904,6 +904,12 @@ mbfl_strpos(
|
||||||
mbfl_wchar_device_clear(&pc.needle);
|
mbfl_wchar_device_clear(&pc.needle);
|
||||||
return -4;
|
return -4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (offset < 0) {
|
||||||
|
negative_offset = -offset-1;
|
||||||
|
offset = 0;
|
||||||
|
}
|
||||||
|
|
||||||
pc.start = offset;
|
pc.start = offset;
|
||||||
pc.output = 0;
|
pc.output = 0;
|
||||||
pc.needle_pos = 0;
|
pc.needle_pos = 0;
|
||||||
|
@ -912,7 +918,7 @@ mbfl_strpos(
|
||||||
|
|
||||||
/* feed data */
|
/* feed data */
|
||||||
p = haystack->val;
|
p = haystack->val;
|
||||||
n = haystack->len;
|
n = haystack->len - negative_offset;
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
while (n > 0) {
|
while (n > 0) {
|
||||||
if ((*filter->filter_function)(*p++, filter) < 0) {
|
if ((*filter->filter_function)(*p++, filter) < 0) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue