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
2aab5aca
Commit
2aab5aca
authored
Sep 07, 2009
by
Jesse Beder
Browse files
Fixed last newline of folded scalar bug
parent
e9d760ee
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
10 deletions
+6
-10
src/scanscalar.cpp
src/scanscalar.cpp
+2
-7
src/scantoken.cpp
src/scantoken.cpp
+1
-0
yaml-reader/spectests.cpp
yaml-reader/spectests.cpp
+3
-3
No files found.
src/scanscalar.cpp
View file @
2aab5aca
...
@@ -111,13 +111,8 @@ namespace YAML
...
@@ -111,13 +111,8 @@ namespace YAML
bool
nextMoreIndented
=
(
INPUT
.
peek
()
==
' '
);
bool
nextMoreIndented
=
(
INPUT
.
peek
()
==
' '
);
// for block scalars, we always start with a newline, so we should ignore it (not fold or keep)
// for block scalars, we always start with a newline, so we should ignore it (not fold or keep)
bool
useNewLine
=
pastOpeningBreak
;
if
(
pastOpeningBreak
)
{
// and for folded scalars, we don't fold the very last newline to a space
if
(
params
.
fold
&&
!
emptyLine
&&
!
nextEmptyLine
&&
!
moreIndented
&&
!
nextMoreIndented
&&
INPUT
.
column
()
>=
params
.
indent
)
if
(
params
.
fold
&&
!
emptyLine
&&
INPUT
.
column
()
<
params
.
indent
)
useNewLine
=
false
;
if
(
useNewLine
)
{
if
(
params
.
fold
&&
!
emptyLine
&&
!
nextEmptyLine
&&
!
moreIndented
&&
!
nextMoreIndented
)
scalar
+=
" "
;
scalar
+=
" "
;
else
else
scalar
+=
"
\n
"
;
scalar
+=
"
\n
"
;
...
...
src/scantoken.cpp
View file @
2aab5aca
...
@@ -368,6 +368,7 @@ namespace YAML
...
@@ -368,6 +368,7 @@ namespace YAML
params
.
fold
=
(
indicator
==
Keys
::
FoldedScalar
);
params
.
fold
=
(
indicator
==
Keys
::
FoldedScalar
);
// eat chomping/indentation indicators
// eat chomping/indentation indicators
params
.
chomp
=
CLIP
;
int
n
=
Exp
::
Chomp
.
Match
(
INPUT
);
int
n
=
Exp
::
Chomp
.
Match
(
INPUT
);
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
char
ch
=
INPUT
.
get
();
char
ch
=
INPUT
.
get
();
...
...
yaml-reader/spectests.cpp
View file @
2aab5aca
...
@@ -446,7 +446,7 @@ namespace Test {
...
@@ -446,7 +446,7 @@ namespace Test {
" home run record in 1998.
\n
"
" home run record in 1998.
\n
"
"stats: |
\n
"
"stats: |
\n
"
" 65 Home Runs
\n
"
" 65 Home Runs
\n
"
" 0.278 Batting Average"
;
" 0.278 Batting Average
\n
"
;
std
::
stringstream
stream
(
input
);
std
::
stringstream
stream
(
input
);
YAML
::
Parser
parser
(
stream
);
YAML
::
Parser
parser
(
stream
);
YAML
::
Node
doc
;
YAML
::
Node
doc
;
...
@@ -454,8 +454,8 @@ namespace Test {
...
@@ -454,8 +454,8 @@ namespace Test {
YAML_ASSERT
(
doc
.
size
()
==
3
);
YAML_ASSERT
(
doc
.
size
()
==
3
);
YAML_ASSERT
(
doc
[
"name"
]
==
"Mark McGwire"
);
YAML_ASSERT
(
doc
[
"name"
]
==
"Mark McGwire"
);
YAML_ASSERT
(
doc
[
"accomplishment"
]
==
"Mark set a major league home run record in 1998."
);
YAML_ASSERT
(
doc
[
"accomplishment"
]
==
"Mark set a major league home run record in 1998.
\n
"
);
YAML_ASSERT
(
doc
[
"stats"
]
==
"65 Home Runs
\n
0.278 Batting Average"
);
YAML_ASSERT
(
doc
[
"stats"
]
==
"65 Home Runs
\n
0.278 Batting Average
\n
"
);
return
true
;
return
true
;
}
}
...
...
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