From 382f1ba3c7ef77cfb887a70dbcf1e2188c2b1ee7 Mon Sep 17 00:00:00 2001 From: Jesse Beder Date: Thu, 30 Jul 2009 05:54:40 +0000 Subject: [PATCH] Fixed empty scalar in sequence bug --- src/node.cpp | 2 +- src/sequence.cpp | 9 +++++++++ src/token.h | 6 ++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/node.cpp b/src/node.cpp index 5f20e4c..587f4b3 100644 --- a/src/node.cpp +++ b/src/node.cpp @@ -264,7 +264,7 @@ namespace YAML if(node.m_pContent) node.m_pContent->Write(out); else - out << ""; + out << Null; return out; } diff --git a/src/sequence.cpp b/src/sequence.cpp index 65788fd..ad49fe3 100644 --- a/src/sequence.cpp +++ b/src/sequence.cpp @@ -4,6 +4,7 @@ #include "scanner.h" #include "token.h" #include "emitter.h" +#include namespace YAML { @@ -80,6 +81,14 @@ namespace YAML Node *pNode = new Node; m_data.push_back(pNode); + + // check for null + if(!pScanner->empty()) { + const Token& token = pScanner->peek(); + if(token.type == TT_BLOCK_ENTRY || token.type == TT_BLOCK_END) + continue; + } + pNode->Parse(pScanner, state); } } diff --git a/src/token.h b/src/token.h index 3c5fb58..8bddc77 100644 --- a/src/token.h +++ b/src/token.h @@ -30,7 +30,8 @@ namespace YAML TT_ANCHOR, TT_ALIAS, TT_TAG, - TT_SCALAR + TT_SCALAR, + TT_NULL }; const std::string TokenNames[] = { @@ -51,7 +52,8 @@ namespace YAML "ANCHOR", "ALIAS", "TAG", - "SCALAR" + "SCALAR", + "NULL" }; struct Token {