summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/standard/string.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 15311417c5..c68f5d35d5 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -442,7 +442,7 @@ PHP_FUNCTION(wordwrap)
}
if (l == -1) {
/* couldn't break it backwards, try looking forwards */
- l = linelength;
+ l = linelength - 1;
while (l <= pgr) {
if (docut == 0)
{
@@ -456,13 +456,12 @@ PHP_FUNCTION(wordwrap)
if (docut == 1)
{
if (text[i+l] == ' ' || l > i-last) {
- strncat(newtext, text+last, i+l-last);
+ strncat(newtext, text+last, i+l-last+1);
strcat(newtext, breakchar);
- last = i + l;
+ last = i + l + 1;
break;
}
}
- l ++;
}
}
i += l+1;