From 0660409987af500701e8ae0dd9cff7645d7f2f1a Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Pueyo Date: Thu, 14 Mar 2013 21:55:50 +0100 Subject: [PATCH] Updated Spyc --- src/utils/Spyc.php | 64 ++++++---------------------------------------- 1 file changed, 8 insertions(+), 56 deletions(-) diff --git a/src/utils/Spyc.php b/src/utils/Spyc.php index c24fab29..5f9d4a57 100644 --- a/src/utils/Spyc.php +++ b/src/utils/Spyc.php @@ -1,32 +1,7 @@ * @author Chris Wanstrath * @link http://code.google.com/p/spyc/ @@ -35,28 +10,6 @@ THE SOFTWARE. * @package Spyc */ -if (!function_exists('spyc_load')) { - /** - * Parses YAML to array. - * @param string $string YAML string. - * @return array - */ - function spyc_load ($string) { - return Spyc::YAMLLoadString($string); - } -} - -if (!function_exists('spyc_load_file')) { - /** - * Parses YAML to array. - * @param string $file Path to YAML file. - * @return array - */ - function spyc_load_file ($file) { - return Spyc::YAMLLoad($file); - } -} - /** * The Simple PHP YAML Class. * @@ -458,18 +411,16 @@ class Spyc { $i--; } + // Strip out comments + if (strpos ($line, '#')) { + $line = preg_replace('/\s*#([^"\']+)$/','',$line); + } + while (++$i < $cnt && self::greedilyNeedNextLine($line)) { $line = rtrim ($line, " \n\t\r") . ' ' . ltrim ($Source[$i], " \t"); } $i--; - - - if (strpos ($line, '#')) { - if (strpos ($line, '"') === false && strpos ($line, "'") === false) - $line = preg_replace('/\s+#(.+)$/','',$line); - } - $lineArray = $this->_parseLine($line); if ($literalBlockStyle) @@ -678,7 +629,8 @@ class Spyc { } while (strpos ($inline, '[') !== false || strpos ($inline, '{') !== false); - $explode = explode(', ',$inline); + $explode = explode(',',$inline); + $explode = array_map('trim', $explode); $stringi = 0; $i = 0; while (1) {