[#7055] More on VC++ 2005 — Austin Ziegler <halostatue@...>

Okay. I've got Ruby compiling. I'm attempting to get everything in

17 messages 2006/01/05
[#7058] Re: More on VC++ 2005 — nobuyoshi nakada <nobuyoshi.nakada@...> 2006/01/06

Hi,

[#7084] mathn: ugly warnings — hadmut@... (Hadmut Danisch)

Hi,

22 messages 2006/01/10
[#7097] Re: mathn: ugly warnings — Daniel Berger <Daniel.Berger@...> 2006/01/10

Hadmut Danisch wrote:

[#7098] Design contracts and refactoring (was Re: mathn: ugly warnings) — mathew <meta@...> 2006/01/10

Daniel Berger wrote:

[#7118] Re: Design contracts and refactoring (was Re: mathn: ugly warnings) — mathew <meta@...> 2006/01/12

*Dean Wampler *<deanwampler gmail.com> writes:

[#7226] Fwd: Re: Question about massive API changes — "Sean E. Russell" <ser@...>

Hello,

23 messages 2006/01/28
[#7228] Re: Question about massive API changes — Caleb Tennis <caleb@...> 2006/01/28

>

Re: YAML.load({[]=>""}.to_yaml)

From: "H.Yamamoto" <ocean@...2.ccsnet.ne.jp>
Date: 2006-01-15 11:22:16 UTC
List: ruby-core #7154
Hi.

>>I found that current YAML doesn't round trip {[]=>""}.
>>
>>% ./ruby -v -ryaml -e 'p YAML.load({[]=>""}.to_yaml)'
>>ruby 1.9.0 (2006-01-10) [i686-linux]
>>/home/akr/ruby/lib/ruby/1.9/yaml.rb:133:in `load': syntax error on line 2, col 1: `: ""' (ArgumentError)
>>        from /home/akr/ruby/lib/ruby/1.9/yaml.rb:133:in `load'
>>        from -e:1
>>
>>ruby-1.8.2 works well.
>>
>>% ruby-1.8.2 -v -ryaml -e 'p YAML.load({[]=>""}.to_yaml)' 
>>ruby 1.8.2 (2004-12-25) [i686-linux]
>>{[]=>""}
>>-- 
>>Tanaka Akira
>
>
>E:\>ruby -v -ryaml -e "puts YAML.dump({[]=>''})"
>ruby 1.8.4 (2005-12-24) [i386-bccwin32]
>---
>[]
>: ""
>
>
>This YAML cannot be loaded. But
>
>---
>? []
>: ""
>
>can be loaded. (I don't know how to fix it... tell the syck [] is complex key?)


How about this? Function name is a bit long though.


Index: emitter.c
===================================================================
RCS file: /src/ruby/ext/syck/emitter.c,v
retrieving revision 1.14
diff -u -w -b -p -r1.14 emitter.c
--- emitter.c	20 Sep 2005 06:50:19 -0000	1.14
+++ emitter.c	15 Jan 2006 11:13:58 -0000
@@ -992,6 +992,17 @@ void syck_emit_folded( SyckEmitter *e, i
 }
 
 /*
+ * Emit complex key mark if neccessaly.
+ */
+static void syck_emit_complex_key_mark_if_needed( SyckEmitter *e, SyckLevel *parent )
+{
+    if ( parent->status == syck_lvl_map && parent->ncount % 2 == 1 ) {
+        syck_emitter_write( e, "? ", 2 );
+        parent->status = syck_lvl_mapx;
+    }
+}
+
+/*
  * Begins emission of a sequence.
  */
 void syck_emit_seq( SyckEmitter *e, char *tag, enum seq_style style )
@@ -1003,6 +1014,7 @@ void syck_emit_seq( SyckEmitter *e, char
         syck_emitter_write( e, "[", 1 );
         lvl->status = syck_lvl_iseq;
     } else {
+        syck_emit_complex_key_mark_if_needed( e, parent );
         lvl->status = syck_lvl_seq;
     }
 }
@@ -1019,6 +1031,7 @@ void syck_emit_map( SyckEmitter *e, char
         syck_emitter_write( e, "{", 1 );
         lvl->status = syck_lvl_imap;
     } else {
+        syck_emit_complex_key_mark_if_needed( e, parent );
         lvl->status = syck_lvl_map;
     }
 }
@@ -1036,19 +1049,12 @@ void syck_emit_item( SyckEmitter *e, st_
         {
             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
+            /* 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. */
-                } else if ( lvl->anctag == 0 ) { 
+            if ( lvl->anctag == 0 && parent->status == syck_lvl_map && lvl->ncount == 0 ) {
                     lvl->spaces = parent->spaces;
                 }
-            }
 
             /* seq-in-seq shortcut */
             else if ( lvl->anctag == 0 && parent->status == syck_lvl_seq && lvl->ncount == 0 ) {
@@ -1080,15 +1086,6 @@ void syck_emit_item( SyckEmitter *e, st_
         {
             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;


In This Thread