From: Mikko Rasa Date: Thu, 19 Dec 2013 21:58:53 +0000 (+0200) Subject: Fix logic problems when ignoring a statement in the middle of direct load X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=e063c8e0aa04f0b09962be8b6c586c1d021a929f;p=libs%2Fdatafile.git Fix logic problems when ignoring a statement in the middle of direct load Each recursive call to parse() was subtracting one from sub_remaining, causing it to get out of sync with the actual statement hierarchy. --- diff --git a/source/binaryparser.cpp b/source/binaryparser.cpp index 051133f..e2ced82 100644 --- a/source/binaryparser.cpp +++ b/source/binaryparser.cpp @@ -48,7 +48,10 @@ Statement BinaryParser::parse() { const StatementKey *key; if(cur_info) + { key = &cur_info->key; + cur_info = 0; + } else { int id = parse_int(); @@ -84,15 +87,16 @@ Statement BinaryParser::parse() } } - if(!sub_remaining.empty()) - --sub_remaining.back(); + unsigned upper_nsub = (sub_remaining.empty() ? 0 : sub_remaining.back()); unsigned nsub = parse_int(); for(unsigned j = 0; j0) + sub_remaining.back() = upper_nsub-1; + result.valid = true; - cur_info = 0; return result; }