Skip to content

Commit f604156

Browse files
committed
fix tests...
1 parent 7a709f8 commit f604156

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

runtime-common/stdlib/string/string-functions.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "common/wrappers/string_view.h"
1717
#include "runtime-common/core/runtime-core.h"
1818
#include "runtime-common/core/utils/kphp-assert-core.h"
19+
#include "runtime-common/stdlib/array/array-functions.h"
1920
#include "runtime-common/stdlib/string/string-context.h"
2021

2122
const char* get_mask(const string& what) noexcept {
@@ -1241,12 +1242,12 @@ string f$stripslashes(const string& str) noexcept {
12411242

12421243
Optional<int64_t> f$stripos(const string& haystack, const string& needle, int64_t offset) noexcept {
12431244
if (offset < 0) {
1244-
php_warning("Wrong offset = %" PRIi64 " in function stripos", offset);
1245-
return false;
1245+
offset += haystack.size();
12461246
}
1247-
if (offset >= haystack.size()) {
1247+
if (offset < 0 || offset >= haystack.size()) {
12481248
return false;
12491249
}
1250+
12501251
if (needle.size() == 0) {
12511252
php_warning("Parameter needle is empty in function stripos");
12521253
return false;
@@ -1726,12 +1727,12 @@ int64_t f$strnatcmp(const string& lhs, const string& rhs) noexcept {
17261727

17271728
Optional<int64_t> f$strpos(const string& haystack, const string& needle, int64_t offset) noexcept {
17281729
if (offset < 0) {
1729-
php_warning("Wrong offset = %" PRIi64 " in function strpos", offset);
1730-
return false;
1730+
offset += haystack.size();
17311731
}
1732-
if (offset > int64_t{haystack.size()}) {
1732+
if (offset < 0 || offset >= haystack.size()) {
17331733
return false;
17341734
}
1735+
17351736
if (needle.size() <= 1) {
17361737
if (needle.size() == 0) {
17371738
php_warning("Parameter needle is empty in function strpos");

0 commit comments

Comments
 (0)