Jeremy Newman : update for PHP7 compat
Jeremy Newman
jnewman at winehq.org
Thu Jun 29 10:56:41 CDT 2017
Module: website
Branch: master
Commit: 7e0d01533f584b6df4381ea3ed5c461dc4207d28
URL: http://source.winehq.org/git/website.git/?a=commit;h=7e0d01533f584b6df4381ea3ed5c461dc4207d28
Author: Jeremy Newman <jnewman at codeweavers.com>
Date: Thu Jun 29 10:56:12 2017 -0500
update for PHP7 compat
---
include/config.php | 33 +++++++++++++++++++--------------
1 file changed, 19 insertions(+), 14 deletions(-)
diff --git a/include/config.php b/include/config.php
index 80f3311..c3fbed8 100644
--- a/include/config.php
+++ b/include/config.php
@@ -13,7 +13,6 @@ class config
{
// get files passed
$files = func_get_args();
-
// loop and parse files
foreach ($files as $path)
{
@@ -28,47 +27,52 @@ class config
if (file_exists($file))
{
$fd = fopen ($file, "r");
- while (!feof ($fd)) {
+ while (!feof ($fd))
+ {
$buffer = trim(fgets($fd, 4096));
- if (preg_match('/^\#/', $buffer)) continue;
- if ($buffer == "") continue;
+ if (empty($buffer))
+ continue;
+ if (preg_match('/^\#/', $buffer))
+ continue;
$arr = preg_split('/:\s+/',$buffer,2);
- $arr[1] = preg_replace("/<br>/","\n",$arr[1]);
+ if (empty($arr) or empty($arr[0]))
+ continue;
+ $arr[0] = preg_replace('/:/','',$arr[0]);
if (preg_match('/^\@/', $arr[0]))
{
// array
$arr[0] = preg_replace('/\@/', '', $arr[0]);
- $this->$arr[0] = preg_split('/,\s+/', $arr[1]);
+ $this->{$arr[0]} = preg_split('/,\s+/', $arr[1]);
}
else if (preg_match('/^\%/', $arr[0]))
{
// assoc array
$arr[0] = preg_replace('/\%/', '', $arr[0]);
- $this->$arr[0] = array();
+ $this->{$arr[0]} = array();
$params = preg_split('/,\s+/', $arr[1]);
while (list($n, $m) = each($params))
{
list($key, $val) = preg_split('/\|/', $m, 2);
- $this->$arr[0] = array_merge($this->$arr[0], array($key => $val));
+ $this->{$arr[0]} = array_merge($this->{$arr[0]}, array($key => $val));
}
}
else
{
// string
- if (preg_match('/\{\$[a-z0-9_]+\}/', $arr[1]))
+ if (!empty($arr[1]) and preg_match('/\{\$[a-z0-9_]+\}/', $arr[1]))
{
// load other vars into existing var
$arr[1] = preg_replace('/(.*)\{\$([a-z0-9_]+)\}(.*)/', "\\1,\\2,\\3", $arr[1]);
list($a,$b,$c) = preg_split("/\,/", $arr[1], 3);
- if ($b and isset($this->$b))
- $arr[1] = $a.$this->$b.$c;
+ if ($b and isset($this->{$b}))
+ $arr[1] = $a.$this->{$b}.$c;
else
$arr[1] = $a.$c;
}
- $this->$arr[0] = $arr[1];
+ $this->{$arr[0]} = (!empty($arr[1]) ? $arr[1] : '');
}
}
- fclose ($fd);
+ fclose($fd);
}
else
{
@@ -78,6 +82,7 @@ class config
// end of readConfig
}
-// done
+// end of class config
}
+
?>
More information about the wine-cvs
mailing list