From c33ea24113c282c63ac1ed882c479ea42d9e5536 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Tue, 21 Jun 2016 18:15:04 +0200 Subject: [PATCH] bug #4587: Fixes issues when filtering context values --- src/template/template_parser.c | 2 +- src/vm/vm_var_parser.c | 2 +- src/vm/vm_var_syntax.cc | 36 ++++++++++++++++------------------ src/vm/vm_var_syntax.h | 2 +- src/vm/vm_var_syntax.y | 6 ++---- src/xml/expr_bool.cc | 6 ++---- src/xml/expr_bool.y | 4 ++-- src/xml/expr_parser.c | 2 +- 8 files changed, 27 insertions(+), 33 deletions(-) diff --git a/src/template/template_parser.c b/src/template/template_parser.c index e2621e6863..44e797d98c 100644 --- a/src/template/template_parser.c +++ b/src/template/template_parser.c @@ -1621,7 +1621,7 @@ static void template_ensure_buffer_stack (void) * scanner will even need a stack. We use 2 instead of 1 to avoid an * immediate realloc on the next call. */ - num_to_alloc = 1; // After all that talk, this was set to 1 anyways... + num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ (yy_buffer_stack) = (struct yy_buffer_state**)template_alloc (num_to_alloc * sizeof(struct yy_buffer_state*) ); diff --git a/src/vm/vm_var_parser.c b/src/vm/vm_var_parser.c index 9d37c943ba..808fb1eaae 100644 --- a/src/vm/vm_var_parser.c +++ b/src/vm/vm_var_parser.c @@ -1582,7 +1582,7 @@ static void vm_var_ensure_buffer_stack (void) * scanner will even need a stack. We use 2 instead of 1 to avoid an * immediate realloc on the next call. */ - num_to_alloc = 1; // After all that talk, this was set to 1 anyways... + num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ (yy_buffer_stack) = (struct yy_buffer_state**)vm_var_alloc (num_to_alloc * sizeof(struct yy_buffer_state*) ); diff --git a/src/vm/vm_var_syntax.cc b/src/vm/vm_var_syntax.cc index bb800019d0..a3ce90aa40 100644 --- a/src/vm/vm_var_syntax.cc +++ b/src/vm/vm_var_syntax.cc @@ -431,13 +431,11 @@ void insert_vector(VirtualMachine * vm, } else { - const VectorAttribute * tmp = 0; - for (int i=0 ; i < num ; i++) { - if (tmp->vector_value(vvar.c_str()) == vval) + if (values[i]->vector_value(vvar.c_str()) == vval) { - vattr = tmp; + vattr = values[i]; break; } } @@ -454,7 +452,7 @@ void insert_vector(VirtualMachine * vm, /* -------------------------------------------------------------------------- */ -#line 458 "vm_var_syntax.cc" /* yacc.c:339 */ +#line 456 "vm_var_syntax.cc" /* yacc.c:339 */ # ifndef YY_NULLPTR # if defined __cplusplus && 201103L <= __cplusplus @@ -506,13 +504,13 @@ extern int vm_var__debug; union YYSTYPE { -#line 410 "vm_var_syntax.y" /* yacc.c:355 */ +#line 408 "vm_var_syntax.y" /* yacc.c:355 */ char * val_str; int val_int; char val_char; -#line 516 "vm_var_syntax.cc" /* yacc.c:355 */ +#line 514 "vm_var_syntax.cc" /* yacc.c:355 */ }; typedef union YYSTYPE YYSTYPE; @@ -542,7 +540,7 @@ int vm_var__parse (mem_collector * mc, VirtualMachine * vm, ostringstream * par /* Copy the second part of user declarations. */ -#line 546 "vm_var_syntax.cc" /* yacc.c:358 */ +#line 544 "vm_var_syntax.cc" /* yacc.c:358 */ #ifdef short # undef short @@ -842,7 +840,7 @@ static const yytype_uint8 yytranslate[] = /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 434, 434, 435, 438, 442, 455, 470 + 0, 432, 432, 433, 436, 440, 453, 468 }; #endif @@ -1722,15 +1720,15 @@ yyreduce: switch (yyn) { case 4: -#line 439 "vm_var_syntax.y" /* yacc.c:1646 */ +#line 437 "vm_var_syntax.y" /* yacc.c:1646 */ { (*parsed) << (yyvsp[0].val_str); } -#line 1730 "vm_var_syntax.cc" /* yacc.c:1646 */ +#line 1728 "vm_var_syntax.cc" /* yacc.c:1646 */ break; case 5: -#line 443 "vm_var_syntax.y" /* yacc.c:1646 */ +#line 441 "vm_var_syntax.y" /* yacc.c:1646 */ { string name((yyvsp[-1].val_str)); @@ -1743,11 +1741,11 @@ yyreduce: (*parsed) << (yyvsp[0].val_char); } } -#line 1747 "vm_var_syntax.cc" /* yacc.c:1646 */ +#line 1745 "vm_var_syntax.cc" /* yacc.c:1646 */ break; case 6: -#line 456 "vm_var_syntax.y" /* yacc.c:1646 */ +#line 454 "vm_var_syntax.y" /* yacc.c:1646 */ { string name((yyvsp[-4].val_str)); string vname((yyvsp[-2].val_str)); @@ -1762,11 +1760,11 @@ yyreduce: (*parsed) << (yyvsp[0].val_char); } } -#line 1766 "vm_var_syntax.cc" /* yacc.c:1646 */ +#line 1764 "vm_var_syntax.cc" /* yacc.c:1646 */ break; case 7: -#line 471 "vm_var_syntax.y" /* yacc.c:1646 */ +#line 469 "vm_var_syntax.y" /* yacc.c:1646 */ { string name((yyvsp[-8].val_str)); string vname((yyvsp[-6].val_str)); @@ -1784,11 +1782,11 @@ yyreduce: (*parsed) << (yyvsp[0].val_char); } } -#line 1788 "vm_var_syntax.cc" /* yacc.c:1646 */ +#line 1786 "vm_var_syntax.cc" /* yacc.c:1646 */ break; -#line 1792 "vm_var_syntax.cc" /* yacc.c:1646 */ +#line 1790 "vm_var_syntax.cc" /* yacc.c:1646 */ default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -2023,7 +2021,7 @@ yyreturn: #endif return yyresult; } -#line 489 "vm_var_syntax.y" /* yacc.c:1906 */ +#line 487 "vm_var_syntax.y" /* yacc.c:1906 */ extern "C" void vm_var__error( diff --git a/src/vm/vm_var_syntax.h b/src/vm/vm_var_syntax.h index 802497f373..52def943b4 100644 --- a/src/vm/vm_var_syntax.h +++ b/src/vm/vm_var_syntax.h @@ -62,7 +62,7 @@ extern int vm_var__debug; union YYSTYPE { -#line 410 "vm_var_syntax.y" /* yacc.c:1909 */ +#line 408 "vm_var_syntax.y" /* yacc.c:1909 */ char * val_str; int val_int; diff --git a/src/vm/vm_var_syntax.y b/src/vm/vm_var_syntax.y index 7e3cb31372..b21e2ce28e 100644 --- a/src/vm/vm_var_syntax.y +++ b/src/vm/vm_var_syntax.y @@ -376,13 +376,11 @@ void insert_vector(VirtualMachine * vm, } else { - const VectorAttribute * tmp = 0; - for (int i=0 ; i < num ; i++) { - if (tmp->vector_value(vvar.c_str()) == vval) + if (values[i]->vector_value(vvar.c_str()) == vval) { - vattr = tmp; + vattr = values[i]; break; } } diff --git a/src/xml/expr_bool.cc b/src/xml/expr_bool.cc index fa3725d31c..8bd796fba9 100644 --- a/src/xml/expr_bool.cc +++ b/src/xml/expr_bool.cc @@ -84,8 +84,6 @@ #include "expr_bool.h" #include "ObjectXML.h" -using namespace std; - #define YYERROR_VERBOSE #define expr_bool__lex expr_lex @@ -1497,7 +1495,7 @@ yyreduce: case 12: #line 160 "expr_bool.y" /* yacc.c:1646 */ { - string val; + std::string val; int rc; rc = oxml->search((yyvsp[-2].val_str),val); @@ -1509,7 +1507,7 @@ yyreduce: case 13: #line 168 "expr_bool.y" /* yacc.c:1646 */ { - string val; + std::string val; int rc; rc = oxml->search((yyvsp[-3].val_str),val); diff --git a/src/xml/expr_bool.y b/src/xml/expr_bool.y index 524c4f9da1..09f9259542 100644 --- a/src/xml/expr_bool.y +++ b/src/xml/expr_bool.y @@ -158,7 +158,7 @@ expr: STRING '=' INTEGER { $$ = (rc == 0 && val < $3);} | STRING '=' STRING { - string val; + std::string val; int rc; rc = oxml->search($1,val); @@ -166,7 +166,7 @@ expr: STRING '=' INTEGER { } | STRING '!''=' STRING { - string val; + std::string val; int rc; rc = oxml->search($1,val); diff --git a/src/xml/expr_parser.c b/src/xml/expr_parser.c index 63175b6d82..1bdd727d13 100644 --- a/src/xml/expr_parser.c +++ b/src/xml/expr_parser.c @@ -1526,7 +1526,7 @@ static void expr_ensure_buffer_stack (void) * scanner will even need a stack. We use 2 instead of 1 to avoid an * immediate realloc on the next call. */ - num_to_alloc = 1; // After all that talk, this was set to 1 anyways... + num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ (yy_buffer_stack) = (struct yy_buffer_state**)expr_alloc (num_to_alloc * sizeof(struct yy_buffer_state*) );