X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=secnet.git;a=blobdiff_plain;f=conffile.fl;h=c169b572e8a54beae15d7d368f9d5dbc519de78f;hp=2142ff3cdb2cf4c804022482e3e3390f146cc32d;hb=7c006408372213194fce572e390d8f474db9cebc;hpb=974d0468ad285d9ddbc5b052110076d7adf0ed2e diff --git a/conffile.fl b/conffile.fl index 2142ff3..c169b57 100644 --- a/conffile.fl +++ b/conffile.fl @@ -1,6 +1,9 @@ /* the "incl" state is used for picking up the name of an include file */ %x incl +%option nounput +%option noinput + %{ #include #include @@ -10,17 +13,27 @@ #include "conffile.tab.h" #include "util.h" +#define YY_NO_UNPUT + +#define YY_INPUT(buf,result,max_size) \ +do{ \ + (result)= fread((buf),1,(max_size),yyin); \ + if (ferror(yyin)) \ + fatal_perror("Error reading configuration file (%s)", \ + config_file); \ +}while(0) + #define MAX_INCLUDE_DEPTH 10 struct include_stack_item { YY_BUFFER_STATE bst; uint32_t lineno; - string_t file; + cstring_t file; }; struct include_stack_item include_stack[MAX_INCLUDE_DEPTH]; int include_stack_ptr=0; uint32_t config_lineno=0; -string_t config_file="xxx"; +cstring_t config_file="xxx"; static struct p_node *leafnode(uint32_t type) { @@ -82,6 +95,14 @@ include BEGIN(incl); yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE)); BEGIN(INITIAL); } +\n { /* include with no filename */ + Message(M_FATAL,"config file %s line %d: %s\n",config_file, + config_lineno,"``include'' requires a filename"); + BEGIN(INITIAL); + ++config_lineno; + ++yynerrs; +} + <> { if (--include_stack_ptr < 0) { yyterminate();