Merge pull request #1428 from rimmington/clearer-regex-space-error

Clearer error message when regex exceeds space limit
This commit is contained in:
Eelco Dolstra 2017-07-10 11:45:05 +02:00 committed by GitHub
commit 1762b9616c

View file

@ -1734,8 +1734,13 @@ static void prim_match(EvalState & state, const Pos & pos, Value * * args, Value
mkString(*(v.listElems()[i] = state.allocValue()), match[i + 1].str().c_str()); mkString(*(v.listElems()[i] = state.allocValue()), match[i + 1].str().c_str());
} }
} catch (std::regex_error &) { } catch (std::regex_error &e) {
throw EvalError("invalid regular expression %s, at %s", re, pos); if (e.code() == std::regex_constants::error_space) {
// limit is _GLIBCXX_REGEX_STATE_LIMIT for libstdc++
throw EvalError("memory limit exceeded by regular expression %s, at %s", re, pos);
} else {
throw EvalError("invalid regular expression %s, at %s", re, pos);
}
} }
} }