Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yaml-cpp
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
yaml-cpp
Commits
e3ff87ec
Commit
e3ff87ec
authored
Sep 07, 2009
by
Jesse Beder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bugs in escape characters (both parsing and emitting)
parent
45ac700f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
4 deletions
+46
-4
src/emitterutils.cpp
+1
-1
src/exp.cpp
+4
-3
yaml-reader/spectests.cpp
+41
-0
No files found.
src/emitterutils.cpp
View file @
e3ff87ec
...
@@ -83,7 +83,7 @@ namespace YAML
...
@@ -83,7 +83,7 @@ namespace YAML
}
else
{
}
else
{
// TODO: for the common escaped characters, give their usual symbol
// TODO: for the common escaped characters, give their usual symbol
std
::
stringstream
str
;
std
::
stringstream
str
;
str
<<
"
\\
x"
<<
std
::
hex
<<
std
::
setfill
(
'0'
)
<<
std
::
setw
(
2
)
<<
static_cast
<
int
>
(
ch
);
str
<<
"
\\
x"
<<
std
::
hex
<<
std
::
setfill
(
'0'
)
<<
std
::
setw
(
2
)
<<
static_cast
<
unsigned
int
>
(
static_cast
<
unsigned
char
>
(
ch
)
);
out
<<
str
.
str
();
out
<<
str
.
str
();
}
}
}
}
...
...
src/exp.cpp
View file @
e3ff87ec
...
@@ -83,7 +83,7 @@ namespace YAML
...
@@ -83,7 +83,7 @@ namespace YAML
// now do the slash (we're not gonna check if it's a slash - you better pass one!)
// now do the slash (we're not gonna check if it's a slash - you better pass one!)
switch
(
ch
)
{
switch
(
ch
)
{
case
'0'
:
return
"
\0
"
;
case
'0'
:
return
std
::
string
(
"
\x00
"
,
1
)
;
case
'a'
:
return
"
\x07
"
;
case
'a'
:
return
"
\x07
"
;
case
'b'
:
return
"
\x08
"
;
case
'b'
:
return
"
\x08
"
;
case
't'
:
case
't'
:
...
@@ -97,8 +97,9 @@ namespace YAML
...
@@ -97,8 +97,9 @@ namespace YAML
case
'\"'
:
return
"
\"
"
;
case
'\"'
:
return
"
\"
"
;
case
'\''
:
return
"
\'
"
;
case
'\''
:
return
"
\'
"
;
case
'\\'
:
return
"
\\
"
;
case
'\\'
:
return
"
\\
"
;
case
'N'
:
return
"
\xC2\x85
"
;
// NEL (#x85)
case
'/'
:
return
"/"
;
case
'_'
:
return
"
\xC2\xA0
"
;
// #xA0
case
'N'
:
return
"
\x85
"
;
case
'_'
:
return
"
\xA0
"
;
case
'L'
:
return
"
\xE2\x80\xA8
"
;
// LS (#x2028)
case
'L'
:
return
"
\xE2\x80\xA8
"
;
// LS (#x2028)
case
'P'
:
return
"
\xE2\x80\xA9
"
;
// PS (#x2029)
case
'P'
:
return
"
\xE2\x80\xA9
"
;
// PS (#x2029)
case
'x'
:
return
Escape
(
in
,
2
);
case
'x'
:
return
Escape
(
in
,
2
);
...
...
yaml-reader/spectests.cpp
View file @
e3ff87ec
...
@@ -793,6 +793,45 @@ namespace Test {
...
@@ -793,6 +793,45 @@ namespace Test {
"}"
);
"}"
);
return
true
;
return
true
;
}
}
// 5.13
TEST
EscapedCharacters
()
{
std
::
string
input
=
"
\"
Fun with
\\\\\n
"
"
\\\"
\\
a
\\
b
\\
e
\\
f
\\\n
"
"
\\
n
\\
r
\\
t
\\
v
\\
0
\\\n
"
"
\\
\\
_
\\
N
\\
L
\\
P
\\\n
"
"
\\
x41
\\
u0041
\\
U00000041
\"
"
;
std
::
stringstream
stream
(
input
);
YAML
::
Parser
parser
(
stream
);
YAML
::
Node
doc
;
parser
.
GetNextDocument
(
doc
);
YAML_ASSERT
(
doc
==
"Fun with
\x5C
\x22
\x07
\x08
\x1B
\x0C
\x0A
\x0D
\x09
\x0B
"
+
std
::
string
(
"
\x00
"
,
1
)
+
"
\x20
\xA0
\x85
\u2028 \u2029 A A A"
);
return
true
;
}
// 5.14
TEST
InvalidEscapedCharacters
()
{
std
::
string
input
=
"Bad escapes:
\n
"
"
\"\\
c
\n
"
"
\\
xq-
\"
"
;
std
::
stringstream
stream
(
input
);
try
{
YAML
::
Parser
parser
(
stream
);
YAML
::
Node
doc
;
parser
.
GetNextDocument
(
doc
);
}
catch
(
const
YAML
::
ParserException
&
e
)
{
YAML_ASSERT
(
e
.
msg
==
YAML
::
ErrorMsg
::
INVALID_ESCAPE
+
"c"
);
return
true
;
}
return
false
;
}
}
}
bool
RunSpecTests
()
bool
RunSpecTests
()
...
@@ -827,6 +866,8 @@ namespace Test {
...
@@ -827,6 +866,8 @@ namespace Test {
RunSpecTest
(
&
Spec
::
QuotedScalarIndicators
,
"5.8"
,
"Quoted Scalar Indicators"
,
passed
);
RunSpecTest
(
&
Spec
::
QuotedScalarIndicators
,
"5.8"
,
"Quoted Scalar Indicators"
,
passed
);
RunSpecTest
(
&
Spec
::
LineBreakCharacters
,
"5.11"
,
"Line Break Characters"
,
passed
);
RunSpecTest
(
&
Spec
::
LineBreakCharacters
,
"5.11"
,
"Line Break Characters"
,
passed
);
RunSpecTest
(
&
Spec
::
TabsAndSpaces
,
"5.12"
,
"Tabs and Spaces"
,
passed
);
RunSpecTest
(
&
Spec
::
TabsAndSpaces
,
"5.12"
,
"Tabs and Spaces"
,
passed
);
RunSpecTest
(
&
Spec
::
EscapedCharacters
,
"5.13"
,
"Escaped Characters"
,
passed
);
RunSpecTest
(
&
Spec
::
InvalidEscapedCharacters
,
"5.14"
,
"Invalid Escaped Characters"
,
passed
);
return
passed
;
return
passed
;
}
}
...
...
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