diff options
author | Maria Matejka <mq@ucw.cz> | 2019-07-15 15:43:47 +0200 |
---|---|---|
committer | Maria Matejka <mq@ucw.cz> | 2019-07-15 15:46:36 +0200 |
commit | efd7c87b5bcd476ba74ffe9f369e2f6fe978cbb1 (patch) | |
tree | cfcc5d2b8d04ca9cbab6e1e2ad07918acb488296 | |
parent | 3782454e8dead1184e698fa84f7491182b54454e (diff) |
Filter: further split of print & die to FI_PRINT, FI_FLUSH and FI_DIE
-rw-r--r-- | filter/config.Y | 28 | ||||
-rw-r--r-- | filter/f-inst.c | 17 |
2 files changed, 23 insertions, 22 deletions
diff --git a/filter/config.Y b/filter/config.Y index 9a240763..83319194 100644 --- a/filter/config.Y +++ b/filter/config.Y @@ -966,8 +966,6 @@ break_command: | ACCEPT { $$ = F_ACCEPT; } | REJECT { $$ = F_REJECT; } | ERROR { $$ = F_ERROR; } - | PRINT { $$ = F_NOP; } - | PRINTN { $$ = F_NONL; } ; print_list: /* EMPTY */ { $$ = NULL; } @@ -1018,21 +1016,23 @@ cmd: $$ = f_new_inst(FI_EA_UNSET, $3); } | break_command print_list ';' { - struct f_inst *breaker = NULL; - struct f_inst *printer = NULL; - if ($2) - printer = f_new_inst(FI_PRINT, $2); - if ($1 != F_NONL) - breaker = f_new_inst(FI_DIE, $1); - - if (printer && breaker) - printer->next = breaker; - - if (printer) + struct f_inst *breaker = f_new_inst(FI_DIE, $1); + if ($2) { + struct f_inst *printer = f_new_inst(FI_PRINT, $2); + struct f_inst *flusher = f_new_inst(FI_FLUSH); + printer->next = flusher; + flusher->next = breaker; $$ = printer; - else + } else $$ = breaker; } + | PRINT print_list ';' { + $$ = f_new_inst(FI_PRINT, $2); + $$->next = f_new_inst(FI_FLUSH); + } + | PRINTN print_list ';' { + $$ = f_new_inst(FI_PRINT, $2); + } | function_call ';' { $$ = f_new_inst(FI_DROP_RESULT, $1); } | CASE term '{' switch_body '}' { $$ = f_new_inst(FI_SWITCH, $2, build_tree($4)); diff --git a/filter/f-inst.c b/filter/f-inst.c index 997bc6ac..0867ac4a 100644 --- a/filter/f-inst.c +++ b/filter/f-inst.c @@ -455,23 +455,24 @@ val_format(&(vv(i)), &fs->buf); } + INST(FI_FLUSH, 0, 0) { + NEVER_CONSTANT; + if (!(fs->flags & FF_SILENT)) + /* After log_commit, the buffer is reset */ + log_commit(*L_INFO, &fs->buf); + } + INST(FI_DIE, 0, 0) { NEVER_CONSTANT; FID_MEMBER(enum filter_return, fret, f1->fret != f2->fret, "%s", filter_return_str(item->fret)); - if (fs->buf.start < fs->buf.pos) - log_commit(*L_INFO, &fs->buf); - switch (whati->fret) { case F_QUITBIRD: die( "Filter asked me to die" ); - case F_ACCEPT: - /* Should take care about turning ACCEPT into MODIFY */ + case F_ACCEPT: /* Should take care about turning ACCEPT into MODIFY */ case F_ERROR: - case F_REJECT: /* FIXME (noncritical) Should print complete route along with reason to reject route */ + case F_REJECT: /* Maybe print complete route along with reason to reject route? */ return fret; /* We have to return now, no more processing. */ - case F_NOP: - break; default: bug( "unknown return type: Can't happen"); } |