mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 12:41:17 +00:00
Forced a newline after any comments
This commit is contained in:
@@ -186,6 +186,7 @@ namespace YAML
|
||||
case ES_WRITING_FLOW_SEQ_ENTRY:
|
||||
return true;
|
||||
case ES_DONE_WITH_FLOW_SEQ_ENTRY:
|
||||
EmitSeparationIfNecessary();
|
||||
m_stream << ',';
|
||||
m_pState->RequireSoftSeparation();
|
||||
m_pState->SwitchState(ES_WAITING_FOR_FLOW_SEQ_ENTRY);
|
||||
@@ -221,9 +222,9 @@ namespace YAML
|
||||
m_pState->SetError(ErrorMsg::EXPECTED_KEY_TOKEN);
|
||||
return true;
|
||||
case ES_WAITING_FOR_FLOW_MAP_KEY:
|
||||
EmitSeparationIfNecessary();
|
||||
m_pState->SwitchState(ES_WRITING_FLOW_MAP_KEY);
|
||||
if(m_pState->CurrentlyInLongKey()) {
|
||||
EmitSeparationIfNecessary();
|
||||
m_stream << '?';
|
||||
m_pState->RequireSoftSeparation();
|
||||
}
|
||||
@@ -234,6 +235,7 @@ namespace YAML
|
||||
m_pState->SetError(ErrorMsg::EXPECTED_VALUE_TOKEN);
|
||||
return true;
|
||||
case ES_WAITING_FOR_FLOW_MAP_VALUE:
|
||||
EmitSeparationIfNecessary();
|
||||
m_stream << ':';
|
||||
m_pState->RequireSoftSeparation();
|
||||
m_pState->SwitchState(ES_WRITING_FLOW_MAP_VALUE);
|
||||
@@ -496,6 +498,7 @@ namespace YAML
|
||||
} else if(flowType == FT_FLOW) {
|
||||
// Note: flow maps are allowed to be empty
|
||||
assert(curState == ES_DONE_WITH_FLOW_MAP_VALUE || curState == ES_WAITING_FOR_FLOW_MAP_ENTRY);
|
||||
EmitSeparationIfNecessary();
|
||||
m_stream << "}";
|
||||
} else
|
||||
assert(false);
|
||||
@@ -526,6 +529,7 @@ namespace YAML
|
||||
m_pState->UnsetSeparation();
|
||||
m_pState->SwitchState(ES_WAITING_FOR_BLOCK_MAP_KEY);
|
||||
} else if(flowType == FT_FLOW) {
|
||||
EmitSeparationIfNecessary();
|
||||
if(curState == ES_DONE_WITH_FLOW_MAP_VALUE) {
|
||||
m_stream << ',';
|
||||
m_pState->RequireSoftSeparation();
|
||||
@@ -796,8 +800,12 @@ namespace YAML
|
||||
if(!good())
|
||||
return *this;
|
||||
|
||||
m_stream << Indentation(m_pState->GetPreCommentIndent());
|
||||
if(m_stream.col() > 0)
|
||||
m_stream << Indentation(m_pState->GetPreCommentIndent());
|
||||
Utils::WriteComment(m_stream, comment.content, m_pState->GetPostCommentIndent());
|
||||
m_pState->RequireHardSeparation();
|
||||
m_pState->ForceHardSeparation();
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@@ -267,7 +267,7 @@ namespace YAML
|
||||
|
||||
bool WriteComment(ostream& out, const std::string& str, int postCommentIndent)
|
||||
{
|
||||
unsigned curIndent = out.col();
|
||||
const unsigned curIndent = out.col();
|
||||
out << "#" << Indentation(postCommentIndent);
|
||||
int codePoint;
|
||||
for(std::string::const_iterator i = str.begin();
|
||||
|
Reference in New Issue
Block a user