summaryrefslogtreecommitdiff
path: root/ext/syck/emitter.c
diff options
context:
space:
mode:
authorocean <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-01-16 01:29:58 +0000
committerocean <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-01-16 01:29:58 +0000
commitd54f7b05e8b2e516451fb50c816cec311db570bf (patch)
tree5279446ef37d5edd33566f25c046ce7532ebf1a6 /ext/syck/emitter.c
parent44bf6c8f492cc87d3faf7891bbb8fee989293cf7 (diff)
* ext/syck/emitter.c (syck_emit_seq, syck_emit_map, syck_emit_item):
should output complex key mark even if map's key is empty seq/map. [ruby-core:7129] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9835 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/syck/emitter.c')
-rw-r--r--ext/syck/emitter.c36
1 files changed, 15 insertions, 21 deletions
diff --git a/ext/syck/emitter.c b/ext/syck/emitter.c
index f5de4b841ac..9fe699f9edd 100644
--- a/ext/syck/emitter.c
+++ b/ext/syck/emitter.c
@@ -1003,6 +1003,11 @@ void syck_emit_seq( SyckEmitter *e, char *tag, enum seq_style style )
syck_emitter_write( e, "[", 1 );
lvl->status = syck_lvl_iseq;
} else {
+ /* complex key */
+ if ( parent->status == syck_lvl_map && parent->ncount % 2 == 1 ) {
+ syck_emitter_write( e, "? ", 2 );
+ parent->status = syck_lvl_mapx;
+ }
lvl->status = syck_lvl_seq;
}
}
@@ -1019,6 +1024,11 @@ void syck_emit_map( SyckEmitter *e, char *tag, enum map_style style )
syck_emitter_write( e, "{", 1 );
lvl->status = syck_lvl_imap;
} else {
+ /* complex key */
+ if ( parent->status == syck_lvl_map && parent->ncount % 2 == 1 ) {
+ syck_emitter_write( e, "? ", 2 );
+ parent->status = syck_lvl_mapx;
+ }
lvl->status = syck_lvl_map;
}
}
@@ -1036,18 +1046,11 @@ void syck_emit_item( SyckEmitter *e, st_data_t n )
{
SyckLevel *parent = syck_emitter_parent_level( e );
- /* seq-in-map shortcut */
- if ( parent->status == syck_lvl_map && lvl->ncount == 0 ) {
- /* complex key */
- if ( parent->ncount % 2 == 1 ) {
- syck_emitter_write( e, "?", 1 );
- parent->status = syck_lvl_mapx;
- /* shortcut -- the lvl->anctag check should be unneccesary but
- * there is a nasty shift/reduce in the parser on this point and
- * i'm not ready to tickle it. */
- } else if ( lvl->anctag == 0 ) {
- lvl->spaces = parent->spaces;
- }
+ /* seq-in-map shortcut -- the lvl->anctag check should be unneccesary but
+ * there is a nasty shift/reduce in the parser on this point and
+ * i'm not ready to tickle it. */
+ if ( lvl->anctag == 0 && parent->status == syck_lvl_map && lvl->ncount == 0 ) {
+ lvl->spaces = parent->spaces;
}
/* seq-in-seq shortcut */
@@ -1080,15 +1083,6 @@ void syck_emit_item( SyckEmitter *e, st_data_t n )
{
SyckLevel *parent = syck_emitter_parent_level( e );
- /* map-in-map */
- if ( parent->status == syck_lvl_map && lvl->ncount == 0 ) {
- /* complex key */
- if ( parent->ncount % 2 == 1 ) {
- syck_emitter_write( e, "?", 1 );
- parent->status = syck_lvl_mapx;
- }
- }
-
/* map-in-seq shortcut */
if ( lvl->anctag == 0 && parent->status == syck_lvl_seq && lvl->ncount == 0 ) {
int spcs = ( lvl->spaces - parent->spaces ) - 2;