[#19075] Request For Removal: No Operator Concatenation — James Gray <james@...>

I'm disappointed that Ruby still supports this goofy syntax:

30 messages 2008/10/01
[#19076] Re: Request For Removal: No Operator Concatenation — "Gregory Brown" <gregory.t.brown@...> 2008/10/01

On Wed, Oct 1, 2008 at 1:58 PM, James Gray <james@grayproductions.net> wrote:

[#19078] Re: Request For Removal: No Operator Concatenation — "Jim Freeze" <jimfreeze@...> 2008/10/01

On Wed, Oct 1, 2008 at 1:08 PM, Gregory Brown <gregory.t.brown@gmail.com> wrote:

[#19080] Re: Request For Removal: No Operator Concatenation — James Gray <james@...> 2008/10/01

On Oct 1, 2008, at 1:15 PM, Jim Freeze wrote:

[#19081] Re: Request For Removal: No Operator Concatenation — "Jim Freeze" <jimfreeze@...> 2008/10/01

On Wed, Oct 1, 2008 at 1:29 PM, James Gray <james@grayproductions.net> wrote:

[#19082] Re: Request For Removal: No Operator Concatenation — James Gray <james@...> 2008/10/01

On Oct 1, 2008, at 1:37 PM, Jim Freeze wrote:

[#19083] Re: Request For Removal: No Operator Concatenation — Eric Hodel <drbrain@...7.net> 2008/10/01

On Oct 1, 2008, at 11:42 AM, James Gray wrote:

[#19084] Re: Request For Removal: No Operator Concatenation — "Gregory Brown" <gregory.t.brown@...> 2008/10/01

On Wed, Oct 1, 2008 at 2:45 PM, Eric Hodel <drbrain@segment7.net> wrote:

[#19087] Re: Request For Removal: No Operator Concatenation — "Jim Freeze" <jimfreeze@...> 2008/10/01

On Wed, Oct 1, 2008 at 2:10 PM, Gregory Brown <gregory.t.brown@gmail.com> wrote:

[#19132] [Feature #615] "with" operator — Lavir the Whiolet <redmine@...>

Feature #615: "with" operator

33 messages 2008/10/05
[#19137] Re: [Feature #615] "with" operator — Nobuyoshi Nakada <nobu@...> 2008/10/06

Hi,

[#19138] Re: [Feature #615] "with" operator — Paul Brannan <pbrannan@...> 2008/10/06

On Mon, Oct 06, 2008 at 10:46:49AM +0900, Nobuyoshi Nakada wrote:

[#19141] Re: [Feature #615] "with" operator — _why <why@...> 2008/10/06

On Mon, Oct 06, 2008 at 10:56:23PM +0900, Paul Brannan wrote:

[#19148] Re: [Feature #615] "with" operator — Trans <transfire@...> 2008/10/06

[#19149] Re: [Feature #615] "with" operator — "Austin Ziegler" <halostatue@...> 2008/10/06

On Mon, Oct 6, 2008 at 3:34 PM, Trans <transfire@gmail.com> wrote:

[#19150] Re: [Feature #615] "with" operator — "David A. Black" <dblack@...> 2008/10/06

Hi --

[#19154] Re: [Feature #615] "with" operator — _why <why@...> 2008/10/07

On Tue, Oct 07, 2008 at 05:47:23AM +0900, David A. Black wrote:

[#19250] default_internal encoding — Dave Thomas <dave@...>

I'm documenting default_internal for the PickAxe, and have a couple of

26 messages 2008/10/09
[#19254] Re: default_internal encoding — "Michael Selig" <michael.selig@...> 2008/10/09

Hi,

[#19255] Re: performance of C function calls in 1.8 vs 1.9 — "Michael Selig" <michael.selig@...> 2008/10/10

On Wed, Oct 8, 2008 at 3:52 PM, Paul Brannan <pbrannan / atdesk.com> wrote:

[#19289] [Bug #633] dl segfaults on x86_64-linux systems — Benjamin Floering <redmine@...>

Bug #633: dl segfaults on x86_64-linux systems

19 messages 2008/10/10

[#19315] [Feature #643] __DIR__ — Thomas Sawyer <redmine@...>

Feature #643: __DIR__

14 messages 2008/10/13

[#19342] [Bug #649] Memory leak in a array assignment? — Henri Suur-Inkeroinen <redmine@...>

Bug #649: Memory leak in a array assignment?

14 messages 2008/10/15

[#19350] Net::HTTP.post_form bug : can't post form to correct uri which contains QueryString(QueryString part are lost) and revise — Klesh <kleshwong@...>

Hi,

10 messages 2008/10/16
[#19352] Re: Net::HTTP.post_form bug : can't post form to correct uri which contains QueryString(QueryString part are lost) and revise — "Matt Todd" <chiology@...> 2008/10/16

You are trying to use GET-style query params instead of POSTing the

[#19378] Constant names in 1.9 — Dave Thomas <dave@...>

When Ruby makes the tIDENTIFIER/tCONSTANT test, it looks to see if the =20=

13 messages 2008/10/18

[#19397] [Feature #666] Enumerable::to_hash — Marc-Andre Lafortune <redmine@...>

Feature #666: Enumerable::to_hash

14 messages 2008/10/20
[#23249] [Feature #666](Rejected) Enumerable::to_hash — Yukihiro Matsumoto <redmine@...> 2009/04/18

Issue #666 has been updated by Yukihiro Matsumoto.

[#19422] Now that lambda has more powerful arguments... — Dave Thomas <dave@...>

is there anything that

24 messages 2008/10/21
[#19423] Re: Now that lambda has more powerful arguments... — Wolfgang N疆asi-Donner <ed.odanow@...> 2008/10/21

Dave Thomas schrieb:

[#19424] Re: Now that lambda has more powerful arguments... — Dave Thomas <dave@...> 2008/10/21

[#19427] Re: Now that lambda has more powerful arguments... — Paul Brannan <pbrannan@...> 2008/10/21

On Wed, Oct 22, 2008 at 04:01:45AM +0900, Dave Thomas wrote:

[#19429] Re: Now that lambda has more powerful arguments... — "David A. Black" <dblack@...> 2008/10/21

Hi --

[#19430] Re: Now that lambda has more powerful arguments... — Paul Brannan <pbrannan@...> 2008/10/21

On Wed, Oct 22, 2008 at 04:38:19AM +0900, David A. Black wrote:

[#19431] Re: Now that lambda has more powerful arguments... — "David A. Black" <dblack@...> 2008/10/21

Hi --

[#19432] Re: Now that lambda has more powerful arguments... — Jim Weirich <jim.weirich@...> 2008/10/21

On Oct 21, 2008, at 4:24 PM, David A. Black wrote:

[#19465] [Bug #680] csv.rb: CSV.parse is too late when encoding is mismatch — Takeyuki Fujioka <redmine@...>

Bug #680: csv.rb: CSV.parse is too late when encoding is mismatch

41 messages 2008/10/24
[#19466] Default source encoding (Was: [Bug #680] csv.rb: CSV.parse is too late when encoding is mismatch) — "Michael Selig" <michael.selig@...> 2008/10/24

Hi,

[#19471] Re: Default source encoding (Was: [Bug #680] csv.rb: CSV.parse is toolate when encoding is mismatch) — Martin Duerst <duerst@...> 2008/10/24

A default for the source encoding has been discussed quite a long

[#19473] Re: Default source encoding (Was: [Bug #680] csv.rb: CSV.parse is toolate when encoding is mismatch) — "Michael Selig" <michael.selig@...> 2008/10/24

Hi,

[#19474] Re: Default source encoding (Was: [Bug #680] csv.rb: CSV.parse is toolate when encoding is mismatch) — Yukihiro Matsumoto <matz@...> 2008/10/24

Hi,

[#19515] String literal encoding (Was: Default source encoding (Was: [Bug #680] csv.rb: CSV.parse is toolate when encoding is mismatch)) — "Michael Selig" <michael.selig@...> 2008/10/26

Hi,

[#19517] Re: String literal encoding (Was: Default source encoding (Was: [Bug #680] csv.rb: CSV.parse is toolate when encoding is mismatch)) — Nobuyoshi Nakada <nobu@...> 2008/10/26

Hi,

[#19518] Re: String literal encoding (Was: Default source encoding (Was: [Bug #680] csv.rb: CSV.parse is toolate when encoding is mismatch)) — "Michael Selig" <michael.selig@...> 2008/10/26

On Sun, 26 Oct 2008 17:26:32 +1100, Nobuyoshi Nakada <nobu@ruby-lang.org>

[#19522] Re: String literal encoding (Was: Default source encoding (Was: [Bug #680] csv.rb: CSV.parse is toolate when encoding is mismatch)) — Nobuyoshi Nakada <nobu@...> 2008/10/26

Hi,

[#19525] Re: String literal encoding (Was: Default source encoding (Was: [Bug #680] csv.rb: CSV.parse is toolate when encoding is mismatch)) — "Michael Selig" <michael.selig@...> 2008/10/26

On Sun, 26 Oct 2008 23:34:26 +1100, Nobuyoshi Nakada <nobu@ruby-lang.org>

[#19531] Re: String literal encoding (Was: Default source encoding (Was: [Bug #680] csv.rb: CSV.parse is toolate when encoding is mismatch)) — Nobuyoshi Nakada <nobu@...> 2008/10/27

Hi,

[#19532] Re: String literal encoding (Was: Default source encoding (Was: [Bug #680] csv.rb: CSV.parse is toolate when encoding is mismatch)) — "Michael Selig" <michael.selig@...> 2008/10/27

On Mon, 27 Oct 2008 16:07:54 +1100, Nobuyoshi Nakada <nobu@ruby-lang.org>

[#19533] Re: String literal encoding (Was: Default source encoding (Was: [Bug #680] csv.rb: CSV.parse is toolate when encoding is mismatch)) — Nobuyoshi Nakada <nobu@...> 2008/10/27

Hi,

[#19535] Re: String literal encoding (Was: Default source encoding (Was: [Bug #680] csv.rb: CSV.parse is toolate when encoding is mismatch)) — "Michael Selig" <michael.selig@...> 2008/10/27

On Mon, 27 Oct 2008 17:27:57 +1100, Nobuyoshi Nakada <nobu@ruby-lang.org>

[#19538] Re: String literal encoding (Was: Default source encoding (Was: [Bug #680] csv.rb: CSV.parse is toolate when encoding is mismatch)) — Nobuyoshi Nakada <nobu@...> 2008/10/27

Hi,

[#19540] Re: String literal encoding (Was: Default source encoding (Was: [Bug #680] csv.rb: CSV.parse is toolate when encoding is mismatch)) — "Michael Selig" <michael.selig@...> 2008/10/27

On Mon, 27 Oct 2008 20:55:32 +1100, Nobuyoshi Nakada <nobu@ruby-lang.org>

[#19546] Re: String literal encoding (Was: Default source encoding (Was: [Bug #680] csv.rb: CSV.parse is toolate when encoding is mismatch)) — Nobuyoshi Nakada <nobu@...> 2008/10/27

Hi,

[#19480] Re: Default source encoding (Was: [Bug #680] csv.rb: CSV.parse is toolate when encoding is mismatch) — James Gray <james@...> 2008/10/24

On Oct 24, 2008, at 1:52 AM, Martin Duerst wrote:

[#19566] GC thought — "Roger Pack" <roger.pack@...>

Here is a recent patch I've been experimenting with--for any advice. [1]

26 messages 2008/10/28
[#19569] Re: GC thought — Ken Bloom <kbloom@...> 2008/10/28

On Tue, 28 Oct 2008 17:02:17 +0900, Roger Pack wrote:

[#19575] Re: GC thought — "Roger Pack" <roger.pack@...> 2008/10/28

> Letting the program continue execution during the mark phase could cause

[#19577] Re: GC thought — Paul Brannan <pbrannan@...> 2008/10/28

On Wed, Oct 29, 2008 at 01:04:52AM +0900, Roger Pack wrote:

[#19596] Re: GC thought — "Robert Klemme" <shortcutter@...> 2008/10/29

2008/10/28 Paul Brannan <pbrannan@atdesk.com>:

[#19590] [Feature #695] More flexibility when combining ASCII-8BIT strings with other encodings — Michael Selig <redmine@...>

Feature #695: More flexibility when combining ASCII-8BIT strings with other encodings

13 messages 2008/10/29
[#19646] Re: [Feature #695] More flexibility when combining ASCII-8BIT strings with other encodings — "Michael Selig" <michael.selig@...> 2008/10/30

Hi,

[ruby-core:19114] GC.reachability_paths

From: "Aman Gupta" <rubytalk@...1.net>
Date: 2008-10-02 23:10:58 UTC
List: ruby-core #19114
I modified the patch at
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/151854 to
work with 1.8.7-p72, but it dies with the following error:

ruby-1.8.7-p72 aman$ ruby -e 'o = Object.new; p GC.reachability_paths(o)'
-e:1:in `inspect': method `inspect' called on terminated object
(0x13cd38) (NotImplementedError)
       from -e:1:in `p'
       from -e:1

The patch (http://gist.github.com/14471):

diff --git a/gc.c b/gc.c
index 45facf0..a246ce9 100644
--- a/gc.c
+++ b/gc.c
@@ -74,7 +74,12 @@ static unsigned long malloc_increase = 0;
 static unsigned long malloc_limit = GC_MALLOC_LIMIT;
 static void run_final();
 static VALUE nomem_error;
+#ifdef DEBUG_REACHABILITY
+static VALUE garbage_collect0 _((VALUE));
+#define garbage_collect() garbage_collect0(0)
+#else
 static void garbage_collect();
+#endif

 int ruby_gc_stress = 0;

@@ -761,16 +766,55 @@ rb_gc_mark_maybe(obj)

 #define GC_LEVEL_MAX 250

+#ifdef DEBUG_REACHABILITY
+VALUE rb_reach_test_obj      = Qnil;
+VALUE rb_reach_test_result   = Qnil;
+VALUE rb_reach_test_path     = Qnil;
+
+static void
+rb_gc_unmark()
+{
+    RVALUE *p, *pend;
+    int i, used = heaps_used;
+
+    for (i = 0; i < used; i++) {
+       p = heaps[i].slot; pend = p + heaps[i].limit;
+       while (p < pend) {
+           RBASIC(p)->flags &= ~FL_MARK;
+           p++;
+       }
+    }
+}
+#endif
+
 static void
 gc_mark(ptr, lev)
    VALUE ptr;
    int lev;
 {
    register RVALUE *obj;
+#ifdef DEBUG_REACHABILITY
+    long saved_len = 0;
+    VALUE inspect = rb_intern("inspect");
+#endif

    obj = RANY(ptr);
    if (rb_special_const_p(ptr)) return; /* special const not marked */
    if (obj->as.basic.flags == 0) return;       /* free cell */
+#ifdef DEBUG_REACHABILITY
+    if (!NIL_P(rb_reach_test_obj) &&
+        (obj->as.basic.flags & T_MASK) != T_NODE) {
+       saved_len = RARRAY(rb_reach_test_path)->len;
+       if ((VALUE)obj == rb_reach_test_obj) {
+           rb_warn("  ...found, after %ld steps!", saved_len);
+           rb_ary_push(rb_reach_test_result,
+                       rb_ary_dup(rb_reach_test_path));
+       }
+       else if (!(obj->as.basic.flags & FL_MARK)) {
+           rb_ary_push(rb_reach_test_path, (VALUE)obj);
+       }
+    }
+#endif
    if (obj->as.basic.flags & FL_MARK) return;  /* already marked */
    obj->as.basic.flags |= FL_MARK;

@@ -787,6 +831,11 @@ gc_mark(ptr, lev)
       return;
    }
    gc_mark_children(ptr, lev+1);
+#ifdef DEBUG_REACHABILITY
+    if (!NIL_P(rb_reach_test_path)) {
+       RARRAY(rb_reach_test_path)->len = saved_len;
+    }
+#endif
 }

 void
@@ -1369,9 +1418,25 @@ int rb_setjmp (rb_jmp_buf);
 #endif /* __human68k__ or DJGPP */
 #endif /* __GNUC__ */

+#ifdef DEBUG_REACHABILITY
+#define IF_DEBUG_REACHABILITY(does) if (obj) {does;}
+#else
+#define IF_DEBUG_REACHABILITY(does)
+#endif
+
+#ifdef DEBUG_REACHABILITY
+static VALUE
+garbage_collect0(obj)
+    VALUE obj;
+#else
 static void
 garbage_collect()
+#endif
 {
+#ifdef DEBUG_REACHABILITY
+    int i = 0;
+    VALUE result;
+#endif
    struct gc_list *list;
    struct FRAME * volatile frame; /* gcc 2.7.2.3 -O2 bug??  */
    jmp_buf save_regs_gc_mark;
@@ -1382,40 +1447,84 @@ garbage_collect()
       rb_bug("cross-thread violation on rb_gc()");
    }
 #endif
-    if (dont_gc || during_gc) {
-       if (!freelist) {
-           add_heap();
+
+#ifdef DEBUG_REACHABILITY
+    if (obj) {
+       if (!NIL_P(rb_reach_test_obj) ||
+           !NIL_P(rb_reach_test_result) ||
+           !NIL_P(rb_reach_test_path)) {
+           rb_raise(rb_eRuntimeError, "reachability_paths called recursively");
       }
-       return;
+
+       rb_reach_test_obj    = obj;
+       rb_reach_test_result = rb_ary_new();
+       rb_reach_test_path   = rb_ary_new();
+    }
+    else
+#endif
+    {
+    if (dont_gc || during_gc) {
+      if (!freelist) {
+          add_heap();
+      }
+#ifdef DEBUG_REACHABILITY
+      return 0;
+#else
+      return;
+#endif
    }
-    if (during_gc) return;
    during_gc++;
+    }

    init_mark_stack();

    gc_mark((VALUE)ruby_current_node, 0);

    /* mark frame stack */
+    IF_DEBUG_REACHABILITY(rb_warn("Checking frame stack..."));
    for (frame = ruby_frame; frame; frame = frame->prev) {
+       IF_DEBUG_REACHABILITY(
+           NODE *node = frame->node;
+           if (node) {
+               rb_ary_push(rb_reach_test_path,
+                           rb_sprintf("frame %d: %s line %d", i,
node->nd_file, nd_line(node)));
+           });
       rb_gc_mark_frame(frame);
+       IF_DEBUG_REACHABILITY((rb_ary_pop(rb_reach_test_path), i++));
       if (frame->tmp) {
           struct FRAME *tmp = frame->tmp;
+#ifdef DEBUG_REACHABILITY
+           int ti = 0;
+#endif
           while (tmp) {
+               IF_DEBUG_REACHABILITY(
+                   NODE *node = tmp->node;
+                   if (node) {
+                       rb_ary_push(rb_reach_test_path,
+                                   rb_sprintf("tmp frame %d: %s line %d",
+                                              ti, node->nd_file,
nd_line(node)));
+                   });
               rb_gc_mark_frame(tmp);
+               IF_DEBUG_REACHABILITY((rb_ary_pop(rb_reach_test_path), ti++));
               tmp = tmp->prev;
           }
       }
    }
+    IF_DEBUG_REACHABILITY(rb_warn("Checking ruby_class..."));
    gc_mark((VALUE)ruby_scope, 0);
+    IF_DEBUG_REACHABILITY(rb_warn("Checking ruby_scope..."));
    gc_mark((VALUE)ruby_dyna_vars, 0);
    if (finalizer_table) {
+       IF_DEBUG_REACHABILITY(rb_warn("Checking finalizer_table..."));
       mark_tbl(finalizer_table, 0);
    }

    FLUSH_REGISTER_WINDOWS;
    /* This assumes that all registers are saved into the jmp_buf
(and stack) */
    rb_setjmp(save_regs_gc_mark);
+    IF_DEBUG_REACHABILITY(rb_warn("Checking save_regs_gc_mark..."));
    mark_locations_array((VALUE*)save_regs_gc_mark,
sizeof(save_regs_gc_mark) / sizeof(VALUE *));
+    IF_DEBUG_REACHABILITY(rb_warn("Checking stack_start..."));
 #if STACK_GROW_DIRECTION < 0
    rb_gc_mark_locations((VALUE*)STACK_END, rb_gc_stack_start);
 #elif STACK_GROW_DIRECTION > 0
@@ -1435,24 +1544,35 @@ garbage_collect()
    rb_gc_mark_locations((VALUE*)((char*)STACK_END + 2),
                        (VALUE*)((char*)rb_gc_stack_start + 2));
 #endif
+    IF_DEBUG_REACHABILITY(rb_warn("Checking threads..."));
    rb_gc_mark_threads();

    /* mark protected global variables */
+    IF_DEBUG_REACHABILITY(rb_warn("Checking C globals..."));
    for (list = global_List; list; list = list->next) {
+       IF_DEBUG_REACHABILITY(rb_ary_push(rb_reach_test_path, rb_sprintf("C
global %d", i)));
       rb_gc_mark_maybe(*list->varptr);
+       IF_DEBUG_REACHABILITY((rb_ary_pop(rb_reach_test_path), i++));
    }
+    IF_DEBUG_REACHABILITY(rb_warn("Checking end_proc..."));
    rb_mark_end_proc();
+    IF_DEBUG_REACHABILITY(rb_warn("Checking global_tbl..."));
    rb_gc_mark_global_tbl();

+    IF_DEBUG_REACHABILITY(rb_warn("Checking class_tbl..."));
    rb_mark_tbl(rb_class_tbl);
+    IF_DEBUG_REACHABILITY(rb_warn("Checking trap_list..."));
    rb_gc_mark_trap_list();

    /* mark generic instance variables for special constants */
+    IF_DEBUG_REACHABILITY(rb_warn("Checking generic_ivar_tbl..."));
    rb_mark_generic_ivar_tbl();

+    IF_DEBUG_REACHABILITY(rb_warn("Checking mark parser..."));
    rb_gc_mark_parser();

    /* gc_mark objects whose marking are not completed*/
+    IF_DEBUG_REACHABILITY(rb_warn("Checking mark stack..."));
    do {
       while (!MARK_STACK_EMPTY) {
           if (mark_stack_overflow){
@@ -1465,6 +1585,20 @@ garbage_collect()
       rb_gc_abort_threads();
    } while (!MARK_STACK_EMPTY);

+    IF_DEBUG_REACHABILITY(
+       rb_warn("Unmarking...");
+       rb_gc_unmark();
+
+       rb_warn("Done.");
+
+       result = rb_reach_test_result;
+
+        rb_reach_test_obj    = Qnil;
+        rb_reach_test_result = Qnil;
+        rb_reach_test_path   = Qnil;
+
+       return result);
+
    gc_sweep();
 }

@@ -2075,6 +2209,15 @@ rb_obj_id(VALUE obj)
    return (VALUE)((long)obj|FIXNUM_FLAG);
 }

+static VALUE
+rbx_reachability_paths(mod, obj)
+    VALUE mod;
+    VALUE obj;
+{
+    if (rb_special_const_p(obj)) return Qnil;
+    return garbage_collect0(obj);
+}
+
 /*
 *  The <code>GC</code> module provides an interface to Ruby's mark and
 *  sweep garbage collection mechanism. Some of the underlying methods
@@ -2092,6 +2235,9 @@ Init_GC()
    rb_define_singleton_method(rb_mGC, "disable", rb_gc_disable, 0);
    rb_define_singleton_method(rb_mGC, "stress", gc_stress_get, 0);
    rb_define_singleton_method(rb_mGC, "stress=", gc_stress_set, 1);
+#ifdef DEBUG_REACHABILITY
+    rb_define_singleton_method(rb_mGC, "reachability_paths",
rbx_reachability_paths, 1);
+#endif
    rb_define_method(rb_mGC, "garbage_collect", rb_gc_start, 0);

    rb_mObSpace = rb_define_module("ObjectSpace");
@@ -2115,6 +2261,10 @@ Init_GC()
    source_filenames = st_init_strtable();

    rb_global_variable(&nomem_error);
+#ifdef DEBUG_REACHABILITY
+    rb_global_variable(&rb_reach_test_result);
+    rb_global_variable(&rb_reach_test_path);
+#endif
    nomem_error = rb_exc_new3(rb_eNoMemError,
                             rb_obj_freeze(rb_str_new2("failed to
allocate memory")));
    OBJ_TAINT(nomem_error);
diff --git a/sprintf.c b/sprintf.c
index 9cdf8bc..d3104b7 100644
--- a/sprintf.c
+++ b/sprintf.c
@@ -846,3 +846,41 @@ fmt_setup(buf, c, flags, width, prec)
    *buf++ = c;
    *buf = '\0';
 }
+
+#undef FILE
+#define FILE rb_printf_buffer
+#define __sbuf rb_printf_sbuf
+#define __sFILE rb_printf_sfile
+#undef feof
+#undef ferror
+#undef clearerr
+#undef fileno
+#if SIZEOF_LONG < SIZEOF_VOIDP
+# if  SIZEOF_LONG_LONG == SIZEOF_VOIDP
+#  define _HAVE_SANE_QUAD_
+#  define _HAVE_LLP64_
+#  define quad_t LONG_LONG
+#  define u_quad_t unsigned LONG_LONG
+# endif
+#endif
+#undef vsnprintf
+#undef snprintf
+#include "missing/vsnprintf.c"
+
+VALUE
+rb_sprintf(const char *format, ...)
+{
+    VALUE result;
+    va_list ap;
+    char *str;
+
+    va_start(ap, format);
+    vasprintf(&str, format, ap);
+    va_end(ap);
+
+    printf("STRING: %s\n", str);
+    result = rb_str_new2(str);
+    free(str);
+
+    return result;
+}
\ No newline at end of file
diff --git a/variable.c b/variable.c
index 50ecf04..b0ef111 100644
--- a/variable.c
+++ b/variable.c
@@ -458,6 +458,13 @@ readonly_setter(val, id, var)
    rb_name_error(id, "%s is a read-only variable", rb_id2name(id));
 }

+#ifdef DEBUG_REACHABILITY
+extern VALUE rb_reach_test_path;
+#define IF_DEBUG_REACHABILITY(does) do {if
(!NIL_P(rb_reach_test_path)) {does;}} while (0)
+#else
+#define IF_DEBUG_REACHABILITY(does)
+#endif
+
 static int
 mark_global_entry(key, entry)
    ID key;
@@ -465,11 +472,25 @@ mark_global_entry(key, entry)
 {
    struct trace_var *trace;
    struct global_variable *var = entry->var;
+#ifdef DEBUG_REACHABILITY
+    int i = 0;
+#endif

+    IF_DEBUG_REACHABILITY(
+       rb_ary_push(rb_reach_test_path,
+                   rb_sprintf("Ruby global %s", rb_id2name(key))));
    (*var->marker)(var->data);
+    IF_DEBUG_REACHABILITY(rb_ary_pop(rb_reach_test_path));
+
    trace = var->trace;
    while (trace) {
-       if (trace->data) rb_gc_mark_maybe(trace->data);
+       if (trace->data) {
+           IF_DEBUG_REACHABILITY(
+               rb_ary_push(rb_reach_test_path,
+                           rb_sprintf("Ruby global %s trace %d",
rb_id2name(key), i++)));
+           rb_gc_mark_maybe(trace->data);
+           IF_DEBUG_REACHABILITY(rb_ary_pop(rb_reach_test_path));
+       }
       trace = trace->next;
    }
    return ST_CONTINUE;


 Aman Gupta

In This Thread

Prev Next