aboutsummaryrefslogtreecommitdiff
path: root/src/configparser.cpp
diff options
context:
space:
mode:
authorGravatar Sadie Powell2022-12-31 18:24:22 +0000
committerGravatar Sadie Powell2022-12-31 18:27:50 +0000
commitb310c28aff053968a601ef6d26925f39fdd6375a (patch)
tree8e4dad790cb495651514f78f078cc8d3a9af9217 /src/configparser.cpp
parentRelease v3.15.0. (diff)
Fix some minor config parser error messages.
- Fix starting the column count for the first line on one instead of zero. This is incremented when reading the first character so starting at 1 causes an off by one error. - Fix showing "last tag was on line ..." message when there is an error before any tags.
Diffstat (limited to 'src/configparser.cpp')
-rw-r--r--src/configparser.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/configparser.cpp b/src/configparser.cpp
index 8a1f78d46..8fe3d082f 100644
--- a/src/configparser.cpp
+++ b/src/configparser.cpp
@@ -59,7 +59,13 @@ struct FilePosition
FilePosition(const std::string& Name)
: name(Name)
, line(1)
- , column(1)
+ , column(0)
+ {
+ }
+
+ FilePosition()
+ : line(0)
+ , column(0)
{
}
@@ -118,7 +124,7 @@ struct Parser
std::string mandatory_tag;
Parser(ParseStack& me, int myflags, FILE* conf, const std::string& name, const std::string& mandatorytag)
- : stack(me), flags(myflags), file(conf), current(name), last_tag(name), ungot(-1), mandatory_tag(mandatorytag)
+ : stack(me), flags(myflags), file(conf), current(name), ungot(-1), mandatory_tag(mandatorytag)
{ }
int next(bool eof_ok = false)
@@ -401,9 +407,10 @@ struct Parser
{
stack.errstr << err.GetReason() << " at " << current.str();
if (tag)
- stack.errstr << " (inside tag " << tag->tag << " at line " << tag->src_line << ")\n";
- else
- stack.errstr << " (last tag was on line " << last_tag.line << ")\n";
+ stack.errstr << " (inside <" << tag->tag << "> tag on line " << tag->src_line << ")";
+ else if (!last_tag.name.empty())
+ stack.errstr << " (last tag was on line " << last_tag.line << ")";
+ stack.errstr << " \n";
}
return false;
}