add support for mac/dos formatted config files (fix newlines)

This commit is contained in:
mohrt
2002-09-23 20:14:46 +00:00
parent f3f83938ec
commit 44da93da28
2 changed files with 26 additions and 0 deletions

View File

@@ -60,6 +60,14 @@ class Config_File {
*/
var $read_hidden = true;
/**
* Controls whether or not to fix mac or dos formatted newlines.
* If set to true, \r or \r\n will be changed to \n.
*
* @access public
*/
var $fix_newlines = true;
/* Private variables */
var $_config_path = "";
var $_config_data = array();
@@ -253,6 +261,11 @@ class Config_File {
$contents = fread($fp, filesize($config_file));
fclose($fp);
if($this->fix_newlines) {
// fix mac/dos formatted newlines
$contents = preg_replace('!\r\n?!',"\n",$contents);
}
$config_data = array();

View File

@@ -60,6 +60,14 @@ class Config_File {
*/
var $read_hidden = true;
/**
* Controls whether or not to fix mac or dos formatted newlines.
* If set to true, \r or \r\n will be changed to \n.
*
* @access public
*/
var $fix_newlines = true;
/* Private variables */
var $_config_path = "";
var $_config_data = array();
@@ -253,6 +261,11 @@ class Config_File {
$contents = fread($fp, filesize($config_file));
fclose($fp);
if($this->fix_newlines) {
// fix mac/dos formatted newlines
$contents = preg_replace('!\r\n?!',"\n",$contents);
}
$config_data = array();