Req #16656 [Opn]: New 'linebreak' option for IniCommented container

From: Date: Tue, 29 Sep 2009 10:09:36 +0000
Subject: Req #16656 [Opn]: New 'linebreak' option for IniCommented container
References: 1  Groups: php.pear.bugs 
Request: Send a blank email to pear-bugs+get-1761@lists.php.net to get a copy of this message
Edit report at http://pear.php.net/bugs/bug.php?id=16656&edit=1 ID: 16656 Updated by: wiesemann@php.net Reported By: wiesemann at php dot net Summary: New 'linebreak' option for IniCommented container Status: Open Type: Feature/Change Request Package: Config Package Version: 1.10.11 PHP Version: Irrelevant Roadmap Versions: New Comment: Patch upload is currently broken ... Index: . =================================================================== --- . (revision 288931) +++ . (working copy) @@ -26,12 +26,12 @@ class Config_Container_IniCommented { /** - * This class options - * Not used at the moment + * Class options + * linebreak: char used for linebreak * * @var array */ - var $options = array(); + var $options = array('linebreak' => "\n"); /** * Constructor @@ -59,6 +59,9 @@ return PEAR::raiseError("Datasource file does not exist.", null, PEAR_ERROR_RETURN); } $lines = file($datasrc); + if ($lines === false) { + return PEAR::raiseError('File could not be read', null, PEAR_ERROR_RETURN); + } $n = 0; $lastline = ''; $currentSection =& $obj->container; @@ -268,10 +271,10 @@ } switch ($obj->type) { case 'blank': - $string = "\n"; + $string = $this->options['linebreak']; break; case 'comment': - $string = ';'.$obj->content."\n"; + $string = ';'.$obj->content . $this->options['linebreak']; break; case 'directive': $count = $obj->parent->countChildren('directive', $obj->name); @@ -305,19 +308,19 @@ } if ($childrenCount[$obj->name] == $count-1) { // Clean the static for future calls to toString - $string .= $commaString[$obj->name].$content."\n"; + $string .= $commaString[$obj->name] . $content . $this->options['linebreak']; unset($childrenCount[$obj->name]); unset($commaString[$obj->name]); } else { $commaString[$obj->name] .= $content.', '; } } else { - $string = $obj->name.' = '.$content."\n"; + $string = $obj->name . ' = ' . $content . $this->options['linebreak']; } break; case 'section': if (!$obj->isRoot()) { - $string = '['.$obj->name."]\n"; + $string = '[' . $obj->name . "]" . $this->options['linebreak']; } if (count($obj->children) > 0) { for ($i = 0; $i < count($obj->children); $i++) { Previous Comments: ------------------------------------------------------------------------ [2009-09-29 10:42:11] wiesemann Description: ------------ The attached patch adds a new 'linebreak' option (default value: "\n") to the IniCommented container. The patch also adds error handling for a failure of the file() call. ------------------------------------------------------------------------ -- Edit this bug report at http://pear.php.net/bugs/bug.php?id=16656&edit=1

« previous php.pear.bugs (#1761) next »