a small fix

This commit is contained in:
blueloveTH 2022-11-09 19:28:33 +08:00
parent fa3e46bc46
commit 4c27b5210b
2 changed files with 11 additions and 1 deletions

View File

@ -44,7 +44,9 @@ struct SourceMetadata {
_Str snapshot(int lineno){ _Str snapshot(int lineno){
_StrStream ss; _StrStream ss;
ss << " " << "File \"" << filename << "\", line " << lineno << '\n'; ss << " " << "File \"" << filename << "\", line " << lineno << '\n';
ss << " " << getLine(lineno) << '\n'; _Str line = getLine(lineno).__lstrip();
if(line.empty()) line = "<?>";
ss << " " << line << '\n';
return ss.str(); return ss.str();
} }
}; };

View File

@ -121,6 +121,14 @@ public:
operator const char*() const { operator const char*() const {
return _s.c_str(); return _s.c_str();
} }
_Str __lstrip() const {
std::string copy(_s);
copy.erase(copy.begin(), std::find_if(copy.begin(), copy.end(), [](char c) {
return !std::isspace(c);
}));
return _Str(copy);
}
}; };