From f8e23519bcbd2d73f59cb151aff579389767ad45 Mon Sep 17 00:00:00 2001 From: x2000habouzit Date: Sat, 1 Jan 2005 16:29:59 +0000 Subject: [PATCH] improve wrapper again --- include/wrapper.inc.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/include/wrapper.inc.php b/include/wrapper.inc.php index 2a867df..7f657d9 100644 --- a/include/wrapper.inc.php +++ b/include/wrapper.inc.php @@ -13,17 +13,14 @@ function wrap($_text,$_prefix="",$_length=72) { $sign = "\n-- \n" . array_pop($parts); $text = join("\n-- \n", $parts); } else { - $text = $_text; $sign = ''; + $text = $_text; } - if ($_prefix != "") { - $lines = split("\n",$_text); - $text = $_prefix.join("\n$_prefix",$lines); - } - $exec="echo ".escapeshellarg($text)." | perl -MText::Autoformat -e 'autoformat {left=>1, right=>$_length, all=>1 };'"; - exec($exec,$result); + + $cmd = "echo ".escapeshellarg($text)." | perl -MText::Autoformat -e 'autoformat {left=>1, right=>$_length, all=>1 };'"; + exec($cmd, $result); - return join("\n",$result).$sign; + return $_prefix.join("\n$_prefix", $result).($_prefix ? '' : $sign); } ?> -- 2.1.4