@@ -41,6 +41,7 @@ namespace urcl
4141{
4242namespace control
4343{
44+ constexpr double ZERO_EPSILON = 0.000001 ;
4445
4546bool operator <(const ScriptReader::DataVariant& lhs, const ScriptReader::DataVariant& rhs)
4647{
@@ -96,7 +97,7 @@ bool operator==(const ScriptReader::DataVariant& lhs, const ScriptReader::DataVa
9697 {
9798 if (std::holds_alternative<double >(rhs))
9899 {
99- return std::abs ((static_cast <double >(std::get<bool >(lhs)) - std::get<double >(rhs))) < 0.0001 ;
100+ return std::abs ((static_cast <double >(std::get<bool >(lhs)) - std::get<double >(rhs))) < ZERO_EPSILON ;
100101 }
101102 if (std::holds_alternative<int >(rhs))
102103 {
@@ -144,12 +145,11 @@ std::string ScriptReader::readScriptFile(const std::string& filename, const Data
144145 return script_code;
145146}
146147
147- std::string ScriptReader::readFileContent (const std::string& filename )
148+ std::string ScriptReader::readFileContent (const std::string& file_path )
148149{
149150 std::ifstream ifs;
150- ifs.open (filename );
151+ ifs.open (file_path );
151152 std::string content;
152- std::ifstream file (filename);
153153 if (ifs)
154154 {
155155 content = std::string ((std::istreambuf_iterator<char >(ifs)), (std::istreambuf_iterator<char >()));
@@ -158,7 +158,7 @@ std::string ScriptReader::readFileContent(const std::string& filename)
158158 else
159159 {
160160 std::stringstream ss;
161- ss << " Could not open script file '" << filename << " '. Please check if the file exists and is readable." ;
161+ ss << " Could not open script file '" << file_path << " '. Please check if the file exists and is readable." ;
162162 throw UrException (ss.str ().c_str ());
163163 }
164164
@@ -174,8 +174,9 @@ void ScriptReader::replaceIncludes(std::string& script, const DataDict& data)
174174 // Replace all include patterns in the line
175175 while (std::regex_search (script, match, include_pattern))
176176 {
177- std::filesystem::path file_path (match[1 ].str ());
178- std::string file_content = readScriptFile ((script_path_.parent_path () / file_path.string ()).string (), data);
177+ std::filesystem::path relative_file_path (match[1 ].str ());
178+ std::string file_content =
179+ readScriptFile ((script_path_.parent_path () / relative_file_path.string ()).string (), data);
179180 script.replace (match.position (0 ), match.length (0 ), file_content);
180181 }
181182}
0 commit comments