* ext/tcltklib/tcltklib.c: rectoring - tcl_protect.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8929 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ocean 2005-08-05 11:22:18 +00:00
parent afb2521096
commit 0ffbf6bca4

View file

@ -2157,56 +2157,25 @@ tcl_protect(proc, data, failed)
ret = rb_protect(proc, data, &status); ret = rb_protect(proc, data, &status);
rb_thread_critical = Qtrue; rb_thread_critical = Qtrue;
if (status) { if (status) {
char *errtype, *buf; char *buf;
int errtype_len, len; VALUE old_gc, type, str;
VALUE old_gc;
old_gc = rb_gc_disable(); old_gc = rb_gc_disable();
switch(status) { switch(status) {
case TAG_RETURN: case TAG_RETURN:
errtype = "LocalJumpError: "; type = eTkCallbackReturn;
errtype_len = strlen(errtype); goto error;
len = errtype_len + RSTRING(rb_obj_as_string(ruby_errinfo))->len;
buf = ALLOC_N(char, len + 1);
memcpy(buf, errtype, errtype_len);
memcpy(buf + errtype_len,
RSTRING(rb_obj_as_string(ruby_errinfo))->ptr,
RSTRING(rb_obj_as_string(ruby_errinfo))->len);
*(buf + len) = 0;
RARRAY(failed)->ptr[0] = rb_exc_new2(eTkCallbackReturn, buf);
free(buf);
break;
case TAG_BREAK: case TAG_BREAK:
errtype = "LocalJumpError: "; type = eTkCallbackBreak;
errtype_len = strlen(errtype); goto error;
len = errtype_len + RSTRING(rb_obj_as_string(ruby_errinfo))->len;
buf = ALLOC_N(char, len + 1);
memcpy(buf, errtype, errtype_len);
memcpy(buf + errtype_len,
RSTRING(rb_obj_as_string(ruby_errinfo))->ptr,
RSTRING(rb_obj_as_string(ruby_errinfo))->len);
*(buf + len) = 0;
RARRAY(failed)->ptr[0] = rb_exc_new2(eTkCallbackBreak, buf);
free(buf);
break;
case TAG_NEXT: case TAG_NEXT:
errtype = "LocalJumpError: "; type = eTkCallbackContinue;
errtype_len = strlen(errtype); goto error;
len = errtype_len + RSTRING(rb_obj_as_string(ruby_errinfo))->len; error:
buf = ALLOC_N(char, len + 1); str = rb_str_new2("LocalJumpError: ");
memcpy(buf, errtype, errtype_len); rb_str_append(str, rb_obj_as_string(ruby_errinfo));
memcpy(buf + errtype_len, RARRAY(failed)->ptr[0] = rb_exc_new3(type, str);
RSTRING(rb_obj_as_string(ruby_errinfo))->ptr,
RSTRING(rb_obj_as_string(ruby_errinfo))->len);
*(buf + len) = 0;
RARRAY(failed)->ptr[0] = rb_exc_new2(eTkCallbackContinue,buf);
free(buf);
break; break;
case TAG_RETRY: case TAG_RETRY:
@ -2815,13 +2784,7 @@ ip_RubyExitCommand(clientData, interp, argc, argv)
Tcl_ResetResult(interp); Tcl_ResetResult(interp);
if (rb_safe_level() >= 4) { if (rb_safe_level() >= 4 || Tcl_IsSafe(interp)) {
ip_finalize(interp);
Tcl_DeleteInterp(interp);
Tcl_Release(interp);
return TCL_OK;
} else if (Tcl_IsSafe(interp)) {
ip_finalize(interp); ip_finalize(interp);
Tcl_DeleteInterp(interp); Tcl_DeleteInterp(interp);
Tcl_Release(interp); Tcl_Release(interp);
@ -4334,7 +4297,6 @@ ip_thread_vwait(self, var)
VALUE var; VALUE var;
{ {
VALUE argv[2]; VALUE argv[2];
VALUE retval;
volatile VALUE cmd_str = rb_str_new2("thread_vwait"); volatile VALUE cmd_str = rb_str_new2("thread_vwait");
argv[0] = cmd_str; argv[0] = cmd_str;
@ -4350,7 +4312,6 @@ ip_thread_tkwait(self, mode, target)
VALUE target; VALUE target;
{ {
VALUE argv[3]; VALUE argv[3];
VALUE retval;
volatile VALUE cmd_str = rb_str_new2("thread_tkwait"); volatile VALUE cmd_str = rb_str_new2("thread_tkwait");
argv[0] = cmd_str; argv[0] = cmd_str;