示例#1
0
void
ruby_init(void)
{
    int state;

    if (ruby_initialized)
	return;
    ruby_initialized = 1;

#ifdef __MACOS__
    rb_origenviron = 0;
#else
    rb_origenviron = environ;
#endif

#if WITH_OBJC
    char *s;
   
    s = getenv("MACRUBY_DEBUG");
    ruby_dlog_enabled = !(s == NULL || *s == '0');
    s = getenv("MACRUBY_DEBUG_FILE");
    if (s == NULL) {
	ruby_dlog_file = stderr;
    }
    else {
	ruby_dlog_file = fopen(s, "w");
	if (ruby_dlog_file == NULL) {
	    fprintf(stderr, "cannot open macruby debug file `%s'",
		    strerror(errno));
	    ruby_dlog_file = stderr;
	}
    }
#endif

    Init_stack((void *)&state);
    Init_PreGC();
    Init_BareVM();
    Init_heap();

    PUSH_TAG();
    if ((state = EXEC_TAG()) == 0) {
	rb_call_inits();

#ifdef __MACOS__
	_macruby_init();
#elif defined(__VMS)
	_vmsruby_init();
#endif

	ruby_prog_init();
	ALLOW_INTS;
    }
    POP_TAG();

    if (state) {
	error_print();
	exit(EXIT_FAILURE);
    }
    GET_VM()->running = 1;
}
示例#2
0
文件: eval.c 项目: genki/ruby
void
ruby_init(void)
{
    static int initialized = 0;
    int state;

    if (initialized)
	return;
    initialized = 1;

#ifdef __MACOS__
    rb_origenviron = 0;
#else
    rb_origenviron = environ;
#endif

    Init_stack((void *)&state);
    Init_BareVM();
    Init_heap();

    PUSH_TAG();
    if ((state = EXEC_TAG()) == 0) {
	rb_call_inits();

#ifdef __MACOS__
	_macruby_init();
#elif defined(__VMS)
	_vmsruby_init();
#endif

	ruby_prog_init();
	ALLOW_INTS;
    }
    POP_TAG();

    if (state) {
	error_print();
	exit(EXIT_FAILURE);
    }
    GET_VM()->running = 1;
}