mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-04 03:50:31 +00:00
(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: https://origsvn.digium.com/svn/asterisk/trunk@114423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user