]> granicus.if.org Git - icinga2/commitdiff
Config: Fix nested dictionaries in arrays.
authorGunnar Beutner <gunnar.beutner@netways.de>
Fri, 21 Jun 2013 07:07:57 +0000 (09:07 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Fri, 21 Jun 2013 07:07:57 +0000 (09:07 +0200)
contrib/gdb/gdbinit
lib/config/config_parser.cc
lib/config/config_parser.yy
lib/icinga/host.cpp

index f4fe791c6452fcc3e8ce1f14b70688e2b6bbc584..b15fb55ba04a42701739192bfc12b606984fcb8f 100644 (file)
@@ -1,3 +1,5 @@
+set env LD_PRELOAD /lib/x86_64-linux-gnu/libpthread.so.0
+
 python
 import sys
 sys.path.insert(0, '/home/gbeutner/strawberry/contrib/gdb')
index 4121738c3d3b3c15a586a8e03cb8675aedbab3fa..1f8dbf7f2ce9ac391eab01db943e75d5db781d5d 100644 (file)
@@ -612,8 +612,8 @@ static const yytype_uint16 yyrline[] =
      273,   280,   281,   282,   283,   284,   285,   286,   293,   293,
      338,   339,   344,   345,   348,   352,   359,   362,   368,   381,
      384,   390,   396,   400,   406,   409,   415,   427,   433,   447,
-     448,   449,   450,   451,   457,   463,   467,   473,   476,   482,
-     494,   499,   503,   507,   517,   518
+     448,   449,   450,   451,   457,   463,   467,   473,   476,   491,
+     511,   516,   520,   524,   534,   535
 };
 #endif
 
@@ -2136,6 +2136,15 @@ yyreduce:
 #line 477 "config_parser.yy"
     {
                (yyval.array) = new Array();
+
+               if ((yyvsp[(1) - (1)].variant)->IsObjectType<ExpressionList>()) {
+                       ExpressionList::Ptr exprl = *(yyvsp[(1) - (1)].variant);
+                       Dictionary::Ptr dict = boost::make_shared<Dictionary>();
+                       exprl->Execute(dict);
+                       delete (yyvsp[(1) - (1)].variant);
+                       (yyvsp[(1) - (1)].variant) = new Value(dict);
+               }
+
                (yyval.array)->Add(*(yyvsp[(1) - (1)].variant));
                delete (yyvsp[(1) - (1)].variant);
        }
@@ -2144,13 +2153,21 @@ yyreduce:
   case 69:
 
 /* Line 1806 of yacc.c  */
-#line 483 "config_parser.yy"
+#line 492 "config_parser.yy"
     {
                if ((yyvsp[(1) - (3)].array))
                        (yyval.array) = (yyvsp[(1) - (3)].array);
                else
                        (yyval.array) = new Array();
 
+               if ((yyvsp[(3) - (3)].variant)->IsObjectType<ExpressionList>()) {
+                       ExpressionList::Ptr exprl = *(yyvsp[(3) - (3)].variant);
+                       Dictionary::Ptr dict = boost::make_shared<Dictionary>();
+                       exprl->Execute(dict);
+                       delete (yyvsp[(3) - (3)].variant);
+                       (yyvsp[(3) - (3)].variant) = new Value(dict);
+               }
+
                (yyval.array)->Add(*(yyvsp[(3) - (3)].variant));
                delete (yyvsp[(3) - (3)].variant);
        }
@@ -2159,7 +2176,7 @@ yyreduce:
   case 70:
 
 /* Line 1806 of yacc.c  */
-#line 495 "config_parser.yy"
+#line 512 "config_parser.yy"
     {
                (yyval.variant) = new Value((yyvsp[(1) - (1)].text));
                free((yyvsp[(1) - (1)].text));
@@ -2169,7 +2186,7 @@ yyreduce:
   case 71:
 
 /* Line 1806 of yacc.c  */
-#line 500 "config_parser.yy"
+#line 517 "config_parser.yy"
     {
                (yyval.variant) = new Value((yyvsp[(1) - (1)].num));
        }
@@ -2178,7 +2195,7 @@ yyreduce:
   case 72:
 
 /* Line 1806 of yacc.c  */
-#line 504 "config_parser.yy"
+#line 521 "config_parser.yy"
     {
                (yyval.variant) = new Value();
        }
@@ -2187,7 +2204,7 @@ yyreduce:
   case 73:
 
 /* Line 1806 of yacc.c  */
-#line 508 "config_parser.yy"
+#line 525 "config_parser.yy"
     {
                if ((yyvsp[(1) - (1)].array) == NULL)
                        (yyvsp[(1) - (1)].array) = new Array();
@@ -2200,7 +2217,7 @@ yyreduce:
   case 75:
 
 /* Line 1806 of yacc.c  */
-#line 519 "config_parser.yy"
+#line 536 "config_parser.yy"
     {
                ExpressionList::Ptr exprl = ExpressionList::Ptr((yyvsp[(1) - (1)].exprl));
                (yyval.variant) = new Value(exprl);
@@ -2210,7 +2227,7 @@ yyreduce:
 
 
 /* Line 1806 of yacc.c  */
-#line 2214 "../../../lib/config/config_parser.cc"
+#line 2231 "../../../lib/config/config_parser.cc"
       default: break;
     }
   /* User semantic actions sometimes alter yychar, and that requires
@@ -2448,6 +2465,6 @@ yyreturn:
 
 
 /* Line 2067 of yacc.c  */
-#line 524 "config_parser.yy"
+#line 541 "config_parser.yy"
 
 
index 5c2c35e2a05273347d16c59b83fe2c5d94053579..201460d03e2931eec8d9709f53abfd8b108cf3e0 100644 (file)
@@ -476,6 +476,15 @@ array_items_inner: /* empty */
        | value
        {
                $$ = new Array();
+
+               if ($1->IsObjectType<ExpressionList>()) {
+                       ExpressionList::Ptr exprl = *$1;
+                       Dictionary::Ptr dict = boost::make_shared<Dictionary>();
+                       exprl->Execute(dict);
+                       delete $1;
+                       $1 = new Value(dict);
+               }
+
                $$->Add(*$1);
                delete $1;
        }
@@ -486,6 +495,14 @@ array_items_inner: /* empty */
                else
                        $$ = new Array();
 
+               if ($3->IsObjectType<ExpressionList>()) {
+                       ExpressionList::Ptr exprl = *$3;
+                       Dictionary::Ptr dict = boost::make_shared<Dictionary>();
+                       exprl->Execute(dict);
+                       delete $3;
+                       $3 = new Value(dict);
+               }
+
                $$->Add(*$3);
                delete $3;
        }
index dcdf3f18eec4d203342cfde512a10e7fb8464e5b..9435187baf44e92ccd1ec4af0e74b3aef17c08b0 100644 (file)
@@ -420,8 +420,6 @@ Service::Ptr Host::GetServiceByShortName(const Value& name) const
                Dictionary::Ptr dict = name;
                String short_name;
 
-               ASSERT(dict->IsSealed());
-
                return Service::GetByNamePair(dict->Get("host"), dict->Get("service"));
        } else {
                BOOST_THROW_EXCEPTION(std::invalid_argument("Host/Service name pair is invalid: " + name.Serialize()));