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
This commit is contained in:
Alexey Samsonov
2013-04-05 09:22:24 +00:00
parent 1c4d286f5c
commit ef148afba8
4 changed files with 26 additions and 9 deletions

View File

@ -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;