cvs: php4 /pear/PEAR Common.php
| From: | Stig Bakken | Date: | Sun, 26 May 2002 23:38:22 +0000 |
| Subject: | cvs: php4 /pear/PEAR Common.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-4118@lists.php.net to get a copy of this message | ||
ssb Sun May 26 19:38:22 2002 EDT
Modified files:
/php4/pear/PEAR Common.php
Log:
* un-indent description too
Index: php4/pear/PEAR/Common.php
diff -u php4/pear/PEAR/Common.php:1.64 php4/pear/PEAR/Common.php:1.65
--- php4/pear/PEAR/Common.php:1.64 Sun May 26 19:33:01 2002
+++ php4/pear/PEAR/Common.php Sun May 26 19:38:22 2002
@@ -17,7 +17,7 @@
// | Tomas V.V.Cox <cox@idecnet.com> |
// +----------------------------------------------------------------------+
//
-// $Id: Common.php,v 1.64 2002/05/26 23:33:01 ssb Exp $
+// $Id: Common.php,v 1.65 2002/05/26 23:38:22 ssb Exp $
require_once 'PEAR.php';
require_once 'Archive/Tar.php';
@@ -254,6 +254,26 @@
// }}}
+ // {{{ _unIndent()
+
+ function _unIndent($str)
+ {
+ // remove leading newlines
+ $str = preg_replace('/^[\r\n]+/', '', $str);
+ // find whitespace at the beginning of the first line
+ $indent_len = strspn($str, " \t");
+ $indent = substr($str, 0, $indent_len);
+ $data = '';
+ // remove the same amount of whitespace from following lines
+ foreach (explode("\n", $str) as $line) {
+ if (substr($line, 0, $indent_len) == $indent) {
+ $data .= substr($line, $indent_len) . "\n";
+ }
+ }
+ return $data;
+ }
+
+ // }}}
// {{{ _element_start()
/**
@@ -461,6 +481,7 @@
$this->pkginfo['summary'] = $data;
break;
case 'description':
+ $data = $this->_unIndent($this->cdata);
$this->pkginfo['description'] = $data;
break;
case 'user':
@@ -490,17 +511,7 @@
case 'notes':
// try to "de-indent" release notes in case someone
// has been over-indenting their xml ;-)
- $data = preg_replace('/^[\r\n]+/', '', $this->cdata);
- $indent_len = strspn($data, " \t");
- $indent = substr($data, 0, $indent_len);
- $newdata = '';
- foreach (explode("\n", $data) as $line) {
- print "indent_len=$indent_len\n";
- if (substr($line, 0, $indent_len) == $indent) {
- $newdata .= substr($line, $indent_len) . "\n";
- }
- }
- $data = $newdata;
+ $data = $this->_unIndent($this->cdata);
if ($this->in_changelog) {
$this->current_release['release_notes'] = $data;
} else {