Skip to content

Commit

Permalink
Use a fake filename for default syntax file (rather than empty string).
Browse files Browse the repository at this point in the history
This makes error reporting less confusing (in the unlikely case there is
an error in the default syntax file).
  • Loading branch information
skvadrik committed Dec 5, 2023
1 parent 7cee721 commit b63b3d9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/codegen/syntax.cc
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,9 @@ StxFile::~StxFile() {
}

Ret StxFile::read(Lang lang) {
msg.filenames.push_back(fname);

if (fname.empty()) {
msg.filenames.push_back("<default syntax file>");

// use the default syntax config that is provided as a string
const char* src = nullptr;
switch (lang) {
Expand All @@ -380,6 +380,8 @@ Ret StxFile::read(Lang lang) {
memcpy(buf, src, flen);
buf[flen] = 0;
} else {
msg.filenames.push_back(fname);

// use the provided syntax file
file = fopen(fname.c_str(), "rb");
if (!file) RET_FAIL(error("cannot open syntax file '%s'", fname.c_str()));
Expand Down

0 comments on commit b63b3d9

Please sign in to comment.