Commit 259ff4e2 authored by Teng Qin's avatar Teng Qin

Use StatusTuple constructor in mkstatus_

parent 13ebe8e8
...@@ -37,6 +37,10 @@ public: ...@@ -37,6 +37,10 @@ public:
msg_ = std::string(buf); msg_ = std::string(buf);
} }
void append_msg(const std::string& msg) {
msg_ += msg;
}
int code() { return ret_; } int code() { return ret_; }
std::string msg() { return msg_; } std::string msg() { return msg_; }
......
...@@ -115,19 +115,17 @@ class Node { ...@@ -115,19 +115,17 @@ class Node {
template <typename... Args> template <typename... Args>
StatusTuple mkstatus_(Node *n, const char *fmt, Args... args) { StatusTuple mkstatus_(Node *n, const char *fmt, Args... args) {
char buf[2048]; StatusTuple status = StatusTuple(n->line_ ? n->line_ : -1, fmt, args...);
snprintf(buf, sizeof(buf), fmt, args...);
string out_msg(buf);
if (n->line_ > 0) if (n->line_ > 0)
out_msg += "\n" + n->text_; status.append_msg("\n" + n->text_);
return StatusTuple(n->line_ ? n->line_ : -1, out_msg); return status;
} }
static inline StatusTuple mkstatus_(Node *n, const char *msg) { static inline StatusTuple mkstatus_(Node *n, const char *msg) {
string out_msg(msg); StatusTuple status = StatusTuple(n->line_ ? n->line_ : -1, msg);
if (n->line_ > 0) if (n->line_ > 0)
out_msg += "\n" + n->text_; status.append_msg("\n" + n->text_);
return StatusTuple(n->line_ ? n->line_ : -1, out_msg); return status;
} }
class StmtNode : public Node { class StmtNode : public Node {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment