diff options
author | Alexey Samsonov <samsonov@google.com> | 2013-04-05 09:22:24 +0000 |
---|---|---|
committer | Alexey Samsonov <samsonov@google.com> | 2013-04-05 09:22:24 +0000 |
commit | ef148afba873b1e24af1b3c22148f967b9b8a232 (patch) | |
tree | b0532453f4545e67dc4436b595de4dce58f1a102 /tools/llvm-symbolizer | |
parent | 1c4d286f5cf3a13d658a4b1930a5ead12bd59918 (diff) | |
download | external_llvm-ef148afba873b1e24af1b3c22148f967b9b8a232.zip external_llvm-ef148afba873b1e24af1b3c22148f967b9b8a232.tar.gz external_llvm-ef148afba873b1e24af1b3c22148f967b9b8a232.tar.bz2 |
llvm-symbolizer: correctly parse filenames given in quotes
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178859 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-symbolizer')
-rw-r--r-- | tools/llvm-symbolizer/llvm-symbolizer.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/tools/llvm-symbolizer/llvm-symbolizer.cpp b/tools/llvm-symbolizer/llvm-symbolizer.cpp index d039ec6..0cafffa 100644 --- a/tools/llvm-symbolizer/llvm-symbolizer.cpp +++ b/tools/llvm-symbolizer/llvm-symbolizer.cpp @@ -70,12 +70,25 @@ static bool parseCommand(bool &IsData, std::string &ModuleName, // If no cmd, assume it's CODE. IsData = false; } - // FIXME: Handle case when filename is given in quotes. - if (char *FilePath = strtok(pos, kDelimiters)) { - ModuleName = FilePath; - if (char *OffsetStr = strtok((char *)0, kDelimiters)) - ModuleOffsetStr = OffsetStr; + // Skip delimiters and parse input filename. + pos += strspn(pos, kDelimiters); + if (*pos == '"' || *pos == '\'') { + char quote = *pos; + pos++; + char *end = strchr(pos, quote); + if (end == 0) + return false; + ModuleName = std::string(pos, end - pos); + pos = end + 1; + } else { + int name_length = strcspn(pos, kDelimiters); + ModuleName = std::string(pos, name_length); + pos += name_length; } + // Skip delimiters and parse module offset. + pos += strspn(pos, kDelimiters); + int offset_length = strcspn(pos, kDelimiters); + ModuleOffsetStr = std::string(pos, offset_length); if (StringRef(ModuleOffsetStr).getAsInteger(0, ModuleOffset)) return false; return true; |