diff options
author | Jérôme Vouillon <jerome.vouillon@gmail.com> | 2024-05-15 15:32:08 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-15 12:32:08 -0700 |
commit | b70d8dff27ccea2d4546909dba83bf8cae072aba (patch) | |
tree | a76b4ead18f3cae141775870cb8b6018918e5df0 /src/parser/contexts.h | |
parent | 6b43a5ef76149c92e216fddb0a1ee17f736b4b6e (diff) | |
download | binaryen-b70d8dff27ccea2d4546909dba83bf8cae072aba.tar.gz binaryen-b70d8dff27ccea2d4546909dba83bf8cae072aba.tar.bz2 binaryen-b70d8dff27ccea2d4546909dba83bf8cae072aba.zip |
Debug location parser: accept arbitrary paths (#6594)
The whole annotation was parsed as a keyword, which prevented file paths with non-ascii characters or paths starting with `/` or `.`.
Also, there was a typo: one was comparing `fileSize` rather than `lineSize` to `contents->npos`.
Diffstat (limited to 'src/parser/contexts.h')
-rw-r--r-- | src/parser/contexts.h | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/src/parser/contexts.h b/src/parser/contexts.h index 2243c6065..5ad0c16de 100644 --- a/src/parser/contexts.h +++ b/src/parser/contexts.h @@ -1719,30 +1719,29 @@ struct ParseDefsCtx : TypeParserCtx<ParseDefsCtx> { return; } - auto contents = lexer.takeKeyword(); - if (!contents || !lexer.empty()) { - return; - } + auto contents = lexer.next(); - auto fileSize = contents->find(':'); - if (fileSize == contents->npos) { + auto fileSize = contents.find(':'); + if (fileSize == 0 || fileSize == contents.npos) { return; } - auto file = contents->substr(0, fileSize); - contents = contents->substr(fileSize + 1); + auto file = contents.substr(0, fileSize); + contents = contents.substr(fileSize + 1); - auto lineSize = contents->find(':'); - if (fileSize == contents->npos) { + auto lineSize = contents.find(':'); + if (lineSize == contents.npos) { return; } - auto line = Lexer(contents->substr(0, lineSize)).takeU32(); - if (!line) { + lexer = Lexer(contents.substr(0, lineSize)); + auto line = lexer.takeU32(); + if (!line || !lexer.empty()) { return; } - contents = contents->substr(lineSize + 1); + contents = contents.substr(lineSize + 1); - auto col = Lexer(*contents).takeU32(); - if (!col) { + lexer = Lexer(contents); + auto col = lexer.takeU32(); + if (!col || !lexer.empty()) { return; } |