macro processor: allow @#includepath to accept a colon-separated list of paths
parent
6cf9a410d0
commit
12b09073e3
|
@ -68,7 +68,14 @@ IncludePath::interpret(ostream &output, bool no_line_macro)
|
||||||
StringPtr msp = dynamic_pointer_cast<String>(expr->eval());
|
StringPtr msp = dynamic_pointer_cast<String>(expr->eval());
|
||||||
if (!msp)
|
if (!msp)
|
||||||
throw StackTrace("File name does not evaluate to a string");
|
throw StackTrace("File name does not evaluate to a string");
|
||||||
path = *msp;
|
size_t last = 0;
|
||||||
|
size_t next = 0;
|
||||||
|
while ((next = static_cast<string>(*msp).find(":", last)) != string::npos)
|
||||||
|
{
|
||||||
|
path.push_back(static_cast<string>(*msp).substr(last, next-last));
|
||||||
|
last = next + 1;
|
||||||
|
}
|
||||||
|
path.push_back(static_cast<string>(*msp).substr(last));
|
||||||
}
|
}
|
||||||
catch (StackTrace &ex)
|
catch (StackTrace &ex)
|
||||||
{
|
{
|
||||||
|
|
|
@ -83,12 +83,12 @@ namespace macro
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
const ExpressionPtr expr;
|
const ExpressionPtr expr;
|
||||||
string path;
|
vector<string> path;
|
||||||
public:
|
public:
|
||||||
IncludePath(const ExpressionPtr expr_arg, Environment &env_arg, const Tokenizer::location location_arg) :
|
IncludePath(const ExpressionPtr expr_arg, Environment &env_arg, const Tokenizer::location location_arg) :
|
||||||
Directive(env_arg, move(location_arg)), expr{move(expr_arg)} { }
|
Directive(env_arg, move(location_arg)), expr{move(expr_arg)} { }
|
||||||
void interpret(ostream &output, bool no_line_macro) override;
|
void interpret(ostream &output, bool no_line_macro) override;
|
||||||
inline string getPath() const { return path; }
|
inline vector<string> getPath() const { return path; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,10 @@ Driver::parse(const string &file_arg, const string &basename_arg, istream &modfi
|
||||||
|
|
||||||
auto ipp = dynamic_pointer_cast<IncludePath>(statement);
|
auto ipp = dynamic_pointer_cast<IncludePath>(statement);
|
||||||
if (ipp)
|
if (ipp)
|
||||||
paths.emplace_back(ipp->getPath());
|
{
|
||||||
|
auto p = ipp->getPath();
|
||||||
|
paths.insert(paths.end(), p.begin(), p.end());
|
||||||
|
}
|
||||||
|
|
||||||
auto ip = dynamic_pointer_cast<Include>(statement);
|
auto ip = dynamic_pointer_cast<Include>(statement);
|
||||||
if (ip)
|
if (ip)
|
||||||
|
|
Loading…
Reference in New Issue