aboutsummaryrefslogtreecommitdiff
path: root/src/Conf.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Conf.cpp')
-rw-r--r--src/Conf.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/Conf.cpp b/src/Conf.cpp
index dc9c406..74c311c 100644
--- a/src/Conf.cpp
+++ b/src/Conf.cpp
@@ -463,19 +463,20 @@ namespace sibs
Result<bool> Config::readFromFile(const _tinydir_char_t *filepath, SibsConfig &config)
{
- Result<StringView> fileContentResult = getFileContent(filepath);
+ Result<std::string> fileContentResult = getFileContent(filepath);
if(fileContentResult.isErr())
return Result<bool>::Err(fileContentResult.getErrMsg());
- const char *code = fileContentResult.unwrap().data;
- if(!utf8::is_valid(code, code + fileContentResult.unwrap().size))
+ const std::string &code = fileContentResult.unwrap();
+ if(!utf8::is_valid(code.data(), code.data() + code.size()))
return Result<bool>::Err("File is not in valid utf8 format");
- if(fileContentResult.unwrap().size >= 3 && utf8::is_bom(code))
- code += 3;
+ const char *code_ptr = code.data();
+ if(code.size() >= 3 && utf8::is_bom(code_ptr))
+ code_ptr += 3;
// Do not free file content (fileContentResult) on purpose, since we are using the data and sibs is short lived
- Result<bool> parseResult = Parser::parse(code, config);
+ Result<bool> parseResult = Parser::parse(code_ptr, config);
if(!parseResult)
{
string errMsg = "Failed while parsing project.conf for project ";