From 23e3b1e6652bac4a003a7eb1e074bdaf7ebb4900 Mon Sep 17 00:00:00 2001 From: Jan Maria Matejka Date: Wed, 22 May 2019 15:16:32 +0000 Subject: [PATCH] Filter: Some people can't pronounce "postfixify" correctly. Let's try "linearize" instead. This is just a naming change. --- conf/confbase.Y | 4 ++-- filter/config.Y | 14 +++++++------- filter/decl.m4 | 30 +++++++++++++++--------------- filter/f-inst.c | 8 ++++---- filter/f-inst.h | 8 ++++---- filter/f-util.c | 2 +- nest/config.Y | 4 ++-- proto/static/config.Y | 2 +- 8 files changed, 36 insertions(+), 36 deletions(-) diff --git a/conf/confbase.Y b/conf/confbase.Y index 9978aec8..bcfd3f1a 100644 --- a/conf/confbase.Y +++ b/conf/confbase.Y @@ -147,14 +147,14 @@ conf: definition ; definition: DEFINE CF_SYM_VOID '=' term ';' { struct f_val *val = cfg_alloc(sizeof(struct f_val)); - if (f_eval(f_postfixify($4), cfg_mem, val) > F_RETURN) cf_error("Runtime error"); + if (f_eval(f_linearize($4), cfg_mem, val) > F_RETURN) cf_error("Runtime error"); cf_define_symbol($2, SYM_CONSTANT | val->type, val, val); } ; expr: NUM - | '(' term ')' { $$ = f_eval_int(f_postfixify($2)); } + | '(' term ')' { $$ = f_eval_int(f_linearize($2)); } | CF_SYM_KNOWN { if ($1->class != (SYM_CONSTANT | T_INT)) cf_error("Number constant expected"); $$ = SYM_VAL($1).i; } diff --git a/filter/config.Y b/filter/config.Y index 5f9b8356..3898748c 100644 --- a/filter/config.Y +++ b/filter/config.Y @@ -481,7 +481,7 @@ filter_def: conf: filter_eval ; filter_eval: - EVAL term { f_eval_int(f_postfixify($2)); } + EVAL term { f_eval_int(f_linearize($2)); } ; conf: custom_attr ; @@ -600,7 +600,7 @@ function_params: function_body: decls '{' cmds '}' { - $$ = f_postfixify($3); + $$ = f_linearize($3); $$->vars = decls_count; } ; @@ -661,7 +661,7 @@ set_atom: | VPN_RD { $$.type = T_RD; $$.val.ec = $1; } | ENUM { $$.type = pair_a($1); $$.val.i = pair_b($1); } | '(' term ')' { - if (f_eval(f_postfixify($2), cfg_mem, &($$)) > F_RETURN) cf_error("Runtime error"); + if (f_eval(f_linearize($2), cfg_mem, &($$)) > F_RETURN) cf_error("Runtime error"); if (!f_valid_set_type($$.type)) cf_error("Set-incompatible type"); } | CF_SYM_KNOWN { @@ -673,13 +673,13 @@ set_atom: switch_atom: NUM { $$.type = T_INT; $$.val.i = $1; } - | '(' term ')' { $$.type = T_INT; $$.val.i = f_eval_int(f_postfixify($2)); } + | '(' term ')' { $$.type = T_INT; $$.val.i = f_eval_int(f_linearize($2)); } | fipa { $$ = $1; } | ENUM { $$.type = pair_a($1); $$.val.i = pair_b($1); } ; cnum: - term { $$ = f_eval_int(f_postfixify($1)); } + term { $$ = f_eval_int(f_linearize($1)); } pair_item: '(' cnum ',' cnum ')' { $$ = f_new_pair_item($2, $2, $4, $4); } @@ -766,7 +766,7 @@ switch_body: /* EMPTY */ { $$ = NULL; } | switch_body switch_items ':' cmds { /* Fill data fields */ struct f_tree *t; - struct f_line *line = f_postfixify($4); + struct f_line *line = f_linearize($4); for (t = $2; t; t = t->left) t->data = line; $$ = f_merge_items($1, $2); @@ -775,7 +775,7 @@ switch_body: /* EMPTY */ { $$ = NULL; } struct f_tree *t = f_new_tree(); t->from.type = t->to.type = T_VOID; t->right = t; - t->data = f_postfixify($3); + t->data = f_linearize($3); $$ = f_merge_items($1, t); } ; diff --git a/filter/decl.m4 b/filter/decl.m4 index c9b5c8c5..d8497535 100644 --- a/filter/decl.m4 +++ b/filter/decl.m4 @@ -12,7 +12,7 @@ m4_divert(-1)m4_dnl # 5 enum fi_code to string # 6 dump line item # 7 dump line item callers -# 8 postfixify +# 8 linearize # 9 same (filter comparator) # 1 union in struct f_inst # 3 constructors @@ -23,7 +23,7 @@ m4_divert(-1)m4_dnl # 102 constructor arguments # 103 constructor body # 104 dump line item content -# 105 postfixify body +# 105 linearize body # 106 comparator body # 107 struct f_line_item content # 108 interpreter body @@ -45,7 +45,7 @@ m4_define(FID_ENUM, `FID_ZONE(4, Code enum)') m4_define(FID_ENUM_STR, `FID_ZONE(5, Code enum to string)') m4_define(FID_DUMP, `FID_ZONE(6, Dump line)') m4_define(FID_DUMP_CALLER, `FID_ZONE(7, Dump line caller)') -m4_define(FID_POSTFIXIFY, `FID_ZONE(8, Postfixify)') +m4_define(FID_LINEARIZE, `FID_ZONE(8, Linearize)') m4_define(FID_SAME, `FID_ZONE(9, Comparison)') m4_define(FID_INTERPRET, `FID_ZONE(10, Interpret)') @@ -53,7 +53,7 @@ m4_define(FID_STRUCT_IN, `m4_divert(101)') m4_define(FID_NEW_ARGS, `m4_divert(102)') m4_define(FID_NEW_BODY, `m4_divert(103)') m4_define(FID_DUMP_BODY, `m4_divert(104)m4_define([[FID_DUMP_BODY_EXISTS]])') -m4_define(FID_POSTFIXIFY_BODY, `m4_divert(105)m4_define([[FID_POSTFIXIFY_BODY_EXISTS]])') +m4_define(FID_LINEARIZE_BODY, `m4_divert(105)m4_define([[FID_LINEARIZE_BODY_EXISTS]])') m4_define(FID_SAME_BODY, `m4_divert(106)') m4_define(FID_LINE_IN, `m4_divert(107)') m4_define(FID_INTERPRET_BODY, `m4_divert(108)') @@ -112,7 +112,7 @@ m4_undivert(104) } FID_ALL_TARGETS -FID_POSTFIXIFY +FID_LINEARIZE case INST_NAME(): { #define what (&(what_->i_]]INST_NAME()[[)) #define item (&(dest->items[pos].i_]]INST_NAME()[[)) @@ -123,7 +123,7 @@ case INST_NAME(): { dest->items[pos].lineno = what_->lineno; break; } -m4_undefine([[FID_POSTFIXIFY_BODY_EXISTS]]) +m4_undefine([[FID_LINEARIZE_BODY_EXISTS]]) FID_SAME case INST_NAME(): @@ -170,7 +170,7 @@ FID_NEW_ARGS FID_NEW_BODY what->$2 = $2; m4_ifelse($3,,,[[ -FID_POSTFIXIFY_BODY +FID_LINEARIZE_BODY item->$3 = what->$2; ]]) m4_ifelse($4,,,[[ @@ -195,8 +195,8 @@ FID_NEW_ARGS FID_NEW_BODY what->f$1 = f$1; for (const struct f_inst *child = f$1; child; child = child->next) what_->size += child->size; -FID_POSTFIXIFY_BODY -pos = postfixify(dest, what->f$1, pos);m4_dnl +FID_LINEARIZE_BODY +pos = linearize(dest, what->f$1, pos);m4_dnl FID_ALL()') m4_define(ARG, `ARG_ANY($1) @@ -226,8 +226,8 @@ FID_NEW_BODY what->f$1 = f$1; FID_DUMP_BODY f_dump_line(item->fl$1, indent + 1); -FID_POSTFIXIFY_BODY -item->fl$1 = f_postfixify(what->f$1); +FID_LINEARIZE_BODY +item->fl$1 = f_linearize(what->f$1); FID_SAME_BODY if (!f_same(f1->fl$1, f2->fl$1)) return 0; FID_INTERPRET_BODY @@ -310,9 +310,9 @@ FID_WR_PUT(7) debug("%sFilter line %p dump done\n", INDENT, dest); } -/* Postfixify */ +/* Linearize */ static uint -postfixify(struct f_line *dest, const struct f_inst *what_, uint pos) +linearize(struct f_line *dest, const struct f_inst *what_, uint pos) { for ( ; what_; what_ = what_->next) { switch (what_->fi_code) { @@ -324,7 +324,7 @@ FID_WR_PUT(8) } struct f_line * -f_postfixify_concat(const struct f_inst * const inst[], uint count) +f_linearize_concat(const struct f_inst * const inst[], uint count) { uint len = 0; for (uint i=0; ilen = postfixify(out, inst[i], out->len); + out->len = linearize(out, inst[i], out->len); #if DEBUGGING f_dump_line(out, 0); diff --git a/filter/f-inst.c b/filter/f-inst.c index 4a4f6016..d0bfa95b 100644 --- a/filter/f-inst.c +++ b/filter/f-inst.c @@ -295,7 +295,7 @@ , const struct f_val val FID_NEW_BODY what->val = val; - FID_POSTFIXIFY_BODY + FID_LINEARIZE_BODY item->val = what->val; FID_SAME_BODY if (!val_same(&(f1->val), &(f2->val))) return 0; @@ -316,7 +316,7 @@ , const struct symbol *sym FID_NEW_BODY what->sym = sym; - FID_POSTFIXIFY_BODY + FID_LINEARIZE_BODY item->valp = (item->sym = what->sym)->val; FID_SAME_BODY if (strcmp(f1->sym->name, f2->sym->name) || !val_same(f1->sym->val, f2->sym->val)) return 0; @@ -339,14 +339,14 @@ LINE(3,1); } INST(FI_PRINT_AND_DIE, 0, 0) { - FID_POSTFIXIFY_BODY + FID_LINEARIZE_BODY { uint opos = pos; FID_ALL ARG_ANY(1); - FID_POSTFIXIFY_BODY + FID_LINEARIZE_BODY if (opos < pos) dest->items[pos].flags |= FIF_PRINTED; } diff --git a/filter/f-inst.h b/filter/f-inst.h index 21cec454..f0dcec64 100644 --- a/filter/f-inst.h +++ b/filter/f-inst.h @@ -17,7 +17,7 @@ * translates into f_new_inst_FI_code(...) and the types are checked in * compile time. * - * 2 Postfixify before interpreting + * 2 Linearize before interpreting * The infix tree is always interpreted in the same order. Therefore we * sort the instructions one after another into struct f_line. Results * and arguments of these instructions are implicitly put on a value @@ -73,9 +73,9 @@ struct f_line { }; /* Convert the f_inst infix tree to the f_line structures */ -struct f_line *f_postfixify_concat(const struct f_inst * const inst[], uint count); -static inline struct f_line *f_postfixify(const struct f_inst *root) -{ return f_postfixify_concat(&root, 1); } +struct f_line *f_linearize_concat(const struct f_inst * const inst[], uint count); +static inline struct f_line *f_linearize(const struct f_inst *root) +{ return f_linearize_concat(&root, 1); } void f_dump_line(const struct f_line *, uint indent); diff --git a/filter/f-util.c b/filter/f-util.c index 79201fba..5500f282 100644 --- a/filter/f-util.c +++ b/filter/f-util.c @@ -58,7 +58,7 @@ struct filter *f_new_where(const struct f_inst *where) }; struct filter *f = cfg_allocz(sizeof(struct filter)); - f->root = f_postfixify(&i); + f->root = f_linearize(&i); return f; } diff --git a/nest/config.Y b/nest/config.Y index fe642489..e4dedc66 100644 --- a/nest/config.Y +++ b/nest/config.Y @@ -112,7 +112,7 @@ rtrid: idval: NUM { $$ = $1; } - | '(' term ')' { $$ = f_eval_int(f_postfixify($2)); } + | '(' term ')' { $$ = f_eval_int(f_linearize($2)); } | IP4 { $$ = ip4_to_u32($1); } | CF_SYM_KNOWN { if ($1->class == (SYM_CONSTANT | T_INT) || $1->class == (SYM_CONSTANT | T_QUAD)) @@ -733,7 +733,7 @@ CF_CLI(DUMP PROTOCOLS,,, [[Dump protocol information]]) { protos_dump_all(); cli_msg(0, ""); } ; CF_CLI(EVAL, term, , [[Evaluate an expression]]) -{ cmd_eval(f_postfixify($2)); } ; +{ cmd_eval(f_linearize($2)); } ; CF_CLI_HELP(ECHO, ..., [[Control echoing of log messages]]) CF_CLI(ECHO, echo_mask echo_size, (all | off | { debug|trace|info|remote|warning|error|auth [, ...] }) [], [[Control echoing of log messages]]) { diff --git a/proto/static/config.Y b/proto/static/config.Y index 3e9ac578..6e410879 100644 --- a/proto/static/config.Y +++ b/proto/static/config.Y @@ -40,7 +40,7 @@ static_route_finish(void) if (net_type_match(this_srt->net, NB_DEST) == !this_srt->dest) cf_error("Unexpected or missing nexthop/type"); - this_srt->cmds = f_postfixify(this_srt_cmds); + this_srt->cmds = f_linearize(this_srt_cmds); } CF_DECLS