]> granicus.if.org Git - php/commitdiff
- Impprove cli_wordwrap() make it respectstart of initial line correctly
authorMarcus Boerger <helly@php.net>
Sat, 12 May 2007 11:53:27 +0000 (11:53 +0000)
committerMarcus Boerger <helly@php.net>
Sat, 12 May 2007 11:53:27 +0000 (11:53 +0000)
ext/phar/phar/clicommand.inc

index 3397855044f8f0ef2e3903d7fb8f7c9271b43f42..d65016afdee5a38a293e067e80d6bd1f3601ca11 100755 (executable)
@@ -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)