From 424c584d20c7e2ab0e2ca4aca3ed7dfc1adabc05 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Tue, 13 Apr 2004 18:49:25 +0000 Subject: [PATCH] Abort parser after 20 lines with errors (instead of trying to parse everything, even huge binary files :-) --- Parser/OpenFile.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Parser/OpenFile.cpp b/Parser/OpenFile.cpp index 7dae62d94c..1e2f568fb1 100644 --- a/Parser/OpenFile.cpp +++ b/Parser/OpenFile.cpp @@ -1,4 +1,4 @@ -// $Id: OpenFile.cpp,v 1.51 2004-03-30 18:17:11 geuzaine Exp $ +// $Id: OpenFile.cpp,v 1.52 2004-04-13 18:49:25 geuzaine Exp $ // // Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle // @@ -110,8 +110,16 @@ int ParseFile(char *f, int silent, int close) fgets(tmp, sizeof(tmp), yyin); fsetpos(yyin, &position); - while(!feof(yyin)) + int errorcount = 0; + while(!feof(yyin)){ yyparse(); + if(yyerrorstate) + errorcount++; + if(errorcount > 20){ + Msg(GERROR, "Too many errors: aborting..."); + break; + } + } if(THEM) status = THEM->status; else -- GitLab