If a symbol is printed without a value list at the very end of a

basic_io dump, we might access a non-existing character position.
This has been fixed and the string length calculation is now only
done once.
master
Thomas Keller 2010-10-03 22:23:08 +00:00
parent eebdc5ad12
commit 0c575ccc74
1 changed files with 9 additions and 5 deletions

View File

@ -38,14 +38,15 @@ class IDF_Scm_Monotone_BasicIO
{
$pos = 0;
$stanzas = array();
$length = strlen($in);
while ($pos < strlen($in)) {
while ($pos < $length) {
$stanza = array();
while ($pos < strlen($in)) {
while ($pos < $length) {
if ($in[$pos] == "\n") break;
$stanzaLine = array('key' => '', 'values' => array(), 'hash' => null);
while ($pos < strlen($in)) {
while ($pos < $length) {
$ch = $in[$pos];
if ($ch == '"' || $ch == '[') break;
++$pos;
@ -53,6 +54,9 @@ class IDF_Scm_Monotone_BasicIO
$stanzaLine['key'] .= $ch;
}
// symbol w/o a value list
if ($pos >= $length || $in[$pos] == "\n") break;
if ($in[$pos] == '[') {
unset($stanzaLine['values']);
++$pos; // opening square bracket
@ -67,7 +71,7 @@ class IDF_Scm_Monotone_BasicIO
while ($in[$pos] == '"') {
++$pos; // opening quote
$stanzaLine['values'][$valCount] = '';
while ($pos < strlen($in)) {
while ($pos < $length) {
$ch = $in[$pos]; $pr = $in[$pos-1];
if ($ch == '"' && $pr != '\\') break;
++$pos;
@ -75,7 +79,7 @@ class IDF_Scm_Monotone_BasicIO
}
++$pos; // closing quote
if ($pos >= strlen($in))
if ($pos >= $length)
break;
if ($in[$pos] == ' ') {