]> granicus.if.org Git - php/commitdiff
Fixed bug #28386 (wordwrap() wraps lines 1 character too soon).
authorIlia Alshanetsky <iliaa@php.net>
Thu, 13 May 2004 17:44:23 +0000 (17:44 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Thu, 13 May 2004 17:44:23 +0000 (17:44 +0000)
ext/standard/string.c
ext/standard/tests/strings/bug28386.phpt [new file with mode: 0644]

index 9bac29237199651ce55b798f28c897ab016c0ad8..b328dcf786f816cd3755825c4eaa872f6a1dad02 100644 (file)
@@ -661,7 +661,7 @@ PHP_FUNCTION(wordwrap)
                        } else if (text[current] == ' ') {
                                if (current - laststart >= linelength) {
                                        newtext[current] = breakchar[0];
-                                       laststart = current;
+                                       laststart = current + 1;
                                }
                                lastspace = current;
                        } else if (current - laststart >= linelength && laststart != lastspace) {
diff --git a/ext/standard/tests/strings/bug28386.phpt b/ext/standard/tests/strings/bug28386.phpt
new file mode 100644 (file)
index 0000000..9c7c158
--- /dev/null
@@ -0,0 +1,13 @@
+--TEST--
+Bug #28386 (wordwrap() wraps text 1 character too soon)
+--FILE--
+<?php
+$text = "Some text";
+$string = "$text $text $text $text";
+echo wordwrap($string, 9);
+?>
+--EXPECT--
+Some text
+Some text
+Some text
+Some text