summaryrefslogtreecommitdiff
path: root/ext/standard/string.c
diff options
context:
space:
mode:
authorjim winstead <jimw@php.net>2002-01-05 23:49:58 +0000
committerjim winstead <jimw@php.net>2002-01-05 23:49:58 +0000
commit4fb4c6d4b39d2e9357d6050286087b40d116193c (patch)
tree9da5416155ac75a79048828b0a69a00400dd8c99 /ext/standard/string.c
parente1876cba4dfa82643a2db41654e65b9cfd972e94 (diff)
downloadphp-git-4fb4c6d4b39d2e9357d6050286087b40d116193c.tar.gz
More tweaking of wordwrap() with the cut parameter set. It was being a
little too aggressive and cutting words without breaking at spaces first. (A couple of tests were incorrect.)
Diffstat (limited to 'ext/standard/string.c')
-rw-r--r--ext/standard/string.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 3149130089..39d41b9531 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -696,8 +696,10 @@ PHP_FUNCTION(wordwrap)
lastspace = current;
}
/* if we are cutting, and we've accumulated enough
- * characters, copy and insert a break. */
- else if (current - laststart >= linelength && docut) {
+ * characters, and we haven't see a space for this line,
+ * copy and insert a break. */
+ else if (current - laststart >= linelength
+ && docut && laststart >= lastspace) {
memcpy(newtext+newtextlen, text+laststart, current-laststart);
newtextlen += current - laststart;
memcpy(newtext+newtextlen, breakchar, breakcharlen);