From: Marcus Boerger Date: Sat, 12 May 2007 11:53:27 +0000 (+0000) Subject: - Impprove cli_wordwrap() make it respectstart of initial line correctly X-Git-Tag: RELEASE_1_2_0~81 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4c6626957336703853cae61004d57dd08eb2040f;p=php - Impprove cli_wordwrap() make it respectstart of initial line correctly --- diff --git a/ext/phar/phar/clicommand.inc b/ext/phar/phar/clicommand.inc index 3397855044..d65016afde 100755 --- a/ext/phar/phar/clicommand.inc +++ b/ext/phar/phar/clicommand.inc @@ -242,9 +242,11 @@ abstract class CLICommand private function cli_wordwrap($what, $l, $sp) { - $l = max(80 - $l, 40); // minimum length - $what = str_replace("\n", "\n".$sp, $what); - return wordwrap($what, $l, "\n".$sp); + $p = max(79 - $l, 40); // minimum length for paragraph + $b = substr($what, 0, $l); // strip out initial $l + $r = substr($what, $l); // remainder + $r = str_replace("\n", "\n".$sp, $r); // in remainder replace \n's + return $b . wordwrap($r, $p, "\n".$sp); } private function cli_help_get_args($func, $l, $sp, $required)