summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/standard/string.c38
-rw-r--r--ext/standard/tests/strings/bug63943.phpt8
-rw-r--r--ext/standard/tests/strings/stripos.phpt17
-rw-r--r--ext/standard/tests/strings/stripos_variation1.phpt20
-rw-r--r--ext/standard/tests/strings/stripos_variation10.phpt18
-rw-r--r--ext/standard/tests/strings/stripos_variation11.phpt16
-rw-r--r--ext/standard/tests/strings/stripos_variation2.phpt20
-rw-r--r--ext/standard/tests/strings/stripos_variation3.phpt2
-rw-r--r--ext/standard/tests/strings/stripos_variation7.phpt6
-rw-r--r--ext/standard/tests/strings/stristr.phpt12
-rw-r--r--ext/standard/tests/strings/stristr_error.phpt31
-rw-r--r--ext/standard/tests/strings/stristr_variation2.phpt26
-rw-r--r--ext/standard/tests/strings/strpos.phptbin9009 -> 7939 bytes
-rw-r--r--ext/standard/tests/strings/strpos_variation1.phpt23
-rw-r--r--ext/standard/tests/strings/strripos.phpt14
-rw-r--r--ext/standard/tests/strings/strripos_variation1.phpt40
-rw-r--r--ext/standard/tests/strings/strripos_variation2.phpt40
-rw-r--r--ext/standard/tests/strings/strripos_variation3.phpt2
-rw-r--r--ext/standard/tests/strings/strripos_variation6.phpt23
-rw-r--r--ext/standard/tests/strings/strrpos.phpt14
-rw-r--r--ext/standard/tests/strings/strrpos_variation1.phpt20
-rw-r--r--ext/standard/tests/strings/strrpos_variation10.phpt16
-rw-r--r--ext/standard/tests/strings/strrpos_variation11.phpt34
-rw-r--r--ext/standard/tests/strings/strrpos_variation14.phpt23
-rw-r--r--ext/standard/tests/strings/strrpos_variation2.phpt20
-rw-r--r--ext/standard/tests/strings/strrpos_variation3.phpt2
-rw-r--r--ext/standard/tests/strings/strrpos_variation7.phpt10
-rw-r--r--ext/standard/tests/strings/strstr.phptbin9649 -> 9539 bytes
-rw-r--r--ext/standard/tests/strings/strstr_variation1.phpt23
29 files changed, 278 insertions, 240 deletions
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 7d7d0faaa0..526eb1353a 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -1812,11 +1812,6 @@ PHP_FUNCTION(stristr)
Z_PARAM_BOOL(part)
ZEND_PARSE_PARAMETERS_END();
- if (!ZSTR_LEN(needle)) {
- php_error_docref(NULL, E_WARNING, "Empty needle");
- RETURN_FALSE;
- }
-
haystack_dup = estrndup(ZSTR_VAL(haystack), ZSTR_LEN(haystack));
orig_needle = estrndup(ZSTR_VAL(needle), ZSTR_LEN(needle));
found = php_stristr(haystack_dup, orig_needle, ZSTR_LEN(haystack), ZSTR_LEN(needle));
@@ -1853,11 +1848,6 @@ PHP_FUNCTION(strstr)
Z_PARAM_BOOL(part)
ZEND_PARSE_PARAMETERS_END();
- if (!ZSTR_LEN(needle)) {
- php_error_docref(NULL, E_WARNING, "Empty needle");
- RETURN_FALSE;
- }
-
found = php_memnstr(ZSTR_VAL(haystack), ZSTR_VAL(needle), ZSTR_LEN(needle), ZSTR_VAL(haystack) + ZSTR_LEN(haystack));
if (found) {
@@ -1899,11 +1889,6 @@ PHP_FUNCTION(strpos)
RETURN_FALSE;
}
- if (!ZSTR_LEN(needle)) {
- php_error_docref(NULL, E_WARNING, "Empty needle");
- RETURN_FALSE;
- }
-
found = (char*)php_memnstr(ZSTR_VAL(haystack) + offset,
ZSTR_VAL(needle), ZSTR_LEN(needle),
ZSTR_VAL(haystack) + ZSTR_LEN(haystack));
@@ -1940,7 +1925,7 @@ PHP_FUNCTION(stripos)
RETURN_FALSE;
}
- if (ZSTR_LEN(needle) == 0 || ZSTR_LEN(needle) > ZSTR_LEN(haystack)) {
+ if (ZSTR_LEN(needle) > ZSTR_LEN(haystack)) {
RETURN_FALSE;
}
@@ -1964,23 +1949,18 @@ PHP_FUNCTION(stripos)
Finds position of last occurrence of a string within another string */
PHP_FUNCTION(strrpos)
{
+ zend_string *needle;
zend_string *haystack;
- char *needle;
- size_t needle_len;
zend_long offset = 0;
const char *p, *e, *found;
ZEND_PARSE_PARAMETERS_START(2, 3)
Z_PARAM_STR(haystack)
- Z_PARAM_STRING(needle, needle_len)
+ Z_PARAM_STR(needle)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(offset)
ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
- if (ZSTR_LEN(haystack) == 0 || needle_len == 0) {
- RETURN_FALSE;
- }
-
if (offset >= 0) {
if ((size_t)offset > ZSTR_LEN(haystack)) {
php_error_docref(NULL, E_WARNING, "Offset not contained in string");
@@ -1993,15 +1973,16 @@ PHP_FUNCTION(strrpos)
php_error_docref(NULL, E_WARNING, "Offset not contained in string");
RETURN_FALSE;
}
+
p = ZSTR_VAL(haystack);
- if ((size_t)-offset < needle_len) {
+ if ((size_t)-offset < ZSTR_LEN(needle)) {
e = ZSTR_VAL(haystack) + ZSTR_LEN(haystack);
} else {
- e = ZSTR_VAL(haystack) + ZSTR_LEN(haystack) + offset + needle_len;
+ e = ZSTR_VAL(haystack) + ZSTR_LEN(haystack) + offset + ZSTR_LEN(needle);
}
}
- if ((found = zend_memnrstr(p, needle, needle_len, e))) {
+ if ((found = zend_memnrstr(p, ZSTR_VAL(needle), ZSTR_LEN(needle), e))) {
RETURN_LONG(found - ZSTR_VAL(haystack));
}
@@ -2026,10 +2007,6 @@ PHP_FUNCTION(strripos)
Z_PARAM_LONG(offset)
ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
- if (ZSTR_LEN(haystack) == 0 || ZSTR_LEN(needle) == 0) {
- RETURN_FALSE;
- }
-
if (ZSTR_LEN(needle) == 1) {
/* Single character search can shortcut memcmps
Can also avoid tolower emallocs */
@@ -2075,6 +2052,7 @@ PHP_FUNCTION(strripos)
php_error_docref(NULL, E_WARNING, "Offset not contained in string");
RETURN_FALSE;
}
+
p = ZSTR_VAL(haystack_dup);
if ((size_t)-offset < ZSTR_LEN(needle)) {
e = ZSTR_VAL(haystack_dup) + ZSTR_LEN(haystack);
diff --git a/ext/standard/tests/strings/bug63943.phpt b/ext/standard/tests/strings/bug63943.phpt
deleted file mode 100644
index 6018879b24..0000000000
--- a/ext/standard/tests/strings/bug63943.phpt
+++ /dev/null
@@ -1,8 +0,0 @@
---TEST--
-Bug #63943 (Bad warning text from strpos() on empty needle)
---FILE--
-<?php
-strpos("lllllll", '');
-?>
---EXPECTF--
-Warning: strpos(): Empty needle in %sbug63943.php on line %d
diff --git a/ext/standard/tests/strings/stripos.phpt b/ext/standard/tests/strings/stripos.phpt
index 4c3c5a7fcc..bc2a7bc8e5 100644
--- a/ext/standard/tests/strings/stripos.phpt
+++ b/ext/standard/tests/strings/stripos.phpt
@@ -25,9 +25,9 @@ stripos() function test
var_dump(stripos("0", false));
var_dump(stripos("1", true));
var_dump(stripos("\\\\a", "\\a"));
-
- echo "Done\n";
?>
+
+DONE
--EXPECT--
int(0)
int(5)
@@ -37,19 +37,20 @@ int(10)
int(2)
int(0)
int(0)
-bool(false)
-bool(false)
-bool(false)
-bool(false)
+int(0)
int(0)
bool(false)
bool(false)
+int(0)
bool(false)
-bool(false)
+int(0)
bool(false)
bool(false)
int(0)
bool(false)
int(0)
+int(0)
+int(0)
int(1)
-Done
+
+DONE
diff --git a/ext/standard/tests/strings/stripos_variation1.phpt b/ext/standard/tests/strings/stripos_variation1.phpt
index 53d6be65e7..c34917ffce 100644
--- a/ext/standard/tests/strings/stripos_variation1.phpt
+++ b/ext/standard/tests/strings/stripos_variation1.phpt
@@ -117,20 +117,20 @@ int(9)
int(8)
bool(false)
-- Iteration 12 --
-bool(false)
-bool(false)
+int(0)
+int(11)
-- Iteration 13 --
-bool(false)
-bool(false)
+int(0)
+int(12)
-- Iteration 14 --
-bool(false)
-bool(false)
+int(0)
+int(13)
-- Iteration 15 --
-bool(false)
-bool(false)
+int(0)
+int(14)
-- Iteration 16 --
-bool(false)
-bool(false)
+int(0)
+int(15)
-- Iteration 17 --
int(10)
int(47)
diff --git a/ext/standard/tests/strings/stripos_variation10.phpt b/ext/standard/tests/strings/stripos_variation10.phpt
index 6792b4d0b2..879da88aa7 100644
--- a/ext/standard/tests/strings/stripos_variation10.phpt
+++ b/ext/standard/tests/strings/stripos_variation10.phpt
@@ -95,7 +95,7 @@ fclose($file_handle); //closing the file handle
echo "*** Done ***";
?>
---EXPECTF--
+--EXPECT--
*** Testing stripos() function with unexpected values for needle ***
-- Iteration 1 --
@@ -144,35 +144,35 @@ stripos() expects parameter 2 to be string, array given
int(9)
-- Iteration 16 --
-bool(false)
+int(0)
-- Iteration 17 --
int(9)
-- Iteration 18 --
-bool(false)
+int(0)
-- Iteration 19 --
int(64)
-- Iteration 20 --
-bool(false)
+int(0)
-- Iteration 21 --
-bool(false)
+int(0)
-- Iteration 22 --
-bool(false)
+int(0)
-- Iteration 23 --
-bool(false)
+int(0)
-- Iteration 24 --
stripos() expects parameter 2 to be string, resource given
-- Iteration 25 --
-bool(false)
+int(0)
-- Iteration 26 --
-bool(false)
+int(0)
*** Done ***
diff --git a/ext/standard/tests/strings/stripos_variation11.phpt b/ext/standard/tests/strings/stripos_variation11.phpt
index aab3181df3..4f002ed0ca 100644
--- a/ext/standard/tests/strings/stripos_variation11.phpt
+++ b/ext/standard/tests/strings/stripos_variation11.phpt
@@ -144,7 +144,7 @@ stripos() expects parameter 1 to be string, array given
int(0)
bool(false)
-- Iteration 16 --
-bool(false)
+int(0)
Warning: stripos(): Offset not contained in string in %s on line %d
bool(false)
@@ -152,7 +152,7 @@ bool(false)
int(0)
bool(false)
-- Iteration 18 --
-bool(false)
+int(0)
Warning: stripos(): Offset not contained in string in %s on line %d
bool(false)
@@ -160,22 +160,22 @@ bool(false)
int(0)
bool(false)
-- Iteration 20 --
-bool(false)
+int(0)
Warning: stripos(): Offset not contained in string in %s on line %d
bool(false)
-- Iteration 21 --
-bool(false)
+int(0)
Warning: stripos(): Offset not contained in string in %s on line %d
bool(false)
-- Iteration 22 --
-bool(false)
+int(0)
Warning: stripos(): Offset not contained in string in %s on line %d
bool(false)
-- Iteration 23 --
-bool(false)
+int(0)
Warning: stripos(): Offset not contained in string in %s on line %d
bool(false)
@@ -183,12 +183,12 @@ bool(false)
stripos() expects parameter 1 to be string, resource given
stripos() expects parameter 1 to be string, resource given
-- Iteration 25 --
-bool(false)
+int(0)
Warning: stripos(): Offset not contained in string in %s on line %d
bool(false)
-- Iteration 26 --
-bool(false)
+int(0)
Warning: stripos(): Offset not contained in string in %s on line %d
bool(false)
diff --git a/ext/standard/tests/strings/stripos_variation2.phpt b/ext/standard/tests/strings/stripos_variation2.phpt
index 0f4c887869..294b088d02 100644
--- a/ext/standard/tests/strings/stripos_variation2.phpt
+++ b/ext/standard/tests/strings/stripos_variation2.phpt
@@ -119,20 +119,20 @@ bool(false)
int(10)
int(10)
-- Iteration 12 --
-bool(false)
-bool(false)
+int(0)
+int(11)
-- Iteration 13 --
-bool(false)
-bool(false)
+int(0)
+int(12)
-- Iteration 14 --
-bool(false)
-bool(false)
+int(0)
+int(13)
-- Iteration 15 --
-bool(false)
-bool(false)
+int(0)
+int(14)
-- Iteration 16 --
-bool(false)
-bool(false)
+int(0)
+int(15)
-- Iteration 17 --
int(14)
int(51)
diff --git a/ext/standard/tests/strings/stripos_variation3.phpt b/ext/standard/tests/strings/stripos_variation3.phpt
index 936f870579..32faf63871 100644
--- a/ext/standard/tests/strings/stripos_variation3.phpt
+++ b/ext/standard/tests/strings/stripos_variation3.phpt
@@ -32,6 +32,6 @@ echo "*** Done ***";
int(14)
int(23)
int(23)
-bool(false)
+int(0)
int(7)
*** Done ***
diff --git a/ext/standard/tests/strings/stripos_variation7.phpt b/ext/standard/tests/strings/stripos_variation7.phpt
index 04c636365f..a21686876d 100644
--- a/ext/standard/tests/strings/stripos_variation7.phpt
+++ b/ext/standard/tests/strings/stripos_variation7.phpt
@@ -25,10 +25,10 @@ echo "*** Done ***";
--EXPECTF--
*** Testing stripos() function: with heredoc strings ***
-- With empty heredoc string --
-bool(false)
+int(0)
Warning: stripos(): Offset not contained in string in %s on line %d
bool(false)
-bool(false)
-bool(false)
+int(0)
+int(0)
*** Done ***
diff --git a/ext/standard/tests/strings/stristr.phpt b/ext/standard/tests/strings/stristr.phpt
index 92cfa09eb1..0d47e80bcb 100644
--- a/ext/standard/tests/strings/stristr.phpt
+++ b/ext/standard/tests/strings/stristr.phpt
@@ -8,10 +8,10 @@ stristr() function
var_dump(stristr("tEsT sTrInG", "t S"));
var_dump(stristr("tEsT sTrInG", "g"));
var_dump(md5(stristr("te".chr(0)."st", chr(0))));
- var_dump(@stristr("", ""));
- var_dump(@stristr("a", ""));
- var_dump(@stristr("", "a"));
- var_dump(md5(@stristr("\\\\a\\", "\\a")));
+ var_dump(stristr("", ""));
+ var_dump(stristr("a", ""));
+ var_dump(stristr("", "a"));
+ var_dump(md5(stristr("\\\\a\\", "\\a")));
var_dump(stristr("tEsT sTrInG", " "));
?>
--EXPECTF--
@@ -21,8 +21,8 @@ string(6) "sTrInG"
string(8) "T sTrInG"
string(1) "G"
string(32) "7272696018bdeb2c9a3f8d01fc2a9273"
-bool(false)
-bool(false)
+string(0) ""
+string(1) "a"
bool(false)
string(32) "6ec19f52f0766c463f3bb240f4396913"
string(7) " sTrInG"
diff --git a/ext/standard/tests/strings/stristr_error.phpt b/ext/standard/tests/strings/stristr_error.phpt
deleted file mode 100644
index a7b683d3b8..0000000000
--- a/ext/standard/tests/strings/stristr_error.phpt
+++ /dev/null
@@ -1,31 +0,0 @@
---TEST--
-Test stristr() function : error conditions
---FILE--
-<?php
-
-/* Prototype: string stristr ( string $haystack , mixed $needle [, bool $before_needle ] )
- Description: Case-insensitive strstr()
-*/
-echo "*** Testing stristr() : error conditions ***\n";
-
-echo "\n-- Testing stristr() function with empty haystack --\n";
-var_dump( stristr(NULL, "") );
-
-echo "\n-- Testing stristr() function with empty needle --\n";
-var_dump( stristr("Hello World", "") );
-
-?>
-===DONE===
---EXPECTF--
-*** Testing stristr() : error conditions ***
-
--- Testing stristr() function with empty haystack --
-
-Warning: stristr(): Empty needle in %s on line %d
-bool(false)
-
--- Testing stristr() function with empty needle --
-
-Warning: stristr(): Empty needle in %s on line %d
-bool(false)
-===DONE===
diff --git a/ext/standard/tests/strings/stristr_variation2.phpt b/ext/standard/tests/strings/stristr_variation2.phpt
index fd842d1106..dd0b34f883 100644
--- a/ext/standard/tests/strings/stristr_variation2.phpt
+++ b/ext/standard/tests/strings/stristr_variation2.phpt
@@ -84,7 +84,7 @@ fclose($file_handle); //closing the file handle
?>
===DONE===
---EXPECTF--
+--EXPECT--
*** Testing stristr() function: with unexpected inputs for 'needle' argument ***
-- Iteration 1 --
bool(false)
@@ -109,33 +109,21 @@ stristr() expects parameter 2 to be string, array given
-- Iteration 11 --
bool(false)
-- Iteration 12 --
-
-Warning: stristr(): Empty needle in %s on line %d
-bool(false)
+string(11) "Hello World"
-- Iteration 13 --
bool(false)
-- Iteration 14 --
-
-Warning: stristr(): Empty needle in %s on line %d
-bool(false)
+string(11) "Hello World"
-- Iteration 15 --
-
-Warning: stristr(): Empty needle in %s on line %d
-bool(false)
+string(11) "Hello World"
-- Iteration 16 --
-
-Warning: stristr(): Empty needle in %s on line %d
-bool(false)
+string(11) "Hello World"
-- Iteration 17 --
bool(false)
-- Iteration 18 --
stristr() expects parameter 2 to be string, resource given
-- Iteration 19 --
-
-Warning: stristr(): Empty needle in %s on line %d
-bool(false)
+string(11) "Hello World"
-- Iteration 20 --
-
-Warning: stristr(): Empty needle in %s on line %d
-bool(false)
+string(11) "Hello World"
===DONE===
diff --git a/ext/standard/tests/strings/strpos.phpt b/ext/standard/tests/strings/strpos.phpt
index 4640b670f3..9fc521d8d8 100644
--- a/ext/standard/tests/strings/strpos.phpt
+++ b/ext/standard/tests/strings/strpos.phpt
Binary files differ
diff --git a/ext/standard/tests/strings/strpos_variation1.phpt b/ext/standard/tests/strings/strpos_variation1.phpt
new file mode 100644
index 0000000000..f28517316d
--- /dev/null
+++ b/ext/standard/tests/strings/strpos_variation1.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Test strpos() function : usage variations - complex strings containing other than 7-bit chars
+--FILE--
+<?php
+$string = chr(0).chr(128).chr(129).chr(234).chr(235).chr(254).chr(255);
+$stringAsHex = bin2hex($string);
+echo "-- Positions of some chars in the string '$stringAsHex' are as follows --\n";
+echo bin2hex( chr(128) ) ." => ";
+var_dump( strpos($string, chr(128)) );
+echo bin2hex( chr(255) ) ." => ";
+var_dump( strpos($string, chr(255), 3) );
+echo bin2hex( chr(256) ) ." => ";
+var_dump( strpos($string, chr(256)) );
+?>
+
+DONE
+--EXPECT--
+-- Positions of some chars in the string '008081eaebfeff' are as follows --
+80 => int(1)
+ff => int(6)
+00 => int(0)
+
+DONE
diff --git a/ext/standard/tests/strings/strripos.phpt b/ext/standard/tests/strings/strripos.phpt
index fa15e2fcac..c343e92731 100644
--- a/ext/standard/tests/strings/strripos.phpt
+++ b/ext/standard/tests/strings/strripos.phpt
@@ -10,11 +10,11 @@ strripos() function
var_dump(strripos("te".chr(0)."st", chr(0)));
var_dump(strripos("tEst", "test"));
var_dump(strripos("teSt", "test"));
- var_dump(@strripos("foo", "f", 1));
- var_dump(@strripos("", ""));
- var_dump(@strripos("a", ""));
- var_dump(@strripos("", "a"));
- var_dump(@strripos("\\\\a", "\\a"));
+ var_dump(strripos("foo", "f", 1));
+ var_dump(strripos("", ""));
+ var_dump(strripos("a", ""));
+ var_dump(strripos("", "a"));
+ var_dump(strripos("\\\\a", "\\a"));
?>
--EXPECT--
int(5)
@@ -26,7 +26,7 @@ int(2)
int(0)
int(0)
bool(false)
-bool(false)
-bool(false)
+int(0)
+int(1)
bool(false)
int(1)
diff --git a/ext/standard/tests/strings/strripos_variation1.phpt b/ext/standard/tests/strings/strripos_variation1.phpt
index ce396695af..8b0c3a35cc 100644
--- a/ext/standard/tests/strings/strripos_variation1.phpt
+++ b/ext/standard/tests/strings/strripos_variation1.phpt
@@ -132,30 +132,30 @@ int(8)
bool(false)
int(8)
-- Iteration 12 --
-bool(false)
-bool(false)
-bool(false)
-bool(false)
+int(44)
+int(44)
+int(44)
+int(43)
-- Iteration 13 --
-bool(false)
-bool(false)
-bool(false)
-bool(false)
+int(44)
+int(44)
+int(44)
+int(43)
-- Iteration 14 --
-bool(false)
-bool(false)
-bool(false)
-bool(false)
+int(44)
+int(44)
+int(44)
+int(43)
-- Iteration 15 --
-bool(false)
-bool(false)
-bool(false)
-bool(false)
+int(44)
+int(44)
+int(44)
+int(43)
-- Iteration 16 --
-bool(false)
-bool(false)
-bool(false)
-bool(false)
+int(44)
+int(44)
+int(44)
+int(43)
-- Iteration 17 --
int(43)
int(43)
diff --git a/ext/standard/tests/strings/strripos_variation2.phpt b/ext/standard/tests/strings/strripos_variation2.phpt
index 3800c32155..affe72a50a 100644
--- a/ext/standard/tests/strings/strripos_variation2.phpt
+++ b/ext/standard/tests/strings/strripos_variation2.phpt
@@ -133,30 +133,30 @@ int(10)
bool(false)
int(10)
-- Iteration 12 --
-bool(false)
-bool(false)
-bool(false)
-bool(false)
+int(54)
+int(54)
+int(54)
+int(53)
-- Iteration 13 --
-bool(false)
-bool(false)
-bool(false)
-bool(false)
+int(54)
+int(54)
+int(54)
+int(53)
-- Iteration 14 --
-bool(false)
-bool(false)
-bool(false)
-bool(false)
+int(54)
+int(54)
+int(54)
+int(53)
-- Iteration 15 --
-bool(false)
-bool(false)
-bool(false)
-bool(false)
+int(54)
+int(54)
+int(54)
+int(53)
-- Iteration 16 --
-bool(false)
-bool(false)
-bool(false)
-bool(false)
+int(54)
+int(54)
+int(54)
+int(53)
-- Iteration 17 --
int(53)
int(53)
diff --git a/ext/standard/tests/strings/strripos_variation3.phpt b/ext/standard/tests/strings/strripos_variation3.phpt
index 4fccaeb47e..0f531f03da 100644
--- a/ext/standard/tests/strings/strripos_variation3.phpt
+++ b/ext/standard/tests/strings/strripos_variation3.phpt
@@ -54,6 +54,6 @@ bool(false)
-- Multi line strings with no offset --
int(18)
int(31)
-bool(false)
+int(63)
int(55)
===DONE===
diff --git a/ext/standard/tests/strings/strripos_variation6.phpt b/ext/standard/tests/strings/strripos_variation6.phpt
new file mode 100644
index 0000000000..92bb70440a
--- /dev/null
+++ b/ext/standard/tests/strings/strripos_variation6.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Test strrpos() function : usage variations - negative offset with empty needle
+--FILE--
+<?php
+$haystack = "Hello,\t\n\0\n $&!#%()*<=>?@hello123456he \x234 \101 ";
+
+var_dump(strlen($haystack));
+
+var_dump( strripos($haystack, "", -1) );
+var_dump( strripos($haystack, "", -10) );
+var_dump( strripos($haystack, "", -26) );
+var_dump( strripos($haystack, "", -44) );
+?>
+
+DONE
+--EXPECT--
+int(44)
+int(43)
+int(34)
+int(18)
+int(0)
+
+DONE
diff --git a/ext/standard/tests/strings/strrpos.phpt b/ext/standard/tests/strings/strrpos.phpt
index 691f67e599..f672d93a2a 100644
--- a/ext/standard/tests/strings/strrpos.phpt
+++ b/ext/standard/tests/strings/strrpos.phpt
@@ -10,11 +10,11 @@ strrpos() function
var_dump(strrpos("te".chr(0)."st", chr(0)));
var_dump(strrpos("tEst", "test"));
var_dump(strrpos("teSt", "test"));
- var_dump(@strrpos("foo", "f", 1));
- var_dump(@strrpos("", ""));
- var_dump(@strrpos("a", ""));
- var_dump(@strrpos("", "a"));
- var_dump(@strrpos("\\\\a", "\\a"));
+ var_dump(strrpos("foo", "f", 1));
+ var_dump(strrpos("", ""));
+ var_dump(strrpos("a", ""));
+ var_dump(strrpos("", "a"));
+ var_dump(strrpos("\\\\a", "\\a"));
?>
--EXPECT--
int(5)
@@ -26,7 +26,7 @@ int(2)
bool(false)
bool(false)
bool(false)
-bool(false)
-bool(false)
+int(0)
+int(1)
bool(false)
int(1)
diff --git a/ext/standard/tests/strings/strrpos_variation1.phpt b/ext/standard/tests/strings/strrpos_variation1.phpt
index 4fc480face..d54adaec73 100644
--- a/ext/standard/tests/strings/strrpos_variation1.phpt
+++ b/ext/standard/tests/strings/strrpos_variation1.phpt
@@ -108,20 +108,20 @@ int(9)
int(8)
bool(false)
-- Iteration 12 --
-bool(false)
-bool(false)
+int(44)
+int(44)
-- Iteration 13 --
-bool(false)
-bool(false)
+int(44)
+int(44)
-- Iteration 14 --
-bool(false)
-bool(false)
+int(44)
+int(44)
-- Iteration 15 --
-bool(false)
-bool(false)
+int(44)
+int(44)
-- Iteration 16 --
-bool(false)
-bool(false)
+int(44)
+int(44)
-- Iteration 17 --
int(43)
int(43)
diff --git a/ext/standard/tests/strings/strrpos_variation10.phpt b/ext/standard/tests/strings/strrpos_variation10.phpt
index 440605d430..2a6b84337c 100644
--- a/ext/standard/tests/strings/strrpos_variation10.phpt
+++ b/ext/standard/tests/strings/strrpos_variation10.phpt
@@ -128,25 +128,25 @@ strrpos() expects parameter 2 to be string, array given
-- Iteration 15 --
int(41)
-- Iteration 16 --
-bool(false)
+int(87)
-- Iteration 17 --
int(41)
-- Iteration 18 --
-bool(false)
+int(87)
-- Iteration 19 --
int(64)
-- Iteration 20 --
-bool(false)
+int(87)
-- Iteration 21 --
-bool(false)
+int(87)
-- Iteration 22 --
-bool(false)
+int(87)
-- Iteration 23 --
-bool(false)
+int(87)
-- Iteration 24 --
strrpos() expects parameter 2 to be string, resource given
-- Iteration 25 --
-bool(false)
+int(87)
-- Iteration 26 --
-bool(false)
+int(87)
*** Done ***
diff --git a/ext/standard/tests/strings/strrpos_variation11.phpt b/ext/standard/tests/strings/strrpos_variation11.phpt
index 71201a1c21..2fbe78e30a 100644
--- a/ext/standard/tests/strings/strrpos_variation11.phpt
+++ b/ext/standard/tests/strings/strrpos_variation11.phpt
@@ -96,7 +96,7 @@ for($index = 0; $index < count($values); $index ++) {
echo "*** Done ***";
?>
---EXPECT--
+--EXPECTF--
*** Testing strrpos() function with unexpected values for haystack and needle ***
-- Iteration 1 --
int(0)
@@ -144,36 +144,52 @@ strrpos() expects parameter 1 to be string, array given
int(0)
bool(false)
-- Iteration 16 --
-bool(false)
+int(0)
+
+Warning: strrpos(): Offset not contained in string in %s on line %d
bool(false)
-- Iteration 17 --
int(0)
bool(false)
-- Iteration 18 --
-bool(false)
+int(0)
+
+Warning: strrpos(): Offset not contained in string in %s on line %d
bool(false)
-- Iteration 19 --
int(0)
bool(false)
-- Iteration 20 --
-bool(false)
+int(0)
+
+Warning: strrpos(): Offset not contained in string in %s on line %d
bool(false)
-- Iteration 21 --
-bool(false)
+int(0)
+
+Warning: strrpos(): Offset not contained in string in %s on line %d
bool(false)
-- Iteration 22 --
-bool(false)
+int(0)
+
+Warning: strrpos(): Offset not contained in string in %s on line %d
bool(false)
-- Iteration 23 --
-bool(false)
+int(0)
+
+Warning: strrpos(): Offset not contained in string in %s on line %d
bool(false)
-- Iteration 24 --
strrpos() expects parameter 1 to be string, resource given
strrpos() expects parameter 1 to be string, resource given
-- Iteration 25 --
-bool(false)
+int(0)
+
+Warning: strrpos(): Offset not contained in string in %s on line %d
bool(false)
-- Iteration 26 --
-bool(false)
+int(0)
+
+Warning: strrpos(): Offset not contained in string in %s on line %d
bool(false)
*** Done ***
diff --git a/ext/standard/tests/strings/strrpos_variation14.phpt b/ext/standard/tests/strings/strrpos_variation14.phpt
new file mode 100644
index 0000000000..d244a19e47
--- /dev/null
+++ b/ext/standard/tests/strings/strrpos_variation14.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Test strrpos() function : usage variations - negative offset with empty needle
+--FILE--
+<?php
+$haystack = "Hello,\t\n\0\n $&!#%()*<=>?@hello123456he \x234 \101 ";
+
+var_dump(strlen($haystack));
+
+var_dump( strrpos($haystack, "", -1) );
+var_dump( strrpos($haystack, "", -10) );
+var_dump( strrpos($haystack, "", -26) );
+var_dump( strrpos($haystack, "", -44) );
+?>
+
+DONE
+--EXPECT--
+int(44)
+int(43)
+int(34)
+int(18)
+int(0)
+
+DONE
diff --git a/ext/standard/tests/strings/strrpos_variation2.phpt b/ext/standard/tests/strings/strrpos_variation2.phpt
index af5c9e349d..3accd165bb 100644
--- a/ext/standard/tests/strings/strrpos_variation2.phpt
+++ b/ext/standard/tests/strings/strrpos_variation2.phpt
@@ -109,20 +109,20 @@ bool(false)
int(10)
int(10)
-- Iteration 12 --
-bool(false)
-bool(false)
+int(54)
+int(54)
-- Iteration 13 --
-bool(false)
-bool(false)
+int(54)
+int(54)
-- Iteration 14 --
-bool(false)
-bool(false)
+int(54)
+int(54)
-- Iteration 15 --
-bool(false)
-bool(false)
+int(54)
+int(54)
-- Iteration 16 --
-bool(false)
-bool(false)
+int(54)
+int(54)
-- Iteration 17 --
int(53)
int(53)
diff --git a/ext/standard/tests/strings/strrpos_variation3.phpt b/ext/standard/tests/strings/strrpos_variation3.phpt
index 460f18cca5..1ebe9e7a21 100644
--- a/ext/standard/tests/strings/strrpos_variation3.phpt
+++ b/ext/standard/tests/strings/strrpos_variation3.phpt
@@ -32,6 +32,6 @@ echo "*** Done ***";
int(44)
int(44)
int(44)
-bool(false)
+int(63)
int(55)
*** Done ***
diff --git a/ext/standard/tests/strings/strrpos_variation7.phpt b/ext/standard/tests/strings/strrpos_variation7.phpt
index c0546c74f8..d5aa8b561c 100644
--- a/ext/standard/tests/strings/strrpos_variation7.phpt
+++ b/ext/standard/tests/strings/strrpos_variation7.phpt
@@ -22,11 +22,13 @@ var_dump( strrpos($empty_string, NULL) );
echo "*** Done ***";
?>
---EXPECT--
+--EXPECTF--
*** Testing strrpos() function: with heredoc strings ***
-- With empty heredoc string --
+int(0)
+
+Warning: strrpos(): Offset not contained in string in %s on line %d
bool(false)
-bool(false)
-bool(false)
-bool(false)
+int(0)
+int(0)
*** Done ***
diff --git a/ext/standard/tests/strings/strstr.phpt b/ext/standard/tests/strings/strstr.phpt
index 6bdc3feab1..81ddee0804 100644
--- a/ext/standard/tests/strings/strstr.phpt
+++ b/ext/standard/tests/strings/strstr.phpt
Binary files differ
diff --git a/ext/standard/tests/strings/strstr_variation1.phpt b/ext/standard/tests/strings/strstr_variation1.phpt
new file mode 100644
index 0000000000..aade1fd5f8
--- /dev/null
+++ b/ext/standard/tests/strings/strstr_variation1.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Test strstr() function : usage variations - complex strings containing other than 7-bit chars
+--FILE--
+<?php
+$string = chr(0).chr(128).chr(129).chr(234).chr(235).chr(254).chr(255);
+$stringAsHex = bin2hex($string);
+echo "-- Positions of some chars in the string '$stringAsHex' are as follows --\n";
+echo bin2hex( chr(128) ) ." => ";
+var_dump( bin2hex( strstr($string, chr(128) ) ) );
+echo bin2hex( chr(255) ) ." => ";
+var_dump( bin2hex( strstr($string, chr(255) ) ) );
+echo bin2hex( chr(256) ) ." => ";
+var_dump( bin2hex( strstr($string, chr(256) ) ) );
+?>
+
+DONE
+--EXPECT--
+-- Positions of some chars in the string '008081eaebfeff' are as follows --
+80 => string(12) "8081eaebfeff"
+ff => string(2) "ff"
+00 => string(14) "008081eaebfeff"
+
+DONE