Skip to content
This repository was archived by the owner on Jan 26, 2024. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions compiler/lib/utils/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -614,25 +614,25 @@ getOptionDesc(std::string& options, size_t StartPos, bool IsShortForm,
return -1;
}

if ((OPTION_type(od) == OT_CSTRING) &&
options.at(pos) == '"') {
if (OPTION_type(od) == OT_CSTRING) {
/* Handle any quoted sections within string value */
size_t sz = options.size();
if ((pos+1) >= sz) {
return -1;
}
/* Handle quoted string value */
ePos = options.find('"', pos+1);
if (ePos == std::string::npos) {
return -1;
bool quoted = false;
ePos = pos;

while (ePos < sz) {
char c = options.at(ePos);
if (c == '"') {
quoted = !quoted;
} else if (c == ' ' && !quoted) {
break;
}
++ePos;
}

/* Advance ePos to the next position or npos */
if (ePos+1 < sz) {
++ePos;
if (options.at(ePos) != ' ') {
return -1;
}
} else {
if (quoted) {
return -1; // closing quote is missing
} else if (ePos == sz) {
ePos = std::string::npos;
}
} else {
Expand Down