diff options
author | Diego Nieto Cid <dnietoc@gmail.com> | 2010-07-20 14:09:19 -0300 |
---|---|---|
committer | Diego Nieto Cid <dnietoc@gmail.com> | 2011-04-08 14:36:18 -0300 |
commit | 22e017432a130728b5b0f535aa490bfaaadacc73 (patch) | |
tree | 48d94b1ba9e08be6c7068ff69e399c9c092f7be9 /console-client | |
parent | f4b3884514804f7a59cecd87d84420358629fc69 (diff) |
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.
Diffstat (limited to 'console-client')
-rw-r--r-- | console-client/xkb/lex.l | 16 |
1 files changed, 9 insertions, 7 deletions
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 <stdio.h> #include <error.h> - 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); } } |