Skip to content
Snippets Groups Projects
Commit edcb01e5 authored by Gina Haeussge's avatar Gina Haeussge
Browse files

Split confToHash into confToHash and linesToHash

New function linesToHash (which now is used by existing function
confToHash) allows for parsing of given strings into a config
hash.

darcs-hash:20090228130423-2b4f5-e4f08c80350d83d3d93a4652aa8db1aae96e3a13.gz
parent aa5a2937
No related branches found
No related tags found
No related merge requests found
......@@ -123,19 +123,16 @@ function getSchemes() {
}
/**
* Builds a hash from a configfile
* Builds a hash from an array of lines
*
* If $lower is set to true all hash keys are converted to
* lower case.
*
* @author Harry Fuecks <hfuecks@gmail.com>
* @author Andreas Gohr <andi@splitbrain.org>
* @author Gina Haeussge <gina@foosel.net>
*/
function confToHash($file,$lower=false) {
$conf = array();
$lines = @file( $file );
if ( !$lines ) return $conf;
function linesToHash($lines, $lower=false) {
foreach ( $lines as $line ) {
//ignore comments (except escaped ones)
$line = preg_replace('/(?<![&\\\\])#.*$/','',$line);
......@@ -154,6 +151,24 @@ function confToHash($file,$lower=false) {
return $conf;
}
/**
* Builds a hash from a configfile
*
* If $lower is set to true all hash keys are converted to
* lower case.
*
* @author Harry Fuecks <hfuecks@gmail.com>
* @author Andreas Gohr <andi@splitbrain.org>
* @author Gina Haeussge <gina@foosel.net>
*/
function confToHash($file,$lower=false) {
$conf = array();
$lines = @file( $file );
if ( !$lines ) return $conf;
return linesToHash($lines, $lower);
}
/**
* Retrieve the requested configuration information
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment