Tweak the basicio parser so that it properly handles multi-value
lines with hashes (lines like symbol [hash] [hash] are still not handled, but aren't outputted from any command either as of now).
This commit is contained in:
parent
0c575ccc74
commit
90edbf0d8b
@ -68,17 +68,30 @@ class IDF_Scm_Monotone_BasicIO
|
||||
{
|
||||
unset($stanzaLine['hash']);
|
||||
$valCount = 0;
|
||||
while ($in[$pos] == '"') {
|
||||
++$pos; // opening quote
|
||||
// if hashs and plain values are encountered in the same
|
||||
// value list, we add the hash values as simple values as well
|
||||
while ($in[$pos] == '"' || $in[$pos] == '[') {
|
||||
$isHashValue = $in[$pos] == '[';
|
||||
++$pos; // opening quote / bracket
|
||||
$stanzaLine['values'][$valCount] = '';
|
||||
while ($pos < $length) {
|
||||
$ch = $in[$pos]; $pr = $in[$pos-1];
|
||||
if ($ch == '"' && $pr != '\\') break;
|
||||
if (($isHashValue && $ch == ']')
|
||||
||(!$isHashValue && $ch == '"' && $pr != '\\'))
|
||||
break;
|
||||
++$pos;
|
||||
$stanzaLine['values'][$valCount] .= $ch;
|
||||
}
|
||||
++$pos; // closing quote
|
||||
|
||||
if (!$isHashValue) {
|
||||
$stanzaLine['values'][$valCount] = str_replace(
|
||||
array("\\\\", "\\\""),
|
||||
array("\\", "\""),
|
||||
$stanzaLine['values'][$valCount]
|
||||
);
|
||||
}
|
||||
|
||||
if ($pos >= $length)
|
||||
break;
|
||||
|
||||
@ -87,14 +100,6 @@ class IDF_Scm_Monotone_BasicIO
|
||||
++$valCount;
|
||||
}
|
||||
}
|
||||
|
||||
for ($i = 0; $i <= $valCount; $i++) {
|
||||
$stanzaLine['values'][$i] = str_replace(
|
||||
array("\\\\", "\\\""),
|
||||
array("\\", "\""),
|
||||
$stanzaLine['values'][$i]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$stanza[] = $stanzaLine;
|
||||
|
Loading…
Reference in New Issue
Block a user