@@ -17,8 +17,6 @@ static std::vector<t_sg_link> parse_sg_link_tags(pugi::xml_node sg_link_list_tag
17
17
std::vector<t_sg_link> sg_link_list;
18
18
pugiutil::expect_only_children (sg_link_list_tag, {" sg_link" }, loc_data);
19
19
for (pugi::xml_node node : sg_link_list_tag.children ()) {
20
- if (strcmp (node.name (), " sg_link" ) != 0 ) continue ;
21
-
22
20
const std::vector<std::string> expected_attributes = {" name" , " x_offset" , " y_offset" , " z_offset" , " mux" , " seg_type" };
23
21
pugiutil::expect_only_attributes (node, expected_attributes, loc_data);
24
22
@@ -27,9 +25,10 @@ static std::vector<t_sg_link> parse_sg_link_tags(pugi::xml_node sg_link_list_tag
27
25
sg_link.mux_name = pugiutil::get_attribute (node, " mux" , loc_data).as_string ();
28
26
sg_link.seg_type = pugiutil::get_attribute (node, " seg_type" , loc_data).as_string ();
29
27
30
- int x_offset = pugiutil::get_attribute (node, " x_offset" , loc_data, pugiutil::OPTIONAL).as_int ();
31
- int y_offset = pugiutil::get_attribute (node, " y_offset" , loc_data, pugiutil::OPTIONAL).as_int ();
32
- int z_offset = pugiutil::get_attribute (node, " z_offset" , loc_data, pugiutil::OPTIONAL).as_int ();
28
+ // Since the offset attributes are optional and might not exist, the as_int method will return a value of zero if the attribute is empty
29
+ int x_offset = pugiutil::get_attribute (node, " x_offset" , loc_data, pugiutil::OPTIONAL).as_int (0 );
30
+ int y_offset = pugiutil::get_attribute (node, " y_offset" , loc_data, pugiutil::OPTIONAL).as_int (0 );
31
+ int z_offset = pugiutil::get_attribute (node, " z_offset" , loc_data, pugiutil::OPTIONAL).as_int (0 );
33
32
34
33
if (x_offset == 0 && y_offset == 0 && z_offset == 0 ) {
35
34
archfpga_throw (loc_data.filename_c_str (), loc_data.line (node), " All offset fields in the <sg_link> are non-zero or missing." );
0 commit comments