From a31c4edfa39b336510bd6f737d28dd6115b197c9 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Tue, 3 May 2016 16:05:16 +0200 Subject: php-patchwork-utf8: 1.2.6 (backported from Fedora) --- php-patchwork-utf8-pr59-modified-for-1-2.patch | 53 ++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 php-patchwork-utf8-pr59-modified-for-1-2.patch (limited to 'php-patchwork-utf8-pr59-modified-for-1-2.patch') diff --git a/php-patchwork-utf8-pr59-modified-for-1-2.patch b/php-patchwork-utf8-pr59-modified-for-1-2.patch new file mode 100644 index 0000000..8ce79b6 --- /dev/null +++ b/php-patchwork-utf8-pr59-modified-for-1-2.patch @@ -0,0 +1,53 @@ +From a06e40ae49123fe71d78f9d8d94e97826d5ebbae Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Thu, 28 Apr 2016 09:47:06 +0200 +Subject: [PATCH] fix tests for php 5.5.35/5.6.21/7.0.6 + +--- + src/Patchwork/Utf8.php | 4 +++- + tests/PHP/Shim/IntlTest.php | 2 +- + tests/Utf8/HhvmTest.php | 3 ++- + 3 files changed, 6 insertions(+), 3 deletions(-) + +diff --git a/src/Patchwork/Utf8.php b/src/Patchwork/Utf8.php +index 585f063..4363a08 100644 +--- a/src/Patchwork/Utf8.php ++++ b/src/Patchwork/Utf8.php +@@ -235,7 +235,9 @@ public static function strlen($s) + } + public static function strpos($s, $needle, $offset = 0) + { +- return grapheme_strpos($s, $needle, $offset); ++ // ignore invalid negative offset to keep compatility ++ // with php < 5.5.35, < 5.6.21, < 7.0.6 ++ return grapheme_strpos($s, $needle, $offset > 0 ? $offset : 0); + } + public static function strrpos($s, $needle, $offset = 0) + { +diff --git a/tests/Patchwork/Tests/PHP/Shim/IntlTest.php b/tests/PHP/Shim/IntlTest.php +index 1d4d4a7..83b3aa8 100644 +--- a/tests/Patchwork/Tests/PHP/Shim/IntlTest.php ++++ b/tests/Patchwork/Tests/PHP/Shim/IntlTest.php +@@ -122,7 +122,7 @@ public function testGrapheme_strpos() + $this->assertSame(false, grapheme_strpos('abc', '')); + $this->assertSame(false, grapheme_strpos('abc', 'd')); + $this->assertSame(false, grapheme_strpos('abc', 'a', 3)); +- $this->assertSame(0, grapheme_strpos('abc', 'a', -1)); ++ $this->assertSame(0, grapheme_strpos('abc', 'a', 0)); + $this->assertSame(1, grapheme_strpos('한국어', '국')); + $this->assertSame(3, grapheme_stripos('DÉJÀ', 'à')); + $this->assertSame(false, grapheme_strrpos('한국어', '')); +diff --git a/tests/Patchwork/Tests/Utf8/HhvmTest.php b/tests/Utf8/HhvmTest.php +index 8a77da0..4eb6866 100644 +--- a/tests/Patchwork/Tests/Utf8/HhvmTest.php ++++ b/tests/Patchwork/Tests/Utf8/HhvmTest.php +@@ -12,7 +12,8 @@ public function test1() + public function test2() + { + // Negative offset are not allowed but native PHP silently casts them to zero +- $this->assertSame(0, grapheme_strpos('abc', 'a', -1)); ++ // Starting with 5.5.35, 5.6.21, 7.0.6, PHP refuse them ++ $this->assertSame(0, grapheme_strpos('abc', 'a', 0)); + } + + public function test3() -- cgit