fix bugs in ArgInfo class

This commit is contained in:
Axel Kohlmeyer
2021-07-29 20:57:42 -04:00
parent 6b20da7549
commit cb32bb972b

View File

@ -68,11 +68,11 @@ ArgInfo::ArgInfo(const std::string &arg, int allowed) : type(NONE), dim(0), inde
} else
has_idx2 = arg.size();
if (arg[has_idx2 - 1] != ']') {
if ((arg[has_idx2 - 1] != ']') || ((dim == 1) && (arg.find(']') != has_idx2 - 1))) {
type = UNKNOWN;
} else {
try {
index1 = std::stoi(arg.substr(has_idx1 + 1, arg.size() - (has_idx2 + 2)));
index1 = std::stoi(arg.substr(has_idx1 + 1, arg.size() - (has_idx1 + 2)));
} catch (std::invalid_argument &) {
type = UNKNOWN;
}