Module: sip-router Branch: andrei/script_vars Commit: 33d560253c7fe8dd652251bc057873906edb2682 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=33d56025...
Author: Andrei Pelinescu-Onciul andrei@iptel.org Committer: Andrei Pelinescu-Onciul andrei@iptel.org Date: Fri Dec 19 14:20:41 2008 +0100
script parsing: helper function updated & moved
- helper function for computing the file position of an expression
---
cfg.y | 23 +---------------------- route_struct.c | 24 ++++++++++++++++++++++++ route_struct.h | 3 +++ 3 files changed, 28 insertions(+), 22 deletions(-)
diff --git a/cfg.y b/cfg.y index 7ced7c1..63c9eb4 100644 --- a/cfg.y +++ b/cfg.y @@ -201,8 +201,6 @@ static struct rvalue* rval_tmp;
static void warn(char* s); static void get_cpos(struct cfg_pos* pos); -static void get_rve2_pos(struct cfg_pos* res, - struct cfg_pos* pos1, struct cfg_pos* pos2); static struct rval_expr* mk_rve_rval(enum rval_type, void* v); static struct rval_expr* mk_rve1(enum rval_expr_op op, struct rval_expr* rve1); static struct rval_expr* mk_rve2(enum rval_expr_op op, struct rval_expr* rve1, @@ -2613,25 +2611,6 @@ static void yyerror(char* format, ...)
-static void get_rve2_pos(struct cfg_pos* res, - struct cfg_pos* pos1, struct cfg_pos* pos2) -{ - *res=*pos1; - if ((res->s_line == 0) || (res->s_line > pos2->s_line)){ - res->s_line=pos2->s_line; - res->s_col=pos2->s_col; - }else if ((res->s_line == pos2->s_line) && (res->s_col > pos2->s_col)){ - res->s_col=pos2->s_col; - } - if ((res->e_line == 0) || (res->e_line < pos2->e_line)){ - res->e_line=pos2->e_line; - res->e_col=pos2->e_col; - }else if ((res->e_line == pos2->e_line) && (res->e_col < pos2->e_col)){ - res->e_col=pos2->e_col; - } -} - - /** mk_rval_expr_v wrapper. * checks mk_rval_expr_v return value and sets the cfg. pos * (line and column numbers) @@ -2688,7 +2667,7 @@ static struct rval_expr* mk_rve2(enum rval_expr_op op, struct rval_expr* rve1, if ((rve1==0) || (rve2==0)) return 0; - get_rve2_pos(&pos, &rve1->fpos, &rve2->fpos); + cfg_pos_join(&pos, &rve1->fpos, &rve2->fpos); ret=mk_rval_expr2(op, rve1, rve2, &pos); if (ret && (rve_check_type(&type, ret, &bad_rve, &bad_t, &exp_t)!=1)){ yyerror_at(&pos, "bad expression: type mismatch:" diff --git a/route_struct.c b/route_struct.c index 5cf74ee..7fce4b8 100644 --- a/route_struct.c +++ b/route_struct.c @@ -52,6 +52,30 @@ #include "ut.h" /* ZSW() */
+ +/** joins to cfg file positions into a new one. */ +void cfg_pos_join(struct cfg_pos* res, + struct cfg_pos* pos1, struct cfg_pos* pos2) +{ + struct cfg_pos ret; + ret=*pos1; + if ((ret.s_line == 0) || (ret.s_line > pos2->s_line)){ + ret.s_line=pos2->s_line; + ret.s_col=pos2->s_col; + }else if ((ret.s_line == pos2->s_line) && (ret.s_col > pos2->s_col)){ + ret.s_col=pos2->s_col; + } + if ((ret.e_line == 0) || (ret.e_line < pos2->e_line)){ + ret.e_line=pos2->e_line; + ret.e_col=pos2->e_col; + }else if ((ret.e_line == pos2->e_line) && (ret.e_col < pos2->e_col)){ + ret.e_col=pos2->e_col; + } + *res=ret; +} + + + struct expr* mk_exp(int op, struct expr* left, struct expr* right) { struct expr * e; diff --git a/route_struct.h b/route_struct.h index ba5046e..76aac25 100644 --- a/route_struct.h +++ b/route_struct.h @@ -167,5 +167,8 @@ void print_action(struct action* a); void print_actions(struct action* a); void print_expr(struct expr* exp);
+/** joins to cfg file positions into a new one. */ +void cfg_pos_join(struct cfg_pos* res, + struct cfg_pos* pos1, struct cfg_pos* pos2); #endif