From 44da93da28bf04579af5d883cb6ab82a0c8aaef2 Mon Sep 17 00:00:00 2001 From: mohrt Date: Mon, 23 Sep 2002 20:14:46 +0000 Subject: [PATCH] add support for mac/dos formatted config files (fix newlines) --- Config_File.class.php | 13 +++++++++++++ libs/Config_File.class.php | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/Config_File.class.php b/Config_File.class.php index bfe0e778..6dcf5e1c 100644 --- a/Config_File.class.php +++ b/Config_File.class.php @@ -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(); diff --git a/libs/Config_File.class.php b/libs/Config_File.class.php index bfe0e778..6dcf5e1c 100644 --- a/libs/Config_File.class.php +++ b/libs/Config_File.class.php @@ -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();