@@ -61,8 +61,10 @@ namespace jse
6161 {
6262 if (key == " /" )
6363 return pointer;
64+ else if (pointer == " /" )
65+ return key;
6466 else
65- return key + " / " + pointer;
67+ return key + pointer;
6668 }
6769
6870 } // namespace
@@ -81,7 +83,7 @@ namespace jse
8183 {
8284 // check if the rules have any include
8385 bool include_present = false ;
84- for (auto rule : current)
86+ for (const auto & rule : current)
8587 if (rule.at (" type" ) == " include" )
8688 include_present = true ;
8789
@@ -91,7 +93,7 @@ namespace jse
9193
9294 json enriched;
9395 // otherwise, do a round of replacement
94- for (auto rule : current)
96+ for (const auto & rule : current)
9597 {
9698 // copy all rules that are not include
9799 if (rule.at (" type" ) != " include" )
@@ -103,26 +105,27 @@ namespace jse
103105 {
104106 bool replaced = false ;
105107 // the include file could be in any of the include directories
106- for (auto dir : dirs)
108+ for (const auto & dir : dirs)
107109 {
108110 string spec_file = rule.at (" spec_file" );
109- string f = dir + spec_file;
111+ string f = dir + " / " + spec_file;
110112 // check if the file exists
111113 if (std::filesystem::is_regular_file (f))
112114 {
113115 std::ifstream ifs (f);
114116 json include_rules = json::parse (ifs);
115117
116118 // loop over all rules to add the prefix
117- for (auto i_rule : include_rules)
119+ for (auto & i_rule : include_rules)
118120 {
119121 string prefix = rule.at (" pointer" );
120122 string pointer = i_rule.at (" pointer" );
121- i_rule.at (" pointer" ) = prepend_pointer (pointer,prefix);
123+ string new_pointer = prepend_pointer (pointer,prefix);
124+ i_rule.at (" pointer" ) = new_pointer;
122125 }
123126
124127 // save modified rules
125- for (auto i_rule : include_rules)
128+ for (const auto & i_rule : include_rules)
126129 enriched.push_back (i_rule);
127130
128131 // one substitution is enough, give up the search over include dirs
0 commit comments