Browse Source

Fix calculation of output buffer size in wordwrap(). (Thanks to Wez.)

experimental/new_ui_api
jim winstead 25 years ago
parent
commit
349936c93e
  1. 2
      ext/standard/string.c
  2. 2
      ext/standard/tests/strings/wordwrap.phpt

2
ext/standard/string.c

@ -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;

2
ext/standard/tests/strings/wordwrap.phpt

@ -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');

Loading…
Cancel
Save