More work on command parser
This commit is contained in:
@@ -14,6 +14,23 @@
|
||||
#include "table.hpp"
|
||||
#include "source.hpp"
|
||||
|
||||
// Read control.lst
|
||||
//
|
||||
// - trim all lines
|
||||
// - remove blank lines
|
||||
// - remove comment lines
|
||||
//
|
||||
util::stringvec read_control_lst(const std::string &path) {
|
||||
util::stringvec lines = util::get_file_lines(path);
|
||||
util::stringvec result;
|
||||
for (int i = 0; i < int(lines.size()); i++) {
|
||||
std::string trimmed = util::trim(lines[i]);
|
||||
if ((trimmed.size() > 0) && (trimmed[0] != '#')) {
|
||||
result.push_back(trimmed);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
LuaDefine(source_makeclass, "f") {
|
||||
LuaArg classname;
|
||||
@@ -158,8 +175,7 @@ void SourceDB::update() {
|
||||
}
|
||||
|
||||
// Read the list of filenames.
|
||||
std::string ctrl = "lua/control.lst";
|
||||
util::stringvec filenames = util::trim_and_uncomment(util::read_lines(ctrl));
|
||||
util::stringvec filenames = read_control_lst("lua/control.lst");
|
||||
if (filenames.empty()) {
|
||||
luaL_error(L, "cannot read source database control.lst");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user