X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=conffile.fl;h=27e725d078bb45b60e1404a97fe7e173f46d81aa;hb=ca58ee4883fc5eb309f950787d35af5deca05321;hp=2142ff3cdb2cf4c804022482e3e3390f146cc32d;hpb=974d0468ad285d9ddbc5b052110076d7adf0ed2e;p=secnet.git diff --git a/conffile.fl b/conffile.fl index 2142ff3..27e725d 100644 --- a/conffile.fl +++ b/conffile.fl @@ -10,17 +10,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 +92,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();