|
|
@ -1,7 +1,7 @@ |
|
|
|
<?php |
|
|
|
<?php |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Spyc -- A Simple PHP YAML Class |
|
|
|
* Spyc -- A Simple PHP YAML Class |
|
|
|
* @version 0.5 |
|
|
|
* @version 0.5.1 |
|
|
|
* @author Vlad Andersen <vlad.andersen@gmail.com> |
|
|
|
* @author Vlad Andersen <vlad.andersen@gmail.com> |
|
|
|
* @author Chris Wanstrath <chris@ozmm.org> |
|
|
|
* @author Chris Wanstrath <chris@ozmm.org> |
|
|
|
* @link http://code.google.com/p/spyc/ |
|
|
|
* @link http://code.google.com/p/spyc/ |
|
|
@ -433,18 +433,16 @@ class Spyc { |
|
|
|
$i--; |
|
|
|
$i--; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Strip out comments |
|
|
|
|
|
|
|
if (strpos ($line, '#')) { |
|
|
|
|
|
|
|
$line = preg_replace('/\s*#([^"\']+)$/','',$line); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
while (++$i < $cnt && self::greedilyNeedNextLine($line)) { |
|
|
|
while (++$i < $cnt && self::greedilyNeedNextLine($line)) { |
|
|
|
$line = rtrim ($line, " \n\t\r") . ' ' . ltrim ($Source[$i], " \t"); |
|
|
|
$line = rtrim ($line, " \n\t\r") . ' ' . ltrim ($Source[$i], " \t"); |
|
|
|
} |
|
|
|
} |
|
|
|
$i--; |
|
|
|
$i--; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (strpos ($line, '#')) { |
|
|
|
|
|
|
|
if (strpos ($line, '"') === false && strpos ($line, "'") === false) |
|
|
|
|
|
|
|
$line = preg_replace('/\s+#(.+)$/','',$line); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$lineArray = $this->_parseLine($line); |
|
|
|
$lineArray = $this->_parseLine($line); |
|
|
|
|
|
|
|
|
|
|
|
if ($literalBlockStyle) |
|
|
|
if ($literalBlockStyle) |
|
|
@ -654,6 +652,7 @@ class Spyc { |
|
|
|
} while (strpos ($inline, '[') !== false || strpos ($inline, '{') !== false); |
|
|
|
} while (strpos ($inline, '[') !== false || strpos ($inline, '{') !== false); |
|
|
|
|
|
|
|
|
|
|
|
$explode = explode(',',$inline); |
|
|
|
$explode = explode(',',$inline); |
|
|
|
|
|
|
|
$explode = array_map('trim', $explode); |
|
|
|
$stringi = 0; $i = 0; |
|
|
|
$stringi = 0; $i = 0; |
|
|
|
|
|
|
|
|
|
|
|
while (1) { |
|
|
|
while (1) { |
|
|
@ -1032,14 +1031,14 @@ class Spyc { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Enable use of Spyc from command line |
|
|
|
// Enable use of Spyc from command line |
|
|
|
// The syntax is the following: php spyc.php spyc.yaml |
|
|
|
// The syntax is the following: php Spyc.php spyc.yaml |
|
|
|
|
|
|
|
|
|
|
|
define ('SPYC_FROM_COMMAND_LINE', false); |
|
|
|
define ('SPYC_FROM_COMMAND_LINE', false); |
|
|
|
|
|
|
|
|
|
|
|
do { |
|
|
|
do { |
|
|
|
if (!SPYC_FROM_COMMAND_LINE) break; |
|
|
|
if (!SPYC_FROM_COMMAND_LINE) break; |
|
|
|
if (empty ($_SERVER['argc']) || $_SERVER['argc'] < 2) break; |
|
|
|
if (empty ($_SERVER['argc']) || $_SERVER['argc'] < 2) break; |
|
|
|
if (empty ($_SERVER['PHP_SELF']) || $_SERVER['PHP_SELF'] != 'spyc.php') break; |
|
|
|
if (empty ($_SERVER['PHP_SELF']) || $_SERVER['PHP_SELF'] != 'Spyc.php') break; |
|
|
|
$file = $argv[1]; |
|
|
|
$file = $argv[1]; |
|
|
|
printf ("Spyc loading file: %s\n", $file); |
|
|
|
printf ("Spyc loading file: %s\n", $file); |
|
|
|
print_r (spyc_load_file ($file)); |
|
|
|
print_r (spyc_load_file ($file)); |