Fix a problem where internal flex buffers were not getting properly
reset when scanning a second file. This commit was SVN r3158.
Этот коммит содержится в:
родитель
fceb5c122f
Коммит
51b2da657a
@ -31,6 +31,7 @@ int mca_base_parse_paramfile(const char *paramfile)
|
|||||||
}
|
}
|
||||||
|
|
||||||
mca_base_parse_done = false;
|
mca_base_parse_done = false;
|
||||||
|
mca_base_param_init_buffer(mca_base_yyin);
|
||||||
while (!mca_base_parse_done) {
|
while (!mca_base_parse_done) {
|
||||||
val = mca_base_yylex();
|
val = mca_base_yylex();
|
||||||
switch (val) {
|
switch (val) {
|
||||||
|
@ -20,7 +20,8 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
extern int mca_base_yylex(void);
|
int mca_base_yylex(void);
|
||||||
|
int mca_base_param_init_buffer(FILE *file);
|
||||||
|
|
||||||
extern FILE *mca_base_yyin;
|
extern FILE *mca_base_yyin;
|
||||||
extern bool mca_base_parse_done;
|
extern bool mca_base_parse_done;
|
||||||
|
@ -62,8 +62,27 @@ static int finish_parsing(void)
|
|||||||
return YY_NULL;
|
return YY_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int mca_base_yywrap(void)
|
static int mca_base_yywrap(void)
|
||||||
{
|
{
|
||||||
mca_base_parse_done = true;
|
mca_base_parse_done = true;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Ensure that we have a valid yybuffer to use. Specifically, if this
|
||||||
|
* scanner is invoked a second time, finish_parsing() (above) will
|
||||||
|
* have been executed, and the current buffer will have been freed.
|
||||||
|
* Flex doesn't recognize this fact because as far as it's concerned,
|
||||||
|
* its internal state was already initialized, so it thinks it should
|
||||||
|
* have a valid buffer. Hence, here we ensure to give it a valid
|
||||||
|
* buffer.
|
||||||
|
*/
|
||||||
|
int mca_base_param_init_buffer(FILE *file)
|
||||||
|
{
|
||||||
|
YY_BUFFER_STATE buf = yy_create_buffer(file, YY_BUF_SIZE);
|
||||||
|
yy_switch_to_buffer(buf);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user