From 22e017432a130728b5b0f535aa490bfaaadacc73 Mon Sep 17 00:00:00 2001 From: Diego Nieto Cid Date: Tue, 20 Jul 2010 14:09:19 -0300 Subject: Propagate error on unexpected end of files. * console-client/xkb/lex.l (close_include): Return an error code on failure. (yywrap): Indicate termination when close_include fails. --- console-client/xkb/lex.l | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'console-client/xkb') diff --git a/console-client/xkb/lex.l b/console-client/xkb/lex.l index ffd14387..379ce692 100644 --- a/console-client/xkb/lex.l +++ b/console-client/xkb/lex.l @@ -23,7 +23,7 @@ #include #include - void close_include (void); + int close_include (void); int lineno = 1; char *filename = "foo"; @@ -299,8 +299,10 @@ overlay2 { yylval.val = 2; return OVERLAY; } int yywrap (void) { - close_include (); - return 0; + if (close_include () == 0) + return 0; + else + return 1; } #define MAX_INCLUDE_DEPTH 50 @@ -339,15 +341,14 @@ overlay2 { yylval.val = 2; return OVERLAY; } yy_switch_to_buffer (buffer); } - /* Close an includefile. */ - void + /* Close an includefile. returns 0 on success */ + int close_include (void) { if ( --include_stack_ptr < 0 ) { - // yyterminate (); fprintf (stderr, "Unexpected end of file at %s:%d.\n", filename, lineno); - exit (1); + return (1); } else { @@ -357,6 +358,7 @@ overlay2 { yylval.val = 2; return OVERLAY; } lineno = include_stack[include_stack_ptr].currline; filename = include_stack[include_stack_ptr].filename; yy_switch_to_buffer (include_stack[include_stack_ptr].buffer); + return (0); } } -- cgit v1.2.3