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
36fd93a8
Commit
36fd93a8
authored
Jan 10, 2016
by
Jesse Beder
Browse files
Fix formatting when writing " as a character.
parent
97d56c3f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
2 deletions
+12
-2
src/emitterutils.cpp
src/emitterutils.cpp
+4
-2
test/integration/emitter_test.cpp
test/integration/emitter_test.cpp
+8
-0
No files found.
src/emitterutils.cpp
View file @
36fd93a8
...
...
@@ -375,14 +375,16 @@ bool WriteLiteralString(ostream_wrapper& out, const std::string& str,
bool
WriteChar
(
ostream_wrapper
&
out
,
char
ch
)
{
if
((
'a'
<=
ch
&&
ch
<=
'z'
)
||
(
'A'
<=
ch
&&
ch
<=
'Z'
))
{
out
<<
ch
;
}
else
if
(
(
0x20
<=
ch
&&
ch
<=
0x7e
)
||
ch
==
'
'
)
{
out
<<
"
\"
"
<<
ch
<<
"
\"
"
;
}
else
if
(
ch
==
'
\"
'
)
{
out
<<
"
\"
\\\
"\"
"
;
}
else
if
(
ch
==
'\t'
)
{
out
<<
"
\"\\
t
\"
"
;
}
else
if
(
ch
==
'\n'
)
{
out
<<
"
\"\\
n
\"
"
;
}
else
if
(
ch
==
'\b'
)
{
out
<<
"
\"\\
b
\"
"
;
}
else
if
((
0x20
<=
ch
&&
ch
<=
0x7e
)
||
ch
==
' '
)
{
out
<<
"
\"
"
<<
ch
<<
"
\"
"
;
}
else
{
out
<<
"
\"
"
;
WriteDoubleQuoteEscapeSequence
(
out
,
ch
);
...
...
test/integration/emitter_test.cpp
View file @
36fd93a8
...
...
@@ -962,6 +962,14 @@ TEST_F(EmitterTest, QuoteNull) {
ExpectEmit
(
"
\"
null
\"
"
);
}
TEST_F
(
EmitterTest
,
ValueOfDoubleQuote
)
{
out
<<
YAML
::
BeginMap
;
out
<<
YAML
::
Key
<<
"foo"
<<
YAML
::
Value
<<
'"'
;
out
<<
YAML
::
EndMap
;
ExpectEmit
(
"foo:
\"\\\"\"
"
);
}
class
EmitterErrorTest
:
public
::
testing
::
Test
{
protected:
void
ExpectEmitError
(
const
std
::
string
&
expectedError
)
{
...
...
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