diff options
author | murf <murf@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-04-21 21:13:02 +0000 |
---|---|---|
committer | murf <murf@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-04-21 21:13:02 +0000 |
commit | 137c1d8d9edab78e7cc0f238e4898ae6adca8e11 (patch) | |
tree | e783203f7d0fa05d28feb3bc509c19bc885d2666 /main/ast_expr2.y | |
parent | 724844c2758c811b9723bb787f465e85da668f20 (diff) |
(closes issue #12467)
Reported by: atis
Tested by: murf
This upgrade adds the ~~ (concatenation) string operator to expr2.
While not needed in normal runtime pbx operation, it is needed when
raw exprs are being syntax checked. This plays into future syntax-
unification plans. By permission of atis, this addition in trunk
and the reason of why things are as they are will suffice to close
this bug.
I also added a short note about the previous addition of "sip show sched"
to the CLI in CHANGES, which I discovered I forgot in a previous commit.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@114423 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/ast_expr2.y')
-rw-r--r-- | main/ast_expr2.y | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/main/ast_expr2.y b/main/ast_expr2.y index 7eba6d165..76fe16005 100644 --- a/main/ast_expr2.y +++ b/main/ast_expr2.y @@ -284,6 +284,7 @@ static struct val *make_str __P((const char *)); static struct val *op_and __P((struct val *, struct val *)); static struct val *op_colon __P((struct val *, struct val *)); static struct val *op_eqtilde __P((struct val *, struct val *)); +static struct val *op_tildetilde __P((struct val *, struct val *)); static struct val *op_div __P((struct val *, struct val *)); static struct val *op_eq __P((struct val *, struct val *)); static struct val *op_ge __P((struct val *, struct val *)); @@ -354,18 +355,16 @@ extern int ast_yylex __P((YYSTYPE *, YYLTYPE *, yyscan_t)); %left <val> TOK_PLUS TOK_MINUS %left <val> TOK_MULT TOK_DIV TOK_MOD %right <val> TOK_COMPL -%left <val> TOK_COLON TOK_EQTILDE +%left <val> TOK_COLON TOK_EQTILDE TOK_TILDETILDE %left <val> TOK_RP TOK_LP - %token <val> TOKEN %type <arglist> arglist %type <val> start expr - %destructor { free_value($$); } expr TOKEN TOK_COND TOK_COLONCOLON TOK_OR TOK_AND TOK_EQ TOK_GT TOK_LT TOK_GE TOK_LE TOK_NE TOK_PLUS TOK_MINUS TOK_MULT TOK_DIV TOK_MOD TOK_COMPL TOK_COLON TOK_EQTILDE - TOK_RP TOK_LP + TOK_RP TOK_LP TOK_TILDETILDE %% @@ -478,6 +477,10 @@ expr: DESTROY($4); @$.first_column = @1.first_column; @$.last_column = @3.last_column; @$.first_line=0; @$.last_line=0;} + | expr TOK_TILDETILDE expr { $$ = op_tildetilde ($1, $3); + DESTROY($2); + @$.first_column = @1.first_column; @$.last_column = @3.last_column; + @$.first_line=0; @$.last_line=0;} ; %% @@ -1617,3 +1620,29 @@ op_eqtilde (struct val *a, struct val *b) return v; } + +static struct val * /* this is a string concat operator */ +op_tildetilde (struct val *a, struct val *b) +{ + struct val *v; + char *vs; + + /* coerce to both arguments to strings */ + to_string(a); + to_string(b); + /* strip double quotes from both -- */ + strip_quotes(a); + strip_quotes(b); + + vs = malloc(strlen(a->u.s)+strlen(b->u.s)+1); + strcpy(vs,a->u.s); + strcat(vs,b->u.s); + + v = make_str(vs); + + /* free arguments */ + free_value(a); + free_value(b); + + return v; +} |