ruby-changes:5942
From: matz <ko1@a...>
Date: Fri, 20 Jun 2008 02:26:37 +0900 (JST)
Subject: [ruby-changes:5942] Ruby:r17450 (ruby_1_8): wrong commit; sorry
matz 2008-06-20 02:26:20 +0900 (Fri, 20 Jun 2008) New Revision: 17450 Modified files: branches/ruby_1_8/ext/openssl/ossl.h branches/ruby_1_8/ext/stringio/stringio.c branches/ruby_1_8/ext/tk/extconf.rb branches/ruby_1_8/ext/tk/stubs.c branches/ruby_1_8/ext/tk/tcltklib.c branches/ruby_1_8/ext/tk/tkutil/extconf.rb branches/ruby_1_8/ext/tk/tkutil/tkutil.c branches/ruby_1_8/test/stringio/test_stringio.rb Log: wrong commit; sorry http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/test/stringio/test_stringio.rb?r1=17450&r2=17449&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/ext/tk/extconf.rb?r1=17450&r2=17449&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/ext/stringio/stringio.c?r1=17450&r2=17449&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/ext/tk/tkutil/extconf.rb?r1=17450&r2=17449&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/ext/tk/tcltklib.c?r1=17450&r2=17449&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/ext/tk/stubs.c?r1=17450&r2=17449&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/ext/openssl/ossl.h?r1=17450&r2=17449&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/ext/tk/tkutil/tkutil.c?r1=17450&r2=17449&diff_format=u Index: ruby_1_8/ext/tk/stubs.c =================================================================== --- ruby_1_8/ext/tk/stubs.c (revision 17449) +++ ruby_1_8/ext/tk/stubs.c (revision 17450) @@ -92,7 +92,7 @@ static DL_HANDLE tk_dll = (DL_HANDLE)0; int -#ifdef RUBY_VM +#ifdef HAVE_PROTOTYPES ruby_open_tcl_dll(char *appname) #else ruby_open_tcl_dll(appname) @@ -179,7 +179,7 @@ } int -#ifdef RUBY_VM +#ifdef HAVE_PROTOTYPES ruby_open_tcltk_dll(char *appname) #else ruby_open_tcltk_dll(appname) @@ -203,7 +203,7 @@ Tcl_Interp * -#ifdef RUBY_VM +#ifdef HAVE_PROTOTYPES ruby_tcl_create_ip_and_stubs_init(int *st) #else ruby_tcl_create_ip_and_stubs_init(st) @@ -290,7 +290,7 @@ } int -#ifdef RUBY_VM +#ifdef HAVE_PROTOTYPES ruby_tk_stubs_init(Tcl_Interp *tcl_ip) #else ruby_tk_stubs_init(tcl_ip) @@ -330,7 +330,7 @@ } int -#ifdef RUBY_VM +#ifdef HAVE_PROTOTYPES ruby_tk_stubs_safeinit(Tcl_Interp *tcl_ip) #else ruby_tk_stubs_safeinit(tcl_ip) @@ -421,7 +421,7 @@ static int call_tk_stubs_init = 0; int -#ifdef RUBY_VM +#ifdef HAVE_PROTOTYPES ruby_open_tcl_dll(char *appname) #else ruby_open_tcl_dll(appname) @@ -450,7 +450,7 @@ } int -#ifdef RUBY_VM +#ifdef HAVE_PROTOTYPES ruby_open_tcltk_dll(char *appname) #else ruby_open_tcltk_dll(appname) @@ -473,7 +473,7 @@ } Tcl_Interp * -#ifdef RUBY_VM +#ifdef HAVE_PROTOTYPES ruby_tcl_create_ip_and_stubs_init(int *st) #else ruby_tcl_create_ip_and_stubs_init(st) @@ -506,7 +506,7 @@ } int -#ifdef RUBY_VM +#ifdef HAVE_PROTOTYPES ruby_tk_stubs_init(Tcl_Interp *tcl_ip) #else ruby_tk_stubs_init(tcl_ip) @@ -527,7 +527,7 @@ } int -#ifdef RUBY_VM +#ifdef HAVE_PROTOTYPES ruby_tk_stubs_safeinit(Tcl_Interp *tcl_ip) #else ruby_tk_stubs_safeinit(tcl_ip) Index: ruby_1_8/ext/tk/tcltklib.c =================================================================== --- ruby_1_8/ext/tk/tcltklib.c (revision 17449) +++ ruby_1_8/ext/tk/tcltklib.c (revision 17450) @@ -8,10 +8,12 @@ #include "ruby.h" -#ifdef RUBY_VM +#ifdef HAVE_RUBY_RUBY_H /* #include "ruby/ruby.h" */ #include "ruby/signal.h" +#ifdef HAVE_RUBY_ENCODING_H #include "ruby/encoding.h" +#endif #else /* #include "ruby.h" */ #include "rubysig.h" @@ -31,6 +33,19 @@ #include <tcl.h> #include <tk.h> +#ifndef HAVE_RUBY_NATIVE_THREAD_P +#define ruby_native_thread_p() is_ruby_native_thread() +#undef RUBY_USE_NATIVE_THREAD +#else +#define RUBY_USE_NATIVE_THREAD 1 +#endif +#ifndef HAVE_RB_ERRINFO +#define rb_errinfo() (ruby_errinfo+0) /* cannot be l-value */ +#endif +#ifndef HAVE_RB_SAFE_LEVEL +#define rb_safe_level() (ruby_safe_level+0) /* cannot be l-value */ +#endif + #include "stubs.h" #ifndef TCL_ALPHA_RELEASE @@ -110,7 +125,7 @@ static int at_exit = 0; -#ifdef RUBY_VM +#ifdef HAVE_RUBY_ENCODING_H static VALUE cRubyEncoding; /* encoding */ @@ -195,7 +210,7 @@ /* safe Tcl_Eval and Tcl_GlobalEval */ static int -#ifdef RUBY_VM +#ifdef HAVE_PROTOTYPES tcl_eval(Tcl_Interp *interp, const char *cmd) #else tcl_eval(interp, cmd) @@ -216,7 +231,7 @@ #define Tcl_Eval tcl_eval static int -#ifdef RUBY_VM +#ifdef HAVE_PROTOTYPES tcl_global_eval(Tcl_Interp *interp, const char *cmd) #else tcl_global_eval(interp, cmd) @@ -393,7 +408,7 @@ static VALUE eventloop_thread; -#ifdef RUBY_VM +#ifdef RUBY_USE_NATIVE_THREAD Tcl_ThreadId tk_eventloop_thread_id; /* native thread ID of Tcl interpreter */ #endif static VALUE eventloop_stack; @@ -424,14 +439,14 @@ * 'timer_tick' is a limit of one term of thread scheduling. * If 'timer_tick' == 0, then not use the timer for thread scheduling. */ -#ifdef RUBY_VM +#ifdef RUBY_USE_NATIVE_THREAD #define DEFAULT_EVENT_LOOP_MAX 800/*counts*/ #define DEFAULT_NO_EVENT_TICK 10/*counts*/ #define DEFAULT_NO_EVENT_WAIT 10/*milliseconds ( 1 -- 999 ) */ #define WATCHDOG_INTERVAL 10/*milliseconds ( 1 -- 999 ) */ #define DEFAULT_TIMER_TICK 0/*milliseconds ( 0 -- 999 ) */ #define NO_THREAD_INTERRUPT_TIME 100/*milliseconds ( 1 -- 999 ) */ -#else /* ! RUBY_VM */ +#else /* ! RUBY_USE_NATIVE_THREAD */ #define DEFAULT_EVENT_LOOP_MAX 800/*counts*/ #define DEFAULT_NO_EVENT_TICK 10/*counts*/ #define DEFAULT_NO_EVENT_WAIT 20/*milliseconds ( 1 -- 999 ) */ @@ -673,7 +688,7 @@ #if TCL_NAMESPACE_DEBUG Tcl_Namespace *default_ns; /* default namespace */ #endif -#ifdef RUBY_VM +#ifdef RUBY_USE_NATIVE_THREAD Tcl_ThreadId tk_thread_id; /* native thread ID of Tcl interpreter */ #endif int has_orig_exit; /* has original 'exit' command ? */ @@ -866,7 +881,7 @@ } #endif -#ifdef RUBY_VM +#ifdef RUBY_USE_NATIVE_THREAD ptr->tk_thread_id = Tcl_GetCurrentThread(); #endif @@ -1138,7 +1153,7 @@ /* tick_counter += event_loop_max; */ } -#ifdef RUBY_VM +#ifdef RUBY_USE_NATIVE_THREAD #if USE_TOGGLE_WINDOW_MODE_FOR_IDLE static int toggle_eventloop_window_mode_for_idle() @@ -1481,7 +1496,7 @@ lib_num_of_mainwindows(self) VALUE self; { -#ifdef RUBY_VM /* Ruby 1.9+ !!! */ +#ifdef RUBY_USE_NATIVE_THREAD /* Ruby 1.9+ !!! */ return tk_funcall(lib_num_of_mainwindows_core, 0, (VALUE*)NULL, self); #else return lib_num_of_mainwindows_core(self, 0, (VALUE*)NULL); @@ -1489,7 +1504,7 @@ } -#ifdef RUBY_VM /* Ruby 1.9+ !!! */ +#ifdef RUBY_USE_NATIVE_THREAD /* Ruby 1.9+ !!! */ static VALUE call_DoOneEvent_core(flag_val) VALUE flag_val; @@ -1538,36 +1553,24 @@ t.tv_usec = (time_t)(no_event_wait*1000.0); #ifdef HAVE_NATIVETHREAD -#ifdef RUBY_VM -#if 0 +#ifndef RUBY_USE_NATIVE_THREAD if (!ruby_native_thread_p()) { rb_bug("cross-thread violation on eventloop_sleep()"); } #endif -#else - if (!is_ruby_native_thread()) { - rb_bug("cross-thread violation on eventloop_sleep()"); - } #endif -#endif DUMP2("eventloop_sleep: rb_thread_wait_for() at thread : %lx", rb_thread_current()); rb_thread_wait_for(t); DUMP2("eventloop_sleep: finish at thread : %lx", rb_thread_current()); #ifdef HAVE_NATIVETHREAD -#ifdef RUBY_VM -#if 0 +#ifndef RUBY_USE_NATIVE_THREAD if (!ruby_native_thread_p()) { rb_bug("cross-thread violation on eventloop_sleep()"); } #endif -#else - if (!is_ruby_native_thread()) { - rb_bug("cross-thread violation on eventloop_sleep()"); - } #endif -#endif return Qnil; } @@ -1578,7 +1581,7 @@ static int get_thread_alone_check_flag() { -#ifdef RUBY_VM +#ifdef RUBY_USE_NATIVE_THREAD return 0; #else set_tcltk_version(); @@ -1690,19 +1693,11 @@ if (status) { switch (status) { case TAG_RAISE: -#ifdef RUBY_VM if (NIL_P(rb_errinfo())) { -#else - if (NIL_P(ruby_errinfo)) { -#endif rbtk_pending_exception = rb_exc_new2(rb_eException, "unknown exception"); } else { -#ifdef RUBY_VM rbtk_pending_exception = rb_errinfo(); -#else - rbtk_pending_exception = ruby_errinfo; -#endif if (!NIL_P(rbtk_pending_exception)) { if (rbtk_eventloop_depth == 0) { @@ -1717,18 +1712,10 @@ break; case TAG_FATAL: -#ifdef RUBY_VM if (NIL_P(rb_errinfo())) { -#else - if (NIL_P(ruby_errinfo)) { -#endif rb_exc_raise(rb_exc_new2(rb_eFatal, "FATAL")); } else { -#ifdef RUBY_VM rb_exc_raise(rb_errinfo()); -#else - rb_exc_raise(ruby_errinfo); -#endif } } } @@ -1819,7 +1806,7 @@ if (NIL_P(eventloop_thread) || current == eventloop_thread) { int st; int status; -#ifdef RUBY_VM +#ifdef RUBY_USE_NATIVE_THREAD if (update_flag) { st = RTEST(rb_protect(call_DoOneEvent, INT2FIX(event_flag), &status)); @@ -1855,20 +1842,12 @@ if (status) { switch (status) { case TAG_RAISE: -#ifdef RUBY_VM if (NIL_P(rb_errinfo())) { -#else - if (NIL_P(ruby_errinfo)) { -#endif rbtk_pending_exception = rb_exc_new2(rb_eException, "unknown exception"); } else { -#ifdef RUBY_VM rbtk_pending_exception = rb_errinfo(); -#else - rbtk_pending_exception = ruby_errinfo; -#endif if (!NIL_P(rbtk_pending_exception)) { if (rbtk_eventloop_depth == 0) { @@ -1883,18 +1862,10 @@ break; case TAG_FATAL: -#ifdef RUBY_VM if (NIL_P(rb_errinfo())) { -#else - if (NIL_P(ruby_errinfo)) { -#endif rb_exc_raise(rb_exc_new2(rb_eFatal, "FATAL")); } else { -#ifdef RUBY_VM rb_exc_raise(rb_errinfo()); -#else - rb_exc_raise(ruby_errinfo); -#endif } } } @@ -1944,20 +1915,12 @@ if (status) { switch (status) { case TAG_RAISE: -#ifdef RUBY_VM if (NIL_P(rb_errinfo())) { -#else - if (NIL_P(ruby_errinfo)) { -#endif rbtk_pending_exception = rb_exc_new2(rb_eException, "unknown exception"); } else { -#ifdef RUBY_VM rbtk_pending_exception = rb_errinfo(); -#else - rbtk_pending_exception = ruby_errinfo; -#endif if (!NIL_P(rbtk_pending_exception)) { if (rbtk_eventloop_depth == 0) { @@ -1972,19 +1935,11 @@ break; case TAG_FATAL: -#ifdef RUBY_VM if (NIL_P(rb_errinfo())) { -#else - if (NIL_P(ruby_errinfo)) { -#endif rb_exc_raise(rb_exc_new2(rb_eFatal, "FATAL")); } else { -#ifdef RUBY_VM rb_exc_raise(rb_errinfo()); -#else - rb_exc_raise(ruby_errinfo); -#endif } } } @@ -2045,7 +2000,7 @@ } DUMP1("trap check & thread scheduling"); -#ifdef RUBY_VM +#ifdef RUBY_USE_NATIVE_THREAD /* if (update_flag == 0) CHECK_INTS; */ /*XXXXXXXXXXXXX TODO !!!! */ #else if (update_flag == 0) CHECK_INTS; @@ -2096,35 +2051,19 @@ switch (status) { case TAG_RAISE: -#ifdef RUBY_VM if (NIL_P(rb_errinfo())) { -#else - if (NIL_P(ruby_errinfo)) { -#endif rbtk_pending_exception = rb_exc_new2(rb_eException, "unknown exception"); } else { -#ifdef RUBY_VM rbtk_pending_exception = rb_errinfo(); -#else - rbtk_pending_exception = ruby_errinfo; -#endif } return Qnil; case TAG_FATAL: -#ifdef RUBY_VM if (NIL_P(rb_errinfo())) { -#else - if (NIL_P(ruby_errinfo)) { -#endif rbtk_pending_exception = rb_exc_new2(rb_eFatal, "FATAL"); } else { -#ifdef RUBY_VM rbtk_pending_exception = rb_errinfo(); -#else - rbtk_pending_exception = ruby_errinfo; -#endif } return Qnil; } @@ -2179,7 +2118,7 @@ } } -#ifdef RUBY_VM +#ifdef RUBY_USE_NATIVE_THREAD if (NIL_P(eventloop_thread)) { tk_eventloop_thread_id = (Tcl_ThreadId) 0; } @@ -2208,7 +2147,7 @@ tcl_stubs_check(); eventloop_thread = rb_thread_current(); -#ifdef RUBY_VM +#ifdef RUBY_USE_NATIVE_THREAD tk_eventloop_thread_id = Tcl_GetCurrentThread(); #endif @@ -2361,7 +2300,7 @@ VALUE arg; { eventloop_thread = Qnil; /* stop eventloops */ -#ifdef RUBY_VM +#ifdef RUBY_USE_NATIVE_THREAD tk_eventloop_thread_id = (Tcl_ThreadId) 0; #endif return Qnil; @@ -2375,7 +2314,7 @@ { VALUE check_rootwidget; -#ifdef RUBY_VM +#ifdef RUBY_USE_NATIVE_THREAD rb_raise(rb_eNotImpError, "eventloop_watchdog is not implemented on Ruby VM."); #endif @@ -2503,17 +2442,10 @@ /* ckfree((char*)q); */ if (NIL_P(rbtk_pending_exception)) { -#ifdef RUBY_VM /* return rb_errinfo(); */ if (status) { rb_exc_raise(rb_errinfo()); } -#else - /* return ruby_errinfo; */ - if (status) { - rb_exc_raise(ruby_errinfo); - } -#endif } else { VALUE exc = rbtk_pending_exception; rbtk_pending_exception = Qnil; @@ -2728,94 +2660,50 @@ goto error; error: str = rb_str_new2("LocalJumpError: "); -#ifdef RUBY_VM rb_str_append(str, rb_obj_as_string(rb_errinfo())); -#else - rb_str_append(str, rb_obj_as_string(ruby_errinfo)); -#endif exc = rb_exc_new3(type, str); break; case TAG_RETRY: -#ifdef RUBY_VM if (NIL_P(rb_errinfo())) { -#else - if (NIL_P(ruby_errinfo)) { -#endif DUMP1("rb_protect: retry"); exc = rb_exc_new2(eTkCallbackRetry, "retry jump error"); } else { -#ifdef RUBY_VM exc = rb_errinfo(); -#else - exc = ruby_errinfo; -#endif } break; case TAG_REDO: -#ifdef RUBY_VM if (NIL_P(rb_errinfo())) { -#else - if (NIL_P(ruby_errinfo)) { -#endif DUMP1("rb_protect: redo"); exc = rb_exc_new2(eTkCallbackRedo, "redo jump error"); } else { -#ifdef RUBY_VM exc = rb_errinfo(); -#else - exc = ruby_errinfo; -#endif } break; case TAG_RAISE: -#ifdef RUBY_VM if (NIL_P(rb_errinfo())) { -#else - if (NIL_P(ruby_errinfo)) { -#endif exc = rb_exc_new2(rb_eException, "unknown exception"); } else { -#ifdef RUBY_VM exc = rb_errinfo(); -#else - exc = ruby_errinfo; -#endif } break; case TAG_FATAL: -#ifdef RUBY_VM if (NIL_P(rb_errinfo())) { -#else - if (NIL_P(ruby_errinfo)) { -#endif exc = rb_exc_new2(rb_eFatal, "FATAL"); } else { -#ifdef RUBY_VM exc = rb_errinfo(); -#else - exc = ruby_errinfo; -#endif } break; case TAG_THROW: -#ifdef RUBY_VM if (NIL_P(rb_errinfo())) { -#else - if (NIL_P(ruby_errinfo)) { -#endif DUMP1("rb_protect: throw"); exc = rb_exc_new2(eTkCallbackThrow, "throw jump error"); } else { -#ifdef RUBY_VM exc = rb_errinfo(); -#else - exc = ruby_errinfo; -#endif } break; @@ -2923,18 +2811,12 @@ int code; #ifdef HAVE_NATIVETHREAD -#ifdef RUBY_VM -#if 0 +#ifndef RUBY_USE_NATIVE_THREAD if (!ruby_native_thread_p()) { rb_bug("cross-thread violation on tcl_protect()"); } #endif -#else - if (!is_ruby_native_thread()) { - rb_bug("cross-thread violation on tcl_protect()"); - } #endif -#endif rb_trap_immediate = 0; code = tcl_protect_core(interp, proc, data); @@ -3213,22 +3095,21 @@ /* get args */ args = rb_ary_new2(argc - 2); -#ifdef RUBY_VM -#else +#ifdef HAVE_STRUCT_RARRAY_LEN RARRAY(args)->len = 0; #endif for(i = 3; i < argc; i++) { #if TCL_MAJOR_VERSION >= 8 str = Tcl_GetStringFromObj(argv[i], &len); DUMP2("arg:%s",str); -#ifdef RUBY_VM +#ifndef HAVE_STRUCT_RARRAY_LEN rb_ary_push(args, rb_tainted_str_new(str, len)); #else RARRAY(args)->ptr[RARRAY(args)->len++] = rb_tainted_str_new(str, len); #endif #else /* TCL_MAJOR_VERSION < 8 */ DUMP2("arg:%s",argv[i]); -#ifdef RUBY_VM +#ifndef HAVE_STRUCT_RARRAY_LEN rb_ary_push(args, rb_tainted_str_new2(argv[i])); #else RARRAY(args)->ptr[RARRAY(args)->len++] = rb_tainted_str_new2(argv[i]); @@ -3429,18 +3310,12 @@ return TCL_ERROR; } #ifdef HAVE_NATIVETHREAD -#ifdef RUBY_VM -#if 0 +#ifndef RUBY_USE_NATIVE_THREAD if (!ruby_native_thread_p()) { rb_bug("cross-thread violation on ip_ruby_eval()"); } #endif -#else - if (!is_ruby_native_thread()) { - rb_bug("cross-thread violation on ip_ruby_eval()"); - } #endif -#endif Tcl_ResetResult(interp); @@ -3586,18 +3461,12 @@ return TCL_ERROR; } #ifdef HAVE_NATIVETHREAD -#ifdef RUBY_VM -#if 0 +#ifndef RUBY_USE_NATIVE_THREAD if (!ruby_native_thread_p()) { rb_bug("cross-thread violation on ip_rb_threadUpdateCommand()"); } #endif -#else - if (!is_ruby_native_thread()) { - rb_bug("cross-thread violation on ip_rb_threadUpdateCommand()"); - } #endif -#endif if (rb_thread_alone() || NIL_P(eventloop_thread) || eventloop_thread == current_thread) { @@ -3785,18 +3654,12 @@ Tcl_Preserve(interp); #ifdef HAVE_NATIVETHREAD -#ifdef RUBY_VM -#if 0 +#ifndef RUBY_USE_NATIVE_THREAD if (!ruby_native_thread_p()) { rb_bug("cross-thread violation on ip_rbVwaitCommand()"); } #endif -#else - if (!is_ruby_native_thread()) { - rb_bug("cross-thread violation on ip_rbVwaitCommand()"); - } #endif -#endif Tcl_ResetResult(interp); @@ -5544,19 +5407,10 @@ Tk_Window mainWin = (Tk_Window)NULL; /* security check */ -#ifdef RUBY_VM if (rb_safe_level() >= 4) { -#else - if (ruby_safe_level >= 4) { -#endif rb_raise(rb_eSecurityError, "Cannot create a TclTkIp object at level %d", -#ifdef RUBY_VM - rb_safe_level() -#else - ruby_safe_level -#endif - ); + rb_safe_level()); } /* create object */ @@ -5564,7 +5418,7 @@ ptr = ALLOC(struct tcltkip); /* ptr = (struct tcltkip *)ckalloc(sizeof(struct tcltkip)); */ DATA_PTR(self) = ptr; -#ifdef RUBY_VM +#ifdef RUBY_USE_NATIVE_THREAD ptr->tk_thread_id = 0; #endif ptr->ref_count = 0; @@ -5674,7 +5528,7 @@ (Tcl_PackageInitProc *) NULL); #endif -#ifdef RUBY_VM +#ifdef RUBY_USE_NATIVE_THREAD /* set Tk thread ID */ ptr->tk_thread_id = Tcl_GetCurrentThread(); #endif @@ -5796,7 +5650,7 @@ #endif /* create slave-ip */ -#ifdef RUBY_VM +#ifdef RUBY_USE_NATIVE_THREAD /* slave->tk_thread_id = 0; */ slave->tk_thread_id = master->tk_thread_id; /* == current thread */ #endif @@ -6253,13 +6107,13 @@ #endif str = s ? rb_str_new(s, len) : rb_str_new2(""); if (binary) { -#ifdef RUBY_VM +#ifdef HAVE_RUBY_ENCODING_H rb_enc_associate_index(str, ENCODING_INDEX_BINARY); #endif rb_ivar_set(str, ID_at_enc, ENCODING_NAME_BINARY); #if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION >= 1) } else { -#ifdef RUBY_VM +#ifdef HAVE_RUBY_ENCODING_H rb_enc_associate_index(str, ENCODING_INDEX_UTF8); #endif rb_ivar_set(str, ID_at_enc, ENCODING_NAME_UTF8); @@ -6288,7 +6142,7 @@ /* text string */ return Tcl_NewStringObj(s, RSTRING_LEN(str)); } -#ifdef RUBY_VM +#ifdef HAVE_RUBY_ENCODING_H } else if (rb_enc_get_index(str) == ENCODING_INDEX_BINARY) { /* binary string */ return Tcl_NewByteArrayObj(s, RSTRING_LEN(str)); @@ -6458,7 +6312,7 @@ ptr = (struct tcltkip *)NULL; } -#ifdef RUBY_VM +#ifdef RUBY_USE_NATIVE_THREAD if (ptr) { /* on Tcl interpreter */ is_tk_evloop_thread = (ptr->tk_thread_id == (Tcl_ThreadId) 0 @@ -6534,7 +6388,7 @@ /* add the handler to Tcl event queue */ DUMP1("add handler"); -#ifdef RUBY_VM +#ifdef RUBY_USE_NATIVE_THREAD if (ptr && ptr->tk_thread_id) { /* Tcl_ThreadQueueEvent(ptr->tk_thread_id, &(callq->ev), TCL_QUEUE_HEAD); */ @@ -6681,35 +6535,19 @@ ret = rb_protect(call_tcl_eval, (VALUE)&inf, &status); switch(status) { case TAG_RAISE: -#ifdef RUBY_VM if (NIL_P(rb_errinfo())) { -#else - if (NIL_P(ruby_errinfo)) { -#endif rbtk_pending_exception = rb_exc_new2(rb_eException, "unknown exception"); } else { -#ifdef RUBY_VM rbtk_pending_exception = rb_errinfo(); -#else - rbtk_pending_exception = ruby_errinfo; -#endif } break; case TAG_FATAL: -#ifdef RUBY_VM if (NIL_P(rb_errinfo())) { -#else - if (NIL_P(ruby_errinfo)) { -#endif rbtk_pending_exception = rb_exc_new2(rb_eFatal, "FATAL"); } else { -#ifdef RUBY_VM rbtk_pending_exception = rb_errinfo(); -#else - rbtk_pending_exception = ruby_errinfo; -#endif } } #endif @@ -6873,18 +6711,12 @@ /* check safe-level */ if (rb_safe_level() != q->safe_level) { #ifdef HAVE_NATIVETHREAD -#ifdef RUBY_VM -#if 0 +#ifndef RUBY_USE_NATIVE_THREAD if (!ruby_native_thread_p()) { rb_bug("cross-thread violation on eval_queue_handler()"); } #endif -#else - if (!is_ruby_native_thread()) { - rb_bug("cross-thread violation on eval_queue_handler()"); - } #endif -#endif /* q_dat = Data_Wrap_Struct(rb_cData,0,-1,q); */ q_dat = Data_Wrap_Struct(rb_cData,eval_queue_mark,-1,q); ret = rb_funcall(rb_proc_new(evq_safelevel_handler, q_dat), @@ -6940,7 +6772,7 @@ VALUE str; { struct eval_queue *evq; -#ifdef RUBY_VM +#ifdef RUBY_USE_NATIVE_THREAD struct tcltkip *ptr; #endif char *eval_str; @@ -6957,12 +6789,12 @@ StringValue(str); rb_thread_critical = thr_crit_bup; -#ifdef RUBY_VM +#ifdef RUBY_USE_NATIVE_THREAD ptr = get_ip(ip_obj); #endif if ( -#ifdef RUBY_VM +#ifdef RUBY_USE_NATIVE_THREAD (ptr->tk_thread_id == 0 || ptr->tk_thread_id == Tcl_GetCurrentThread()) && #endif @@ -7025,7 +6857,7 @@ /* add the handler to Tcl event queue */ DUMP1("add handler"); -#ifdef RUBY_VM +#ifdef RUBY_USE_NATIVE_THREAD if (ptr->tk_thread_id) { /* Tcl_ThreadQueueEvent(ptr->tk_thread_id, &(evq->ev), position); */ Tcl_ThreadQueueEvent(ptr->tk_thread_id, (Tcl_Event*)evq, position); @@ -7247,7 +7079,7 @@ if (TYPE(str) == T_STRING) { volatile VALUE enc; -#ifdef RUBY_VM +#ifdef HAVE_RUBY_ENCODING_H enc = rb_funcall(rb_obj_encoding(str), ID_to_s, 0, 0); #else enc = rb_attr_get(str, ID_at_enc); @@ -7277,7 +7109,7 @@ } else { StringValue(enc); if (strcmp(RSTRING_PTR(enc), "binary") == 0) { -#ifdef RUBY_VM +#ifdef HAVE_RUBY_ENCODING_H rb_enc_associate_index(str, ENCODING_INDEX_BINARY); #endif rb_ivar_set(str, ID_at_enc, ENCODING_NAME_BINARY); @@ -7297,7 +7129,7 @@ } else { StringValue(encodename); if (strcmp(RSTRING_PTR(encodename), "binary") == 0) { -#ifdef RUBY_VM +#ifdef HAVE_RUBY_ENCODING_H rb_enc_associate_index(str, ENCODING_INDEX_BINARY); #endif rb_ivar_set(str, ID_at_enc, ENCODING_NAME_BINARY); @@ -7334,7 +7166,7 @@ /* str = rb_tainted_str_new2(Tcl_DStringValue(&dstr)); */ /* str = rb_str_new2(Tcl_DStringValue(&dstr)); */ str = rb_str_new(Tcl_DStringValue(&dstr), Tcl_DStringLength(&dstr)); -#ifdef RUBY_VM +#ifdef HAVE_RUBY_ENCODING_H rb_enc_associate_index(str, ENCODING_INDEX_UTF8); #endif rb_ivar_set(str, ID_at_enc, ENCODING_NAME_UTF8); @@ -7427,14 +7259,14 @@ if (!NIL_P(enc)) { StringValue(enc); if (strcmp(RSTRING_PTR(enc), "binary") == 0) { -#ifdef RUBY_VM +#ifdef HAVE_RUBY_ENCODING_H rb_enc_associate_index(str, ENCODING_INDEX_BINARY); #endif rb_ivar_set(str, ID_at_enc, ENCODING_NAME_BINARY); rb_thread_critical = thr_crit_bup; return str; } -#ifdef RUBY_VM +#ifdef HAVE_RUBY_ENCODING_H } else if (rb_enc_get_index(str) == ENCODING_INDEX_BINARY) { rb_enc_associate_index(str, ENCODING_INDEX_BINARY); rb_ivar_set(str, ID_at_enc, ENCODING_NAME_BINARY); @@ -7483,7 +7315,7 @@ str = rb_tainted_str_new(s, len); s = (char*)NULL; Tcl_DecrRefCount(tclstr); -#ifdef RUBY_VM +#ifdef HAVE_RUBY_ENCODING_H rb_enc_associate_index(str, ENCODING_INDEX_BINARY); #endif rb_ivar_set(str, ID_at_enc, ENCODING_NAME_BINARY); @@ -7525,7 +7357,7 @@ /* str = rb_tainted_str_new2(Tcl_DStringValue(&dstr)); */ /* str = rb_str_new2(Tcl_DStringValue(&dstr)); */ str = rb_str_new(Tcl_DStringValue(&dstr), Tcl_DStringLength(&dstr)); -#ifdef RUBY_VM +#ifdef HAVE_RUBY_ENCODING_H if (interp) { /* can access encoding_table of TclTkIp */ /* -> try to use encoding_table */ @@ -7634,7 +7466,7 @@ str = rb_str_new(dst_buf, dst_len); if (taint_flag) OBJ_TAINT(str); -#ifdef RUBY_VM +#ifdef HAVE_RUBY_ENCODING_H rb_enc_associate_index(str, ENCODING_INDEX_UTF8); #endif rb_ivar_set(str, ID_at_enc, ENCODING_NAME_UTF8); @@ -7939,35 +7771,19 @@ ret = rb_protect(invoke_tcl_proc, (VALUE)&inf, &status); switch(status) { case TAG_RAISE: -#ifdef RUBY_VM if (NIL_P(rb_errinfo())) { -#else - if (NIL_P(ruby_errinfo)) { -#endif rbtk_pending_exception = rb_exc_new2(rb_eException, "unknown exception"); } else { -#ifdef RUBY_VM rbtk_pending_exception = rb_errinfo(); -#else - rbtk_pending_exception = ruby_errinfo; -#endif } break; case TAG_FATAL: -#ifdef RUBY_VM if (NIL_P(rb_errinfo())) { -#else - if (NIL_P(ruby_errinfo)) { -#endif rbtk_pending_exception = rb_exc_new2(rb_eFatal, "FATAL"); } else { -#ifdef RUBY_VM rbtk_pending_exception = rb_errinfo(); -#else - rbtk_pending_exception = ruby_errinfo; -#endif } } @@ -8351,7 +8167,7 @@ Tcl_QueuePosition position; { struct invoke_queue *ivq; -#ifdef RUBY_VM +#ifdef RUBY_USE_NATIVE_THREAD struct tcltkip *ptr; #endif int *alloc_done; @@ -8371,7 +8187,7 @@ rb_raise(rb_eArgError, "command name missing"); } -#ifdef RUBY_VM +#ifdef RUBY_USE_NATIVE_THREAD ptr = get_ip(ip_obj); DUMP2("status: ptr->tk_thread_id %d", ptr->tk_thread_id); #endif @@ -8379,7 +8195,7 @@ DUMP2("status: eventloopt_thread %lx", eventloop_thread); if ( -#ifdef RUBY_VM +#ifdef RUBY_USE_NATIVE_THREAD (ptr->tk_thread_id == 0 || ptr->tk_thread_id == Tcl_GetCurrentThread()) && #endif @@ -8435,7 +8251,7 @@ /* add the handler to Tcl event queue */ DUMP1("add handler"); -#ifdef RUBY_VM +#ifdef RUBY_USE_NATIVE_THREAD if (ptr->tk_thread_id) { /* Tcl_ThreadQueueEvent(ptr->tk_thread_id, &(ivq->ev), position); */ Tcl_ThreadQueueEvent(ptr->tk_thread_id, (Tcl_Event*)ivq, position); @@ -8961,7 +8777,7 @@ volatile VALUE ary, elem; int idx; int taint_flag = OBJ_TAINTED(list_str); -#ifdef RUBY_VM +#ifdef HAVE_RUBY_ENCODING_H int list_enc_idx; volatile VALUE list_ivar_enc; #endif @@ -8979,7 +8795,7 @@ } StringValue(list_str); -#ifdef RUBY_VM +#ifdef HAVE_RUBY_ENCODING_H list_enc_idx = rb_enc_get_index(list_str); list_ivar_enc = rb_ivar_get(list_str, ID_at_enc); #endif @@ -9021,7 +8837,7 @@ for(idx = 0; idx < objc; idx++) { elem = get_str_from_obj(objv[idx]); -#ifdef RUBY_VM +#ifdef HAVE_RUBY_ENCODING_H if (rb_enc_get_index(elem) == ENCODING_INDEX_BINARY) { rb_enc_associate_index(elem, ENCODING_INDEX_BINARY); rb_ivar_set(elem, ID_at_enc, ENCODING_NAME_BINARY); @@ -9354,7 +9170,7 @@ } #endif -#ifdef RUBY_VM +#ifdef HAVE_RUBY_ENCODING_H if (RTEST(rb_define_dummy_encoding(RSTRING_PTR(name)))) { int idx = rb_enc_find_index(StringValueCStr(name)); return rb_enc_from_encoding(rb_enc_from_index(idx)); @@ -9379,7 +9195,7 @@ } -#ifdef RUBY_VM +#ifdef HAVE_RUBY_ENCODING_H static int update_encoding_table(table, interp, error_mode) VALUE table; @@ -9553,7 +9369,7 @@ } } -#else /* ! RUBY_VM */ +#else /* ! HAVE_RUBY_ENCODING_H */ #if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION >= 1) static int update_encoding_table(table, interp, error_mode) @@ -9680,7 +9496,7 @@ return encoding_table_get_obj_core(table, enc, Qtrue); } -#ifdef RUBY_VM +#ifdef HAVE_RUBY_ENCODING_H static VALUE create_encoding_table(interp) VALUE interp; @@ -9770,7 +9586,7 @@ return table; } -#else /* ! RUBY_VM */ +#else /* ! HAVE_RUBY_ENCODING_H */ #if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION >= 1) static VALUE create_encoding_table(interp) @@ -10003,9 +9819,9 @@ /* --------------------------------------------------------------- */ -#ifdef RUBY_VM +#ifdef HAVE_RUBY_ENCODING_H rb_global_variable(&cRubyEncoding); - cRubyEncoding = rb_const_get(rb_cObject, rb_intern("Encoding")); + cRubyEncoding = rb_path2class("Encoding"); ENCODING_INDEX_UTF8 = rb_enc_to_index(rb_utf8_encoding()); ENCODING_INDEX_BINARY = rb_enc_find_index("binary"); @@ -10261,11 +10077,7 @@ /* if ruby->nativethread-supprt and tcltklib->doen't, the following will cause link-error. */ -#ifdef RUBY_VM ruby_native_thread_p(); -#else - is_ruby_native_thread(); -#endif /* --------------------------------------------------------------- */ Index: ruby_1_8/ext/tk/extconf.rb =================================================================== --- ruby_1_8/ext/tk/extconf.rb (revision 17449) +++ ruby_1_8/ext/tk/extconf.rb (revision 17450) @@ -2,10 +2,17 @@ require 'mkmf' -#is_win32 = (/mswin32|mingw|cygwin|bccwin32/ =~ RUBY_PLATFORM) is_win32 = (/mswin|mingw|cygwin|bccwin|wince/ =~ RUBY_PLATFORM) #is_macosx = (/darwin/ =~ RUBY_PLATFORM) +have_header("ruby/ruby.h") +have_header("ruby/encoding.h") +have_func("ruby_native_thread_p", "ruby.h") +have_func("rb_errinfo", "ruby.h") +have_func("rb_safe_level", "ruby.h") +have_struct_member("struct RArray", "ptr", "ruby.h") +have_struct_member("struct RArray", "len", "ruby.h") + def find_framework(tcl_hdr, tk_hdr) if framework_dir = with_config("tcltk-framework") paths = [framework_dir] Index: ruby_1_8/ext/tk/tkutil/extconf.rb =================================================================== --- ruby_1_8/ext/tk/tkutil/extconf.rb (revision 17449) +++ ruby_1_8/ext/tk/tkutil/extconf.rb (revision 17450) @@ -7,7 +7,9 @@ if has_tk require 'mkmf' + have_header("ruby/ruby.h") have_func("rb_obj_instance_exec", "ruby.h") + have_func("rb_sym_to_s", "ruby.h") have_func("strndup", "string.h") create_makefile('tkutil') end Index: ruby_1_8/ext/tk/tkutil/tkutil.c =================================================================== --- ruby_1_8/ext/tk/tkutil/tkutil.c (revision 17449) +++ ruby_1_8/ext/tk/tkutil/tkutil.c (revision 17450) @@ -11,7 +11,7 @@ #include "ruby.h" -#ifdef RUBY_VM /* Ruby 1.9 */ +#ifdef HAVE_RUBY_RUBY_H /* #include "ruby/ruby.h" */ #include "ruby/signal.h" #include "ruby/st.h" @@ -117,8 +117,8 @@ ID_call, argc - 1, argv + 1); } -static char *cmd_id_head = "ruby_cmd TkUtil callback "; -static char *cmd_id_prefix = "cmd"; +static const char cmd_id_head[] = "ruby_cmd TkUtil callback "; +static const char cmd_id_prefix[] = "cmd"; static VALUE tk_install_cmd_core(cmd) @@ -791,7 +791,7 @@ return fromDefaultEnc_toUTF8(rb_str_new2(rb_id2name(SYM2ID(obj))), self); } } else { -#ifdef RUBY_VM +#ifdef HAVE_RB_SYM_TO_S return rb_sym_to_s(obj); #else return rb_str_new2(rb_id2name(SYM2ID(obj))); Index: ruby_1_8/ext/openssl/ossl.h =================================================================== --- ruby_1_8/ext/openssl/ossl.h (revision 17449) +++ ruby_1_8/ext/openssl/ossl.h (revision 17450) @@ -46,7 +46,11 @@ #if defined(_WIN32) # define OSSL_NO_CONF_API 1 -# include <winsock2.h> +# ifdef USE_WINSOCK2 +# include <winsock2.h> +# else +# include <winsock.h> +# endif #endif #include <errno.h> #include <openssl/err.h> Index: ruby_1_8/ext/stringio/stringio.c =================================================================== --- ruby_1_8/ext/stringio/stringio.c (revision 17449) +++ ruby_1_8/ext/stringio/stringio.c (revision 17450) @@ -269,6 +269,8 @@ break; } ptr->string = string; + ptr->pos = 0; + ptr->lineno = 0; } static VALUE Index: ruby_1_8/test/stringio/test_stringio.rb =================================================================== --- ruby_1_8/test/stringio/test_stringio.rb (revision 17449) +++ ruby_1_8/test/stringio/test_stringio.rb (revision 17450) @@ -40,4 +40,17 @@ end assert_equal("hacker\nother ruby\n", stringio.string) end + + def test_reopen + f = StringIO.new("foo\nbar\nbaz\n") + assert_equal("foo\n", f.gets) + f.reopen("qux\nquux\nquuux\n") + assert_equal("qux\n", f.gets) + + f2 = StringIO.new("") + f2.reopen(f) + assert_equal("quux\n", f2.gets) + ensure + f.close unless f.closed? + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/