From b70d8dff27ccea2d4546909dba83bf8cae072aba Mon Sep 17 00:00:00 2001 From: Jérôme Vouillon Date: Wed, 15 May 2024 15:32:08 -0400 Subject: 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`. --- src/parser/contexts.h | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'src/parser/contexts.h') 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 { 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; } -- cgit v1.2.3