mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
gen-zam: gen-zam extended to read from multiple files on the command-line
This commit is contained in:
parent
aee70af743
commit
4ae4548ceb
1 changed files with 20 additions and 13 deletions
|
@ -1959,16 +1959,19 @@ void TemplateInput::Gripe(const char* msg, const InputLoc& l) const
|
|||
|
||||
ZAMGen::ZAMGen(int argc, char** argv)
|
||||
{
|
||||
auto prog_name = argv[0];
|
||||
auto prog_name = (argv++)[0];
|
||||
|
||||
if ( argc != 2 )
|
||||
if ( --argc < 1 )
|
||||
{
|
||||
fprintf(stderr, "usage: %s <ZAM-templates-file>\n", prog_name);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
auto file_name = argv[1];
|
||||
auto f = strcmp(file_name, "-") ? fopen(file_name, "r") : stdin;
|
||||
while ( argc-- > 0 )
|
||||
{
|
||||
auto file_name = (argv++)[0];
|
||||
bool is_stdin = file_name == std::string("-");
|
||||
auto f = is_stdin ? stdin : fopen(file_name, "r");
|
||||
|
||||
if ( ! f )
|
||||
{
|
||||
|
@ -1978,11 +1981,15 @@ ZAMGen::ZAMGen(int argc, char** argv)
|
|||
|
||||
ti = make_unique<TemplateInput>(f, prog_name, file_name);
|
||||
|
||||
InitEmitTargets();
|
||||
|
||||
while ( ParseTemplate() )
|
||||
;
|
||||
|
||||
if ( ! is_stdin )
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
InitEmitTargets();
|
||||
|
||||
for ( auto& t : templates )
|
||||
t->Instantiate();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue