1
1

Similar to the commits earlier today about multiple input files for

MCA param files, ensure that we reset the flex buffer properly when we
start parsing a 2nd (or 3rd or 4th or ...) file.

This commit was SVN r3176.
Этот коммит содержится в:
Jeff Squyres 2004-10-15 21:38:42 +00:00
родитель ea6f7be7ba
Коммит f82aa9802f
3 изменённых файлов: 25 добавлений и 1 удалений

Просмотреть файл

@ -137,6 +137,10 @@ static int open_file(const char *base, const char *topic)
return OMPI_ERR_NOT_FOUND;
}
/* Set the buffer */
ompi_show_help_init_buffer(ompi_show_help_yyin);
/* Happiness */
return OMPI_SUCCESS;

Просмотреть файл

@ -19,7 +19,8 @@
#include <stdio.h>
extern int ompi_show_help_yylex(void);
int ompi_show_help_yylex(void);
int ompi_show_help_init_buffer(FILE *file);
extern FILE *ompi_show_help_yyin;
extern bool ompi_show_help_parse_done;

Просмотреть файл

@ -65,8 +65,27 @@ int ompi_show_help_finish_parsing(void)
return YY_NULL;
}
static int ompi_show_help_yywrap(void)
{
ompi_show_help_parse_done = true;
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 ompi_show_help_init_buffer(FILE *file)
{
YY_BUFFER_STATE buf = yy_create_buffer(file, YY_BUF_SIZE);
yy_switch_to_buffer(buf);
return 0;
}