X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=conffile.fl;h=27e725d078bb45b60e1404a97fe7e173f46d81aa;hb=ca58ee4883fc5eb309f950787d35af5deca05321;hp=c1b4b042d06cf7c3dcbc430a7a1c7fde4441b2a2;hpb=558fa3fbbb2e6fd1bed6dec54ef603ceb6c943ad;p=secnet.git diff --git a/conffile.fl b/conffile.fl index c1b4b04..27e725d 100644 --- a/conffile.fl +++ b/conffile.fl @@ -12,17 +12,25 @@ #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) { @@ -84,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();