mirror of
https://github.com/luau-lang/luau.git
synced 2025-05-04 10:33:46 +01:00
Detect shebang more precisely and simplify erase code
This commit is contained in:
parent
b37e6b7db8
commit
488a588aea
1 changed files with 3 additions and 10 deletions
|
@ -67,16 +67,9 @@ std::optional<std::string> readFile(const std::string& name)
|
|||
if (read != size_t(length))
|
||||
return std::nullopt;
|
||||
|
||||
// Skip first line if it's a comment
|
||||
if (length != 0 && result[0] == '#')
|
||||
{
|
||||
auto newLine = result.find('\n');
|
||||
|
||||
if (newLine != std::string::npos)
|
||||
result.erase(0, newLine);
|
||||
else
|
||||
result.clear();
|
||||
}
|
||||
// Skip first line if it's a shebang
|
||||
if (length > 2 && result[0] == '#' && result[1] == '!')
|
||||
result.erase(0, result.find('\n'));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue