mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 12:41:17 +00:00
Refactor plain scalar validation in the emitter to precompute the invalid regexes
This commit is contained in:
@@ -175,11 +175,17 @@ bool IsValidPlainScalar(const std::string& str, FlowType::value flowType,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// then check until something is disallowed
|
// then check until something is disallowed
|
||||||
const RegEx& disallowed = (flowType == FlowType::Flow ? Exp::EndScalarInFlow()
|
static const RegEx& disallowed_flow =
|
||||||
: Exp::EndScalar()) ||
|
Exp::EndScalarInFlow() || (Exp::BlankOrBreak() + Exp::Comment()) ||
|
||||||
(Exp::BlankOrBreak() + Exp::Comment()) ||
|
Exp::NotPrintable() || Exp::Utf8_ByteOrderMark() || Exp::Break() ||
|
||||||
Exp::NotPrintable() || Exp::Utf8_ByteOrderMark() ||
|
Exp::Tab();
|
||||||
Exp::Break() || Exp::Tab();
|
static const RegEx& disallowed_block =
|
||||||
|
Exp::EndScalar() || (Exp::BlankOrBreak() + Exp::Comment()) ||
|
||||||
|
Exp::NotPrintable() || Exp::Utf8_ByteOrderMark() || Exp::Break() ||
|
||||||
|
Exp::Tab();
|
||||||
|
const RegEx& disallowed =
|
||||||
|
flowType == FlowType::Flow ? disallowed_flow : disallowed_block;
|
||||||
|
|
||||||
StringCharSource buffer(str.c_str(), str.size());
|
StringCharSource buffer(str.c_str(), str.size());
|
||||||
while (buffer) {
|
while (buffer) {
|
||||||
if (disallowed.Matches(buffer)) {
|
if (disallowed.Matches(buffer)) {
|
||||||
|
Reference in New Issue
Block a user