From: Adam Bozanich Date: 2007-04-16T16:26:03+09:00 Subject: block_given? => true in main(). ------=_Part_31699_26609454.1176708360261 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi all. I'm trying to drive ruby from c ( eg, not call ruby_run() ). I'm having problems with 1.9(trunk) because for some reason rb_block_given_p() returns true all of the time, see the examples below. The first one is a simple test, the next I tried to copy everything that main,eval,ruby.c did before they start to use ruby classes ( i stopped when rb_str_new() was used in proc_options() ). I think there might be an initialization function that I'm not calling because this does not happen in 1.8.6. Any suggestions? Thanks, -Adam #include "ruby.h" int main( int argc , char * argv[] ) { RUBY_INIT_STACK; ruby_init(); ruby_script("test"); printf("block_given? => %s\n" , rb_block_given_p() ? "true" : "false" ); return 0; } #include "ruby.h" #include "eval_intern.h" int main( int argc , char * argv[] ) { RUBY_INIT_STACK; ruby_init(); int state; Init_stack((void*)&state); PUSH_THREAD_TAG(); if((state = EXEC_TAG()) == 0 ) { ruby_script("test"); /* rb_str_new() called from ruby.c:proc_options() */ printf("block_given? => %s\n" , rb_block_given_p() ? "true" : "false" ); } else { printf("state != 0\n"); } POP_THREAD_TAG(); return 0; } ------=_Part_31699_26609454.1176708360261 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi all.

I'm trying to drive ruby from c ( eg, not call ruby_run() ).

I'm having problems with 1.9(trunk) because for some reason rb_block_given_p() returns true all of the time, see the examples below.  The first one is a simple test, the next I tried to copy everything that main,eval, ruby.c did before they start to use ruby classes ( i stopped when rb_str_new() was used in proc_options() ).

I think there might be an initialization function that I'm not calling because this does not happen in 1.8.6.  Any suggestions?

Thanks,
-Adam

#include "ruby.h"

int main( int argc , char * argv[] ) {
    RUBY_INIT_STACK;
    ruby_init();
    ruby_script("test");
    printf("block_given? => %s\n" , rb_block_given_p() ? "true" : "false" );
    return 0;
}

#include "ruby.h"
#include "eval_intern.h"

int main( int argc , char * argv[] ) {
    RUBY_INIT_STACK;
    ruby_init();

    int state;
    Init_stack((void*)&state);
    PUSH_THREAD_TAG();
    if((state = EXEC_TAG()) == 0 ) {
        ruby_script("test");

        /* rb_str_new() called from ruby.c:proc_options() */

        printf("block_given? => %s\n" , rb_block_given_p() ? "true" : "false" );

    } else {
        printf("state != 0\n");
    }
    POP_THREAD_TAG();
    return 0;
}

------=_Part_31699_26609454.1176708360261--