]> granicus.if.org Git - php/commitdiff
- Fix for bug #8367 (wordwrap not cutting correctly)
authorDerick Rethans <derick@php.net>
Thu, 18 Jan 2001 21:46:24 +0000 (21:46 +0000)
committerDerick Rethans <derick@php.net>
Thu, 18 Jan 2001 21:46:24 +0000 (21:46 +0000)
ext/standard/string.c

index 15311417c5a666cfa427149bdbd98086798bd74c..c68f5d35d56b41258ebc97356f47333fe1d1214c 100644 (file)
@@ -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;