Commit 92a316b6 authored by Ronan's avatar Ronan

fix(Loop::_feed): increase repeat before input[pos]!=0 comparison

parent 42376f65
......@@ -267,12 +267,11 @@ size_t Loop::_feed(const shared_ptr<ParserContextBase> &ctx, const string &input
size_t total=0;
int repeat;
for(repeat=0;mMax!=-1 ? repeat<mMax : true;repeat++){
for(repeat=0;(mMax!=-1 ? repeat<mMax : true) && input[pos]!='\0';repeat++){
matched=mRecognizer->feed(ctx, input, pos);
if (matched==string::npos) break;
if (input[pos]=='\0') break;
if (repeat<mMin) return string::npos;
return total;
......@@ -314,15 +314,21 @@ ABNFGrammarBuilder::ABNFGrammarBuilder()
shared_ptr<Grammar> ABNFGrammarBuilder::createFromAbnf(const string &abnf, const shared_ptr<Grammar> &gram){
size_t parsed;
shared_ptr<ABNFBuilder> builder = mParser.parseInput("rulelist",abnf,&parsed);
if (!builder) {
bctbx_error("[belr] Failed to create builder.");
return nullptr;
if (parsed<(size_t)abnf.size()){
bctbx_error("[belr] Only %llu bytes parsed over a total of %llu.", (unsigned long long)parsed, (unsigned long long) abnf.size());
return nullptr;
shared_ptr<Grammar> retGram;
if (gram==nullptr) retGram=make_shared<Grammar>(abnf);
else retGram=gram;
bctbx_message("[belr] Succesfully created grammar with %i rules.", retGram->getNumRules());
if (retGram->isComplete()){
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment