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
f7358701
Commit
f7358701
authored
Jul 01, 2008
by
Jesse Beder
Browse files
Fixed opening newline bug for block scalars.
parent
4c5a488f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
7 deletions
+10
-7
scanscalar.cpp
scanscalar.cpp
+10
-7
No files found.
scanscalar.cpp
View file @
f7358701
...
@@ -18,7 +18,7 @@ namespace YAML
...
@@ -18,7 +18,7 @@ namespace YAML
// and different places in the above flow.
// and different places in the above flow.
std
::
string
ScanScalar
(
Stream
&
INPUT
,
ScanScalarParams
&
params
)
std
::
string
ScanScalar
(
Stream
&
INPUT
,
ScanScalarParams
&
params
)
{
{
bool
foundNonEmptyLine
=
false
;
bool
foundNonEmptyLine
=
false
,
pastOpeningBreak
=
false
;
bool
emptyLine
=
false
,
moreIndented
=
false
;
bool
emptyLine
=
false
,
moreIndented
=
false
;
std
::
string
scalar
;
std
::
string
scalar
;
params
.
leadingSpaces
=
false
;
params
.
leadingSpaces
=
false
;
...
@@ -39,6 +39,7 @@ namespace YAML
...
@@ -39,6 +39,7 @@ namespace YAML
}
}
foundNonEmptyLine
=
true
;
foundNonEmptyLine
=
true
;
pastOpeningBreak
=
true
;
// escaped newline? (only if we're escaping on slash)
// escaped newline? (only if we're escaping on slash)
if
(
params
.
escape
==
'\\'
&&
Exp
::
EscBreak
.
Matches
(
INPUT
))
{
if
(
params
.
escape
==
'\\'
&&
Exp
::
EscBreak
.
Matches
(
INPUT
))
{
...
@@ -108,15 +109,17 @@ namespace YAML
...
@@ -108,15 +109,17 @@ namespace YAML
bool
nextEmptyLine
=
Exp
::
Break
.
Matches
(
INPUT
);
bool
nextEmptyLine
=
Exp
::
Break
.
Matches
(
INPUT
);
bool
nextMoreIndented
=
(
INPUT
.
peek
()
==
' '
);
bool
nextMoreIndented
=
(
INPUT
.
peek
()
==
' '
);
// TODO: for block scalars, we always start with a newline, so we should fold OR keep that
// for block scalars, we always start with a newline, so we should ignore it (not fold or keep)
if
(
pastOpeningBreak
)
{
if
(
params
.
fold
&&
!
emptyLine
&&
!
nextEmptyLine
&&
!
moreIndented
&&
!
nextMoreIndented
)
if
(
params
.
fold
&&
!
emptyLine
&&
!
nextEmptyLine
&&
!
moreIndented
&&
!
nextMoreIndented
)
scalar
+=
" "
;
scalar
+=
" "
;
else
else
scalar
+=
"
\n
"
;
scalar
+=
"
\n
"
;
}
emptyLine
=
nextEmptyLine
;
emptyLine
=
nextEmptyLine
;
moreIndented
=
nextMoreIndented
;
moreIndented
=
nextMoreIndented
;
pastOpeningBreak
=
true
;
// are we done via indentation?
// are we done via indentation?
if
(
!
emptyLine
&&
INPUT
.
column
<
params
.
indent
)
{
if
(
!
emptyLine
&&
INPUT
.
column
<
params
.
indent
)
{
...
...
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