Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
yaml-cpp
Commits
97fa02a4
Commit
97fa02a4
authored
Jan 11, 2012
by
Jesse Beder
Browse files
Disallowed a plain scalar with just a dash
parent
5024caa6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
3 deletions
+13
-3
src/exp.h
src/exp.h
+1
-1
test/emittertests.cpp
test/emittertests.cpp
+12
-2
No files found.
src/exp.h
View file @
97fa02a4
...
@@ -137,7 +137,7 @@ namespace YAML
...
@@ -137,7 +137,7 @@ namespace YAML
// . In the block context - ? : must be not be followed with a space.
// . In the block context - ? : must be not be followed with a space.
// . In the flow context ? is illegal and : and - must not be followed with a space.
// . In the flow context ? is illegal and : and - must not be followed with a space.
inline
const
RegEx
&
PlainScalar
()
{
inline
const
RegEx
&
PlainScalar
()
{
static
const
RegEx
e
=
!
(
BlankOrBreak
()
||
RegEx
(
",[]{}#&*!|>
\'\"
%@`"
,
REGEX_OR
)
||
(
RegEx
(
"-?:"
,
REGEX_OR
)
+
Blank
(
)));
static
const
RegEx
e
=
!
(
BlankOrBreak
()
||
RegEx
(
",[]{}#&*!|>
\'\"
%@`"
,
REGEX_OR
)
||
(
RegEx
(
"-?:"
,
REGEX_OR
)
+
(
Blank
OrBreak
()
||
RegEx
()
)));
return
e
;
return
e
;
}
}
inline
const
RegEx
&
PlainScalarInFlow
()
{
inline
const
RegEx
&
PlainScalarInFlow
()
{
...
...
test/emittertests.cpp
View file @
97fa02a4
...
@@ -892,7 +892,16 @@ namespace Test
...
@@ -892,7 +892,16 @@ namespace Test
out
<<
YAML
::
EndSeq
;
out
<<
YAML
::
EndSeq
;
desiredOutput
=
"- 1.23
\n
- 3.14159"
;
desiredOutput
=
"- 1.23
\n
- 3.14159"
;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
void
DashInBlockContext
(
YAML
::
Emitter
&
out
,
std
::
string
&
desiredOutput
)
{
out
<<
YAML
::
BeginMap
;
out
<<
YAML
::
Key
<<
"key"
<<
YAML
::
Value
<<
"-"
;
out
<<
YAML
::
EndMap
;
desiredOutput
=
"key:
\"
-
\"
"
;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
// incorrect emitting
// incorrect emitting
void
ExtraEndSeq
(
YAML
::
Emitter
&
out
,
std
::
string
&
desiredError
)
void
ExtraEndSeq
(
YAML
::
Emitter
&
out
,
std
::
string
&
desiredError
)
...
@@ -995,7 +1004,7 @@ namespace Test
...
@@ -995,7 +1004,7 @@ namespace Test
YAML
::
Node
node
;
YAML
::
Node
node
;
parser
.
GetNextDocument
(
node
);
parser
.
GetNextDocument
(
node
);
#else
#else
// Parse with the new API
// YAML::Node node = YAML::Load(output);
#endif
#endif
passed
++
;
passed
++
;
...
@@ -1113,6 +1122,7 @@ namespace Test
...
@@ -1113,6 +1122,7 @@ namespace Test
RunEmitterTest
(
&
Emitter
::
SingleChar
,
"single char"
,
passed
,
total
);
RunEmitterTest
(
&
Emitter
::
SingleChar
,
"single char"
,
passed
,
total
);
RunEmitterTest
(
&
Emitter
::
DefaultPrecision
,
"default precision"
,
passed
,
total
);
RunEmitterTest
(
&
Emitter
::
DefaultPrecision
,
"default precision"
,
passed
,
total
);
RunEmitterTest
(
&
Emitter
::
SetPrecision
,
"set precision"
,
passed
,
total
);
RunEmitterTest
(
&
Emitter
::
SetPrecision
,
"set precision"
,
passed
,
total
);
RunEmitterTest
(
&
Emitter
::
DashInBlockContext
,
"dash in block context"
,
passed
,
total
);
RunEmitterErrorTest
(
&
Emitter
::
ExtraEndSeq
,
"extra EndSeq"
,
passed
,
total
);
RunEmitterErrorTest
(
&
Emitter
::
ExtraEndSeq
,
"extra EndSeq"
,
passed
,
total
);
RunEmitterErrorTest
(
&
Emitter
::
ExtraEndMap
,
"extra EndMap"
,
passed
,
total
);
RunEmitterErrorTest
(
&
Emitter
::
ExtraEndMap
,
"extra EndMap"
,
passed
,
total
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment