}
}
assert(*p); assert(!*++p);
+ *q++= 0;
return tokv_quotedstring;
}
r= pa_mnl(); if (r) return r;
r= parse_string(RESET_CONFIGURATION,"<builtin reset configuration>",1);
- assert(!r);
- return 0;
+ return r;
}
int dfg_fdwant(int dtoken) {
}
int parse_string(const char *string, const char *descrip, int isinternal) {
- /* Returns the same things as parser, except that tokv_eof
- * is turned into 0.
+ /* Returns the same things as parser, except that tokv_eof is turned
+ * into 0. *string must be statically allocated or copied, so that
+ * it is not overwritten while the parsing takes place (unlike with
+ * parse_file).
*/
static const struct stat blankstab;
}
static int parse_file(const char *string, int *didexist) {
- /* Returns the same things as parser, except that tokv_eof
- * is turned into 0. If *didexist is 0 then errno will
- * have been set.
+ /* Returns the same things as parser, except that tokv_eof is turned
+ * into 0. If *didexist is 0 then errno will have been set.
+ * *string will be copied by parse_file so it may be be overwritten
+ * during the parsing (so, for example, yytext need not be copied).
*/
static int fileparselevel= 0;
YY_BUFFER_STATE ybuf;
int r;
FILE *file;
+ char *filename;
struct stat newstab;
if (fileparselevel >= MAX_INCLUDE_NEST) {
ybuf= yy_create_buffer(file,YY_BUF_SIZE);
if (!ybuf) syscallerror("unable to create flex buffer for file");
- parser_push(&usestate,string,&newstab,ybuf,0);
+ filename= xstrsave(string);
+ parser_push(&usestate,filename,&newstab,ybuf,0);
fileparselevel++;
r= parser(0);
parseerrprint("error reading configuration file `%s'",string);
r= tokv_error;
}
-
+
fileparselevel--;
parser_pop();
+ free(filename);
fclose(file);
if (r == tokv_eof) r= 0;
return r;