]> granicus.if.org Git - php/commitdiff
Fix calculation of output buffer size in wordwrap(). (Thanks to Wez.)
authorjim winstead <jimw@php.net>
Mon, 18 Mar 2002 02:00:57 +0000 (02:00 +0000)
committerjim winstead <jimw@php.net>
Mon, 18 Mar 2002 02:00:57 +0000 (02:00 +0000)
ext/standard/string.c
ext/standard/tests/strings/wordwrap.phpt

index e255dc09b587a7d968c07f4aefd43c32e88e7772..09b2e4694177012093b5e3461a5a8647a561611f 100644 (file)
@@ -662,7 +662,7 @@ PHP_FUNCTION(wordwrap)
        else {
                /* Multiple character line break or forced cut */
                if (linelength > 0) {
-                       newtextlen = textlen + (textlen/linelength) * breakcharlen + 1;
+                       newtextlen = textlen + (textlen/linelength + 1) * breakcharlen + 1;
                }
                else {
                        newtextlen = textlen * (breakcharlen + 1) + 1;
index d367b3a82bb8f5955ffee784097192c4f4869a85..3fc8f1d8805a814b73881675aa2d5e8dbec1d3a1 100644 (file)
@@ -27,6 +27,8 @@ $tests = <<<TESTS
 
 "12345|12345|67890" === wordwrap("12345 1234567890", 5, "|", 1)
 
+"123|==1234567890|==123" === wordwrap("123 1234567890 123", 10, "|==", 1)
+
 TESTS;
 
 include('tests/quicktester.inc');