зеркало из https://github.com/github/ruby.git
* ext/tk/tcltklib.c (rb_thread_critical): fix type.
* ext/tk/tcltklib.c (eventloop_sleep, lib_eventloop_core): int is enough for micro seconds. may need to check overflow in the setter though. * ext/tk/tcltklib.c (RSTRING_LENINT): check overflow if necessary. * ext/tk/tcltklib.c (RbTk_ALLOC_N): wrapper for ckalloc() which takes an int. * ext/tk/tcltklib.c (ip_ruby_cmd_receiver_get, tcltklib_compile_info): get rid overflow. * ext/tk/tcltklib.c (tcltklib_compile_info): constified. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33674 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
ddb9acd9f8
Коммит
ebe0280253
18
ChangeLog
18
ChangeLog
|
@ -1,3 +1,21 @@
|
||||||
|
Tue Nov 8 23:26:49 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* ext/tk/tcltklib.c (rb_thread_critical): fix type.
|
||||||
|
|
||||||
|
* ext/tk/tcltklib.c (eventloop_sleep, lib_eventloop_core): int is
|
||||||
|
enough for micro seconds. may need to check overflow in the
|
||||||
|
setter though.
|
||||||
|
|
||||||
|
* ext/tk/tcltklib.c (RSTRING_LENINT): check overflow if necessary.
|
||||||
|
|
||||||
|
* ext/tk/tcltklib.c (RbTk_ALLOC_N): wrapper for ckalloc() which
|
||||||
|
takes an int.
|
||||||
|
|
||||||
|
* ext/tk/tcltklib.c (ip_ruby_cmd_receiver_get, tcltklib_compile_info):
|
||||||
|
get rid overflow.
|
||||||
|
|
||||||
|
* ext/tk/tcltklib.c (tcltklib_compile_info): constified.
|
||||||
|
|
||||||
Tue Nov 8 20:50:45 2011 Tanaka Akira <akr@fsij.org>
|
Tue Nov 8 20:50:45 2011 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* test/dbm/test_dbm.rb: split tests for read only database.
|
* test/dbm/test_dbm.rb: split tests for read only database.
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef RUBY_VM
|
#ifdef RUBY_VM
|
||||||
static VALUE rb_thread_critical; /* dummy */
|
static int rb_thread_critical; /* dummy */
|
||||||
int rb_thread_check_trap_pending();
|
int rb_thread_check_trap_pending();
|
||||||
#else
|
#else
|
||||||
/* use rb_thread_critical on Ruby 1.8.x */
|
/* use rb_thread_critical on Ruby 1.8.x */
|
||||||
|
@ -31,6 +31,9 @@ int rb_thread_check_trap_pending();
|
||||||
#define RSTRING_PTR(s) (RSTRING(s)->ptr)
|
#define RSTRING_PTR(s) (RSTRING(s)->ptr)
|
||||||
#define RSTRING_LEN(s) (RSTRING(s)->len)
|
#define RSTRING_LEN(s) (RSTRING(s)->len)
|
||||||
#endif
|
#endif
|
||||||
|
#if !defined(RSTRING_LENINT)
|
||||||
|
#define RSTRING_LENINT(s) ((int)RSTRING_LEN(s))
|
||||||
|
#endif
|
||||||
#if !defined(RARRAY_PTR)
|
#if !defined(RARRAY_PTR)
|
||||||
#define RARRAY_PTR(s) (RARRAY(s)->ptr)
|
#define RARRAY_PTR(s) (RARRAY(s)->ptr)
|
||||||
#define RARRAY_LEN(s) (RARRAY(s)->len)
|
#define RARRAY_LEN(s) (RARRAY(s)->len)
|
||||||
|
@ -41,6 +44,7 @@ int rb_thread_check_trap_pending();
|
||||||
#else
|
#else
|
||||||
#define RbTk_OBJ_UNTRUST(x) OBJ_TAINT(x)
|
#define RbTk_OBJ_UNTRUST(x) OBJ_TAINT(x)
|
||||||
#endif
|
#endif
|
||||||
|
#define RbTk_ALLOC_N(type, n) (type *)ckalloc((int)(sizeof(type) * (n)))
|
||||||
|
|
||||||
#if defined(HAVE_RB_PROC_NEW) && !defined(RUBY_VM)
|
#if defined(HAVE_RB_PROC_NEW) && !defined(RUBY_VM)
|
||||||
/* Ruby 1.8 :: rb_proc_new() was hidden from intern.h at 2008/04/22 */
|
/* Ruby 1.8 :: rb_proc_new() was hidden from intern.h at 2008/04/22 */
|
||||||
|
@ -1481,7 +1485,7 @@ call_original_exit(ptr, state)
|
||||||
#if USE_RUBY_ALLOC
|
#if USE_RUBY_ALLOC
|
||||||
argv = (Tcl_Obj **)ALLOC_N(Tcl_Obj *, 3);
|
argv = (Tcl_Obj **)ALLOC_N(Tcl_Obj *, 3);
|
||||||
#else /* not USE_RUBY_ALLOC */
|
#else /* not USE_RUBY_ALLOC */
|
||||||
argv = (Tcl_Obj **)ckalloc(sizeof(Tcl_Obj *) * 3);
|
argv = RbTk_ALLOC_N(Tcl_Obj *, 3);
|
||||||
#if 0 /* use Tcl_Preserve/Release */
|
#if 0 /* use Tcl_Preserve/Release */
|
||||||
Tcl_Preserve((ClientData)argv); /* XXXXXXXX */
|
Tcl_Preserve((ClientData)argv); /* XXXXXXXX */
|
||||||
#endif
|
#endif
|
||||||
|
@ -1521,7 +1525,7 @@ call_original_exit(ptr, state)
|
||||||
#if USE_RUBY_ALLOC
|
#if USE_RUBY_ALLOC
|
||||||
argv = ALLOC_N(char *, 3); /* XXXXXXXXXX */
|
argv = ALLOC_N(char *, 3); /* XXXXXXXXXX */
|
||||||
#else /* not USE_RUBY_ALLOC */
|
#else /* not USE_RUBY_ALLOC */
|
||||||
argv = (CONST84 char **)ckalloc(sizeof(char *) * 3);
|
argv = RbTk_ALLOC_N(CONST84 char *, 3);
|
||||||
#if 0 /* use Tcl_Preserve/Release */
|
#if 0 /* use Tcl_Preserve/Release */
|
||||||
Tcl_Preserve((ClientData)argv); /* XXXXXXXX */
|
Tcl_Preserve((ClientData)argv); /* XXXXXXXX */
|
||||||
#endif
|
#endif
|
||||||
|
@ -1560,7 +1564,7 @@ call_original_exit(ptr, state)
|
||||||
#if USE_RUBY_ALLOC
|
#if USE_RUBY_ALLOC
|
||||||
argv = (char **)ALLOC_N(char *, 3);
|
argv = (char **)ALLOC_N(char *, 3);
|
||||||
#else /* not USE_RUBY_ALLOC */
|
#else /* not USE_RUBY_ALLOC */
|
||||||
argv = (char **)ckalloc(sizeof(char *) * 3);
|
argv = RbTk_ALLOC_N(char *, 3);
|
||||||
#if 0 /* use Tcl_Preserve/Release */
|
#if 0 /* use Tcl_Preserve/Release */
|
||||||
Tcl_Preserve((ClientData)argv); /* XXXXXXXX */
|
Tcl_Preserve((ClientData)argv); /* XXXXXXXX */
|
||||||
#endif
|
#endif
|
||||||
|
@ -2062,7 +2066,7 @@ eventloop_sleep(dummy)
|
||||||
}
|
}
|
||||||
|
|
||||||
t.tv_sec = 0;
|
t.tv_sec = 0;
|
||||||
t.tv_usec = (long)(no_event_wait*1000.0);
|
t.tv_usec = (int)(no_event_wait*1000.0);
|
||||||
|
|
||||||
#ifdef HAVE_NATIVETHREAD
|
#ifdef HAVE_NATIVETHREAD
|
||||||
#ifndef RUBY_USE_NATIVE_THREAD
|
#ifndef RUBY_USE_NATIVE_THREAD
|
||||||
|
@ -2193,7 +2197,7 @@ lib_eventloop_core(check_root, update_flag, check_var, interp)
|
||||||
if (update_flag) DUMP1("update loop start!!");
|
if (update_flag) DUMP1("update loop start!!");
|
||||||
|
|
||||||
t.tv_sec = 0;
|
t.tv_sec = 0;
|
||||||
t.tv_usec = 1000 * (long)no_event_wait;
|
t.tv_usec = 1000 * no_event_wait;
|
||||||
|
|
||||||
Tcl_DeleteTimerHandler(timer_token);
|
Tcl_DeleteTimerHandler(timer_token);
|
||||||
run_timer_flag = 0;
|
run_timer_flag = 0;
|
||||||
|
@ -2676,7 +2680,7 @@ lib_eventloop_launcher(check_root, update_flag, check_var, interp)
|
||||||
{
|
{
|
||||||
volatile VALUE parent_evloop = eventloop_thread;
|
volatile VALUE parent_evloop = eventloop_thread;
|
||||||
struct evloop_params *args = ALLOC(struct evloop_params);
|
struct evloop_params *args = ALLOC(struct evloop_params);
|
||||||
/* struct evloop_params *args = (struct evloop_params *)ckalloc(sizeof(struct evloop_params)); */
|
/* struct evloop_params *args = RbTk_ALLOC_N(struct evloop_params, 1); */
|
||||||
|
|
||||||
tcl_stubs_check();
|
tcl_stubs_check();
|
||||||
|
|
||||||
|
@ -2956,10 +2960,10 @@ lib_thread_callback(argc, argv, self)
|
||||||
}
|
}
|
||||||
|
|
||||||
q = (struct thread_call_proc_arg *)ALLOC(struct thread_call_proc_arg);
|
q = (struct thread_call_proc_arg *)ALLOC(struct thread_call_proc_arg);
|
||||||
/* q = (struct thread_call_proc_arg *)ckalloc(sizeof(struct thread_call_proc_arg)); */
|
/* q = RbTk_ALLOC_N(struct thread_call_proc_arg, 1); */
|
||||||
q->proc = proc;
|
q->proc = proc;
|
||||||
q->done = (int*)ALLOC(int);
|
q->done = (int*)ALLOC(int);
|
||||||
/* q->done = (int*)ckalloc(sizeof(int)); */
|
/* q->done = RbTk_ALLOC_N(int, 1); */
|
||||||
*(q->done) = 0;
|
*(q->done) = 0;
|
||||||
|
|
||||||
/* create call-proc thread */
|
/* create call-proc thread */
|
||||||
|
@ -3121,14 +3125,14 @@ ip_set_exc_message(interp, exc)
|
||||||
/* buf = ALLOC_N(char, (RSTRING(msg)->len)+1);*/
|
/* buf = ALLOC_N(char, (RSTRING(msg)->len)+1);*/
|
||||||
/* memcpy(buf, RSTRING(msg)->ptr, RSTRING(msg)->len);*/
|
/* memcpy(buf, RSTRING(msg)->ptr, RSTRING(msg)->len);*/
|
||||||
/* buf[RSTRING(msg)->len] = 0; */
|
/* buf[RSTRING(msg)->len] = 0; */
|
||||||
buf = ALLOC_N(char, RSTRING_LEN(msg)+1);
|
buf = ALLOC_N(char, RSTRING_LENINT(msg)+1);
|
||||||
/* buf = ckalloc(sizeof(char)*((RSTRING_LEN(msg))+1)); */
|
/* buf = ckalloc(RSTRING_LENINT(msg)+1); */
|
||||||
memcpy(buf, RSTRING_PTR(msg), RSTRING_LEN(msg));
|
memcpy(buf, RSTRING_PTR(msg), RSTRING_LEN(msg));
|
||||||
buf[RSTRING_LEN(msg)] = 0;
|
buf[RSTRING_LEN(msg)] = 0;
|
||||||
|
|
||||||
Tcl_DStringInit(&dstr);
|
Tcl_DStringInit(&dstr);
|
||||||
Tcl_DStringFree(&dstr);
|
Tcl_DStringFree(&dstr);
|
||||||
Tcl_ExternalToUtfDString(encoding, buf, RSTRING_LEN(msg), &dstr);
|
Tcl_ExternalToUtfDString(encoding, buf, RSTRING_LENINT(msg), &dstr);
|
||||||
|
|
||||||
Tcl_AppendResult(interp, Tcl_DStringValue(&dstr), (char*)NULL);
|
Tcl_AppendResult(interp, Tcl_DStringValue(&dstr), (char*)NULL);
|
||||||
DUMP2("error message:%s", Tcl_DStringValue(&dstr));
|
DUMP2("error message:%s", Tcl_DStringValue(&dstr));
|
||||||
|
@ -3555,7 +3559,7 @@ ip_ruby_cmd_receiver_get(str)
|
||||||
} else {
|
} else {
|
||||||
/* global variable omitted '$' */
|
/* global variable omitted '$' */
|
||||||
char *buf;
|
char *buf;
|
||||||
int len;
|
size_t len;
|
||||||
|
|
||||||
len = strlen(str);
|
len = strlen(str);
|
||||||
buf = ALLOC_N(char, len + 2);
|
buf = ALLOC_N(char, len + 2);
|
||||||
|
@ -3677,7 +3681,7 @@ ip_ruby_cmd(clientData, interp, argc, argv)
|
||||||
|
|
||||||
/* allocate */
|
/* allocate */
|
||||||
arg = ALLOC(struct cmd_body_arg);
|
arg = ALLOC(struct cmd_body_arg);
|
||||||
/* arg = (struct cmd_body_arg *)ckalloc(sizeof(struct cmd_body_arg)); */
|
/* arg = RbTk_ALLOC_N(struct cmd_body_arg, 1); */
|
||||||
|
|
||||||
arg->receiver = receiver;
|
arg->receiver = receiver;
|
||||||
arg->method = method;
|
arg->method = method;
|
||||||
|
@ -4116,7 +4120,7 @@ ip_rb_threadUpdateCommand(clientData, interp, objc, objv)
|
||||||
DUMP1("pass argument check");
|
DUMP1("pass argument check");
|
||||||
|
|
||||||
/* param = (struct th_update_param *)Tcl_Alloc(sizeof(struct th_update_param)); */
|
/* param = (struct th_update_param *)Tcl_Alloc(sizeof(struct th_update_param)); */
|
||||||
param = (struct th_update_param *)ckalloc(sizeof(struct th_update_param));
|
param = RbTk_ALLOC_N(struct th_update_param, 1);
|
||||||
#if 0 /* use Tcl_Preserve/Release */
|
#if 0 /* use Tcl_Preserve/Release */
|
||||||
Tcl_Preserve((ClientData)param);
|
Tcl_Preserve((ClientData)param);
|
||||||
#endif
|
#endif
|
||||||
|
@ -4980,7 +4984,7 @@ ip_rb_threadVwaitCommand(clientData, interp, objc, objv)
|
||||||
rb_thread_critical = Qtrue;
|
rb_thread_critical = Qtrue;
|
||||||
|
|
||||||
/* param = (struct th_vwait_param *)Tcl_Alloc(sizeof(struct th_vwait_param)); */
|
/* param = (struct th_vwait_param *)Tcl_Alloc(sizeof(struct th_vwait_param)); */
|
||||||
param = (struct th_vwait_param *)ckalloc(sizeof(struct th_vwait_param));
|
param = RbTk_ALLOC_N(struct th_vwait_param, 1);
|
||||||
#if 1 /* use Tcl_Preserve/Release */
|
#if 1 /* use Tcl_Preserve/Release */
|
||||||
Tcl_Preserve((ClientData)param);
|
Tcl_Preserve((ClientData)param);
|
||||||
#endif
|
#endif
|
||||||
|
@ -5196,7 +5200,7 @@ ip_rb_threadTkWaitCommand(clientData, interp, objc, objv)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* param = (struct th_vwait_param *)Tcl_Alloc(sizeof(struct th_vwait_param)); */
|
/* param = (struct th_vwait_param *)Tcl_Alloc(sizeof(struct th_vwait_param)); */
|
||||||
param = (struct th_vwait_param *)ckalloc(sizeof(struct th_vwait_param));
|
param = RbTk_ALLOC_N(struct th_vwait_param, 1);
|
||||||
#if 1 /* use Tcl_Preserve/Release */
|
#if 1 /* use Tcl_Preserve/Release */
|
||||||
Tcl_Preserve((ClientData)param);
|
Tcl_Preserve((ClientData)param);
|
||||||
#endif
|
#endif
|
||||||
|
@ -6042,7 +6046,7 @@ ip_rbNamespaceObjCmd(clientData, interp, objc, objv)
|
||||||
char **argv;
|
char **argv;
|
||||||
|
|
||||||
/* argv = (char **)Tcl_Alloc(sizeof(char *) * (objc + 1)); */
|
/* argv = (char **)Tcl_Alloc(sizeof(char *) * (objc + 1)); */
|
||||||
argv = (char **)ckalloc(sizeof(char *) * (objc + 1));
|
argv = RbTk_ALLOC_N(char *, (objc + 1));
|
||||||
#if 0 /* use Tcl_Preserve/Release */
|
#if 0 /* use Tcl_Preserve/Release */
|
||||||
Tcl_Preserve((ClientData)argv); /* XXXXXXXX */
|
Tcl_Preserve((ClientData)argv); /* XXXXXXXX */
|
||||||
#endif
|
#endif
|
||||||
|
@ -6151,7 +6155,7 @@ ip_init(argc, argv, self)
|
||||||
/* create object */
|
/* create object */
|
||||||
Data_Get_Struct(self, struct tcltkip, ptr);
|
Data_Get_Struct(self, struct tcltkip, ptr);
|
||||||
ptr = ALLOC(struct tcltkip);
|
ptr = ALLOC(struct tcltkip);
|
||||||
/* ptr = (struct tcltkip *)ckalloc(sizeof(struct tcltkip)); */
|
/* ptr = RbTk_ALLOC_N(struct tcltkip, 1); */
|
||||||
DATA_PTR(self) = ptr;
|
DATA_PTR(self) = ptr;
|
||||||
#ifdef RUBY_USE_NATIVE_THREAD
|
#ifdef RUBY_USE_NATIVE_THREAD
|
||||||
ptr->tk_thread_id = 0;
|
ptr->tk_thread_id = 0;
|
||||||
|
@ -6388,7 +6392,7 @@ ip_create_slave_core(interp, argc, argv)
|
||||||
{
|
{
|
||||||
struct tcltkip *master = get_ip(interp);
|
struct tcltkip *master = get_ip(interp);
|
||||||
struct tcltkip *slave = ALLOC(struct tcltkip);
|
struct tcltkip *slave = ALLOC(struct tcltkip);
|
||||||
/* struct tcltkip *slave = (struct tcltkip *)ckalloc(sizeof(struct tcltkip)); */
|
/* struct tcltkip *slave = RbTk_ALLOC_N(struct tcltkip, 1); */
|
||||||
VALUE safemode;
|
VALUE safemode;
|
||||||
VALUE name;
|
VALUE name;
|
||||||
int safe;
|
int safe;
|
||||||
|
@ -6928,22 +6932,22 @@ get_obj_from_str(str)
|
||||||
StringValue(enc);
|
StringValue(enc);
|
||||||
if (strcmp(RSTRING_PTR(enc), "binary") == 0) {
|
if (strcmp(RSTRING_PTR(enc), "binary") == 0) {
|
||||||
/* binary string */
|
/* binary string */
|
||||||
return Tcl_NewByteArrayObj((const unsigned char *)s, RSTRING_LEN(str));
|
return Tcl_NewByteArrayObj((const unsigned char *)s, RSTRING_LENINT(str));
|
||||||
} else {
|
} else {
|
||||||
/* text string */
|
/* text string */
|
||||||
return Tcl_NewStringObj(s, RSTRING_LEN(str));
|
return Tcl_NewStringObj(s, RSTRING_LENINT(str));
|
||||||
}
|
}
|
||||||
#ifdef HAVE_RUBY_ENCODING_H
|
#ifdef HAVE_RUBY_ENCODING_H
|
||||||
} else if (rb_enc_get_index(str) == ENCODING_INDEX_BINARY) {
|
} else if (rb_enc_get_index(str) == ENCODING_INDEX_BINARY) {
|
||||||
/* binary string */
|
/* binary string */
|
||||||
return Tcl_NewByteArrayObj((const unsigned char *)s, RSTRING_LEN(str));
|
return Tcl_NewByteArrayObj((const unsigned char *)s, RSTRING_LENINT(str));
|
||||||
#endif
|
#endif
|
||||||
} else if (memchr(s, 0, RSTRING_LEN(str))) {
|
} else if (memchr(s, 0, RSTRING_LEN(str))) {
|
||||||
/* probably binary string */
|
/* probably binary string */
|
||||||
return Tcl_NewByteArrayObj((const unsigned char *)s, RSTRING_LEN(str));
|
return Tcl_NewByteArrayObj((const unsigned char *)s, RSTRING_LENINT(str));
|
||||||
} else {
|
} else {
|
||||||
/* probably text string */
|
/* probably text string */
|
||||||
return Tcl_NewStringObj(s, RSTRING_LEN(str));
|
return Tcl_NewStringObj(s, RSTRING_LENINT(str));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -7149,7 +7153,7 @@ tk_funcall(func, argc, argv, obj)
|
||||||
/* allocate memory (argv cross over thread : must be in heap) */
|
/* allocate memory (argv cross over thread : must be in heap) */
|
||||||
if (argv) {
|
if (argv) {
|
||||||
/* VALUE *temp = ALLOC_N(VALUE, argc); */
|
/* VALUE *temp = ALLOC_N(VALUE, argc); */
|
||||||
VALUE *temp = (VALUE*)ckalloc(sizeof(VALUE) * argc);
|
VALUE *temp = RbTk_ALLOC_N(VALUE, argc);
|
||||||
#if 0 /* use Tcl_Preserve/Release */
|
#if 0 /* use Tcl_Preserve/Release */
|
||||||
Tcl_Preserve((ClientData)temp); /* XXXXXXXX */
|
Tcl_Preserve((ClientData)temp); /* XXXXXXXX */
|
||||||
#endif
|
#endif
|
||||||
|
@ -7159,7 +7163,7 @@ tk_funcall(func, argc, argv, obj)
|
||||||
|
|
||||||
/* allocate memory (keep result) */
|
/* allocate memory (keep result) */
|
||||||
/* alloc_done = (int*)ALLOC(int); */
|
/* alloc_done = (int*)ALLOC(int); */
|
||||||
alloc_done = (int*)ckalloc(sizeof(int));
|
alloc_done = RbTk_ALLOC_N(int, 1);
|
||||||
#if 0 /* use Tcl_Preserve/Release */
|
#if 0 /* use Tcl_Preserve/Release */
|
||||||
Tcl_Preserve((ClientData)alloc_done); /* XXXXXXXX */
|
Tcl_Preserve((ClientData)alloc_done); /* XXXXXXXX */
|
||||||
#endif
|
#endif
|
||||||
|
@ -7167,7 +7171,7 @@ tk_funcall(func, argc, argv, obj)
|
||||||
|
|
||||||
/* allocate memory (freed by Tcl_ServiceEvent) */
|
/* allocate memory (freed by Tcl_ServiceEvent) */
|
||||||
/* callq = (struct call_queue *)Tcl_Alloc(sizeof(struct call_queue)); */
|
/* callq = (struct call_queue *)Tcl_Alloc(sizeof(struct call_queue)); */
|
||||||
callq = (struct call_queue *)ckalloc(sizeof(struct call_queue));
|
callq = RbTk_ALLOC_N(struct call_queue, 1);
|
||||||
#if 0 /* use Tcl_Preserve/Release */
|
#if 0 /* use Tcl_Preserve/Release */
|
||||||
Tcl_Preserve(callq);
|
Tcl_Preserve(callq);
|
||||||
#endif
|
#endif
|
||||||
|
@ -7632,7 +7636,7 @@ ip_eval(self, str)
|
||||||
} else {
|
} else {
|
||||||
DUMP2("eval from current eventloop %lx", current);
|
DUMP2("eval from current eventloop %lx", current);
|
||||||
}
|
}
|
||||||
result = ip_eval_real(self, RSTRING_PTR(str), RSTRING_LEN(str));
|
result = ip_eval_real(self, RSTRING_PTR(str), RSTRING_LENINT(str));
|
||||||
if (rb_obj_is_kind_of(result, rb_eException)) {
|
if (rb_obj_is_kind_of(result, rb_eException)) {
|
||||||
rb_exc_raise(result);
|
rb_exc_raise(result);
|
||||||
}
|
}
|
||||||
|
@ -7646,14 +7650,14 @@ ip_eval(self, str)
|
||||||
|
|
||||||
/* allocate memory (keep result) */
|
/* allocate memory (keep result) */
|
||||||
/* alloc_done = (int*)ALLOC(int); */
|
/* alloc_done = (int*)ALLOC(int); */
|
||||||
alloc_done = (int*)ckalloc(sizeof(int));
|
alloc_done = RbTk_ALLOC_N(int, 1);
|
||||||
#if 0 /* use Tcl_Preserve/Release */
|
#if 0 /* use Tcl_Preserve/Release */
|
||||||
Tcl_Preserve((ClientData)alloc_done); /* XXXXXXXX */
|
Tcl_Preserve((ClientData)alloc_done); /* XXXXXXXX */
|
||||||
#endif
|
#endif
|
||||||
*alloc_done = 0;
|
*alloc_done = 0;
|
||||||
|
|
||||||
/* eval_str = ALLOC_N(char, RSTRING_LEN(str) + 1); */
|
/* eval_str = ALLOC_N(char, RSTRING_LEN(str) + 1); */
|
||||||
eval_str = ckalloc(sizeof(char) * (RSTRING_LEN(str) + 1));
|
eval_str = ckalloc(RSTRING_LENINT(str) + 1);
|
||||||
#if 0 /* use Tcl_Preserve/Release */
|
#if 0 /* use Tcl_Preserve/Release */
|
||||||
Tcl_Preserve((ClientData)eval_str); /* XXXXXXXX */
|
Tcl_Preserve((ClientData)eval_str); /* XXXXXXXX */
|
||||||
#endif
|
#endif
|
||||||
|
@ -7662,7 +7666,7 @@ ip_eval(self, str)
|
||||||
|
|
||||||
/* allocate memory (freed by Tcl_ServiceEvent) */
|
/* allocate memory (freed by Tcl_ServiceEvent) */
|
||||||
/* evq = (struct eval_queue *)Tcl_Alloc(sizeof(struct eval_queue)); */
|
/* evq = (struct eval_queue *)Tcl_Alloc(sizeof(struct eval_queue)); */
|
||||||
evq = (struct eval_queue *)ckalloc(sizeof(struct eval_queue));
|
evq = RbTk_ALLOC_N(struct eval_queue, 1);
|
||||||
#if 0 /* use Tcl_Preserve/Release */
|
#if 0 /* use Tcl_Preserve/Release */
|
||||||
Tcl_Preserve(evq);
|
Tcl_Preserve(evq);
|
||||||
#endif
|
#endif
|
||||||
|
@ -7673,7 +7677,7 @@ ip_eval(self, str)
|
||||||
/* construct event data */
|
/* construct event data */
|
||||||
evq->done = alloc_done;
|
evq->done = alloc_done;
|
||||||
evq->str = eval_str;
|
evq->str = eval_str;
|
||||||
evq->len = RSTRING_LEN(str);
|
evq->len = RSTRING_LENINT(str);
|
||||||
evq->interp = ip_obj;
|
evq->interp = ip_obj;
|
||||||
evq->result = result;
|
evq->result = result;
|
||||||
evq->thread = current;
|
evq->thread = current;
|
||||||
|
@ -8055,14 +8059,14 @@ lib_toUTF8_core(ip_obj, src, encodename)
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
buf = ALLOC_N(char, RSTRING_LEN(str)+1);
|
buf = ALLOC_N(char, RSTRING_LEN(str)+1);
|
||||||
/* buf = ckalloc(sizeof(char) * (RSTRING_LEN(str)+1)); */
|
/* buf = ckalloc(sizeof(char) * (RSTRING_LENINT(str)+1)); */
|
||||||
memcpy(buf, RSTRING_PTR(str), RSTRING_LEN(str));
|
memcpy(buf, RSTRING_PTR(str), RSTRING_LEN(str));
|
||||||
buf[RSTRING_LEN(str)] = 0;
|
buf[RSTRING_LEN(str)] = 0;
|
||||||
|
|
||||||
Tcl_DStringInit(&dstr);
|
Tcl_DStringInit(&dstr);
|
||||||
Tcl_DStringFree(&dstr);
|
Tcl_DStringFree(&dstr);
|
||||||
/* Tcl_ExternalToUtfDString(encoding,buf,strlen(buf),&dstr); */
|
/* Tcl_ExternalToUtfDString(encoding,buf,strlen(buf),&dstr); */
|
||||||
Tcl_ExternalToUtfDString(encoding, buf, RSTRING_LEN(str), &dstr);
|
Tcl_ExternalToUtfDString(encoding, buf, RSTRING_LENINT(str), &dstr);
|
||||||
|
|
||||||
/* str = rb_tainted_str_new2(Tcl_DStringValue(&dstr)); */
|
/* str = rb_tainted_str_new2(Tcl_DStringValue(&dstr)); */
|
||||||
/* str = rb_str_new2(Tcl_DStringValue(&dstr)); */
|
/* str = rb_str_new2(Tcl_DStringValue(&dstr)); */
|
||||||
|
@ -8210,7 +8214,7 @@ lib_fromUTF8_core(ip_obj, src, encodename)
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
StringValue(str);
|
StringValue(str);
|
||||||
tclstr = Tcl_NewStringObj(RSTRING_PTR(str), RSTRING_LEN(str));
|
tclstr = Tcl_NewStringObj(RSTRING_PTR(str), RSTRING_LENINT(str));
|
||||||
Tcl_IncrRefCount(tclstr);
|
Tcl_IncrRefCount(tclstr);
|
||||||
s = (char*)Tcl_GetByteArrayFromObj(tclstr, &len);
|
s = (char*)Tcl_GetByteArrayFromObj(tclstr, &len);
|
||||||
str = rb_tainted_str_new(s, len);
|
str = rb_tainted_str_new(s, len);
|
||||||
|
@ -8246,14 +8250,14 @@ lib_fromUTF8_core(ip_obj, src, encodename)
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = ALLOC_N(char, RSTRING_LEN(str)+1);
|
buf = ALLOC_N(char, RSTRING_LEN(str)+1);
|
||||||
/* buf = ckalloc(sizeof(char) * (RSTRING_LEN(str)+1)); */
|
/* buf = ckalloc(sizeof(char) * (RSTRING_LENINT(str)+1)); */
|
||||||
memcpy(buf, RSTRING_PTR(str), RSTRING_LEN(str));
|
memcpy(buf, RSTRING_PTR(str), RSTRING_LEN(str));
|
||||||
buf[RSTRING_LEN(str)] = 0;
|
buf[RSTRING_LEN(str)] = 0;
|
||||||
|
|
||||||
Tcl_DStringInit(&dstr);
|
Tcl_DStringInit(&dstr);
|
||||||
Tcl_DStringFree(&dstr);
|
Tcl_DStringFree(&dstr);
|
||||||
/* Tcl_UtfToExternalDString(encoding,buf,strlen(buf),&dstr); */
|
/* Tcl_UtfToExternalDString(encoding,buf,strlen(buf),&dstr); */
|
||||||
Tcl_UtfToExternalDString(encoding,buf,RSTRING_LEN(str),&dstr);
|
Tcl_UtfToExternalDString(encoding,buf,RSTRING_LENINT(str),&dstr);
|
||||||
|
|
||||||
/* str = rb_tainted_str_new2(Tcl_DStringValue(&dstr)); */
|
/* str = rb_tainted_str_new2(Tcl_DStringValue(&dstr)); */
|
||||||
/* str = rb_str_new2(Tcl_DStringValue(&dstr)); */
|
/* str = rb_str_new2(Tcl_DStringValue(&dstr)); */
|
||||||
|
@ -8342,7 +8346,7 @@ lib_UTF_backslash_core(self, str, all_bs)
|
||||||
rb_thread_critical = Qtrue;
|
rb_thread_critical = Qtrue;
|
||||||
|
|
||||||
/* src_buf = ALLOC_N(char, RSTRING_LEN(str)+1); */
|
/* src_buf = ALLOC_N(char, RSTRING_LEN(str)+1); */
|
||||||
src_buf = ckalloc(sizeof(char) * (RSTRING_LEN(str)+1));
|
src_buf = ckalloc(RSTRING_LENINT(str)+1);
|
||||||
#if 0 /* use Tcl_Preserve/Release */
|
#if 0 /* use Tcl_Preserve/Release */
|
||||||
Tcl_Preserve((ClientData)src_buf); /* XXXXXXXX */
|
Tcl_Preserve((ClientData)src_buf); /* XXXXXXXX */
|
||||||
#endif
|
#endif
|
||||||
|
@ -8350,7 +8354,7 @@ lib_UTF_backslash_core(self, str, all_bs)
|
||||||
src_buf[RSTRING_LEN(str)] = 0;
|
src_buf[RSTRING_LEN(str)] = 0;
|
||||||
|
|
||||||
/* dst_buf = ALLOC_N(char, RSTRING_LEN(str)+1); */
|
/* dst_buf = ALLOC_N(char, RSTRING_LEN(str)+1); */
|
||||||
dst_buf = ckalloc(sizeof(char) * (RSTRING_LEN(str)+1));
|
dst_buf = ckalloc(RSTRING_LENINT(str)+1);
|
||||||
#if 0 /* use Tcl_Preserve/Release */
|
#if 0 /* use Tcl_Preserve/Release */
|
||||||
Tcl_Preserve((ClientData)dst_buf); /* XXXXXXXX */
|
Tcl_Preserve((ClientData)dst_buf); /* XXXXXXXX */
|
||||||
#endif
|
#endif
|
||||||
|
@ -8487,7 +8491,7 @@ invoke_tcl_proc(arg)
|
||||||
if (!inf->cmdinfo.isNativeObjectProc) {
|
if (!inf->cmdinfo.isNativeObjectProc) {
|
||||||
/* string interface */
|
/* string interface */
|
||||||
/* argv = (char **)ALLOC_N(char *, argc+1);*/ /* XXXXXXXXXX */
|
/* argv = (char **)ALLOC_N(char *, argc+1);*/ /* XXXXXXXXXX */
|
||||||
argv = (char **)ckalloc(sizeof(char *)*(argc+1));
|
argv = RbTk_ALLOC_N(char *, (argc+1));
|
||||||
#if 0 /* use Tcl_Preserve/Release */
|
#if 0 /* use Tcl_Preserve/Release */
|
||||||
Tcl_Preserve((ClientData)argv); /* XXXXXXXX */
|
Tcl_Preserve((ClientData)argv); /* XXXXXXXX */
|
||||||
#endif
|
#endif
|
||||||
|
@ -8633,7 +8637,7 @@ ip_invoke_core(interp, argc, argv)
|
||||||
|
|
||||||
#if TCL_MAJOR_VERSION >= 8
|
#if TCL_MAJOR_VERSION >= 8
|
||||||
/* unknown_objv = (Tcl_Obj **)ALLOC_N(Tcl_Obj *, objc+2); */
|
/* unknown_objv = (Tcl_Obj **)ALLOC_N(Tcl_Obj *, objc+2); */
|
||||||
unknown_objv = (Tcl_Obj **)ckalloc(sizeof(Tcl_Obj *) * (objc+2));
|
unknown_objv = RbTk_ALLOC_N(Tcl_Obj *, (objc+2));
|
||||||
#if 0 /* use Tcl_Preserve/Release */
|
#if 0 /* use Tcl_Preserve/Release */
|
||||||
Tcl_Preserve((ClientData)unknown_objv); /* XXXXXXXX */
|
Tcl_Preserve((ClientData)unknown_objv); /* XXXXXXXX */
|
||||||
#endif
|
#endif
|
||||||
|
@ -8644,7 +8648,7 @@ ip_invoke_core(interp, argc, argv)
|
||||||
objv = unknown_objv;
|
objv = unknown_objv;
|
||||||
#else
|
#else
|
||||||
/* unknown_argv = (char **)ALLOC_N(char *, argc+2); */
|
/* unknown_argv = (char **)ALLOC_N(char *, argc+2); */
|
||||||
unknown_argv = (char **)ckalloc(sizeof(char *) * (argc+2));
|
unknown_argv = RbTk_ALLOC_N(char *, (argc+2));
|
||||||
#if 0 /* use Tcl_Preserve/Release */
|
#if 0 /* use Tcl_Preserve/Release */
|
||||||
Tcl_Preserve((ClientData)unknown_argv); /* XXXXXXXX */
|
Tcl_Preserve((ClientData)unknown_argv); /* XXXXXXXX */
|
||||||
#endif
|
#endif
|
||||||
|
@ -8701,7 +8705,7 @@ ip_invoke_core(interp, argc, argv)
|
||||||
|
|
||||||
/* string interface */
|
/* string interface */
|
||||||
/* argv = (char **)ALLOC_N(char *, argc+1); */
|
/* argv = (char **)ALLOC_N(char *, argc+1); */
|
||||||
argv = (char **)ckalloc(sizeof(char *) * (argc+1));
|
argv = RbTk_ALLOC_N(char *, (argc+1));
|
||||||
#if 0 /* use Tcl_Preserve/Release */
|
#if 0 /* use Tcl_Preserve/Release */
|
||||||
Tcl_Preserve((ClientData)argv); /* XXXXXXXX */
|
Tcl_Preserve((ClientData)argv); /* XXXXXXXX */
|
||||||
#endif
|
#endif
|
||||||
|
@ -8846,7 +8850,7 @@ alloc_invoke_arguments(argc, argv)
|
||||||
/* memory allocation */
|
/* memory allocation */
|
||||||
#if TCL_MAJOR_VERSION >= 8
|
#if TCL_MAJOR_VERSION >= 8
|
||||||
/* av = ALLOC_N(Tcl_Obj *, argc+1);*/ /* XXXXXXXXXX */
|
/* av = ALLOC_N(Tcl_Obj *, argc+1);*/ /* XXXXXXXXXX */
|
||||||
av = (Tcl_Obj**)ckalloc(sizeof(Tcl_Obj *)*(argc+1));
|
av = RbTk_ALLOC_N(Tcl_Obj *, (argc+1));
|
||||||
#if 0 /* use Tcl_Preserve/Release */
|
#if 0 /* use Tcl_Preserve/Release */
|
||||||
Tcl_Preserve((ClientData)av); /* XXXXXXXX */
|
Tcl_Preserve((ClientData)av); /* XXXXXXXX */
|
||||||
#endif
|
#endif
|
||||||
|
@ -8859,7 +8863,7 @@ alloc_invoke_arguments(argc, argv)
|
||||||
#else /* TCL_MAJOR_VERSION < 8 */
|
#else /* TCL_MAJOR_VERSION < 8 */
|
||||||
/* string interface */
|
/* string interface */
|
||||||
/* av = ALLOC_N(char *, argc+1); */
|
/* av = ALLOC_N(char *, argc+1); */
|
||||||
av = (char**)ckalloc(sizeof(char *) * (argc+1));
|
av = RbTk_ALLOC_N(char *, (argc+1));
|
||||||
#if 0 /* use Tcl_Preserve/Release */
|
#if 0 /* use Tcl_Preserve/Release */
|
||||||
Tcl_Preserve((ClientData)av); /* XXXXXXXX */
|
Tcl_Preserve((ClientData)av); /* XXXXXXXX */
|
||||||
#endif
|
#endif
|
||||||
|
@ -9139,7 +9143,7 @@ ip_invoke_with_position(argc, argv, obj, position)
|
||||||
|
|
||||||
/* allocate memory (keep result) */
|
/* allocate memory (keep result) */
|
||||||
/* alloc_done = (int*)ALLOC(int); */
|
/* alloc_done = (int*)ALLOC(int); */
|
||||||
alloc_done = (int*)ckalloc(sizeof(int));
|
alloc_done = RbTk_ALLOC_N(int, 1);
|
||||||
#if 0 /* use Tcl_Preserve/Release */
|
#if 0 /* use Tcl_Preserve/Release */
|
||||||
Tcl_Preserve((ClientData)alloc_done); /* XXXXXXXX */
|
Tcl_Preserve((ClientData)alloc_done); /* XXXXXXXX */
|
||||||
#endif
|
#endif
|
||||||
|
@ -9147,7 +9151,7 @@ ip_invoke_with_position(argc, argv, obj, position)
|
||||||
|
|
||||||
/* allocate memory (freed by Tcl_ServiceEvent) */
|
/* allocate memory (freed by Tcl_ServiceEvent) */
|
||||||
/* ivq = (struct invoke_queue *)Tcl_Alloc(sizeof(struct invoke_queue)); */
|
/* ivq = (struct invoke_queue *)Tcl_Alloc(sizeof(struct invoke_queue)); */
|
||||||
ivq = (struct invoke_queue *)ckalloc(sizeof(struct invoke_queue));
|
ivq = RbTk_ALLOC_N(struct invoke_queue, 1);
|
||||||
#if 0 /* use Tcl_Preserve/Release */
|
#if 0 /* use Tcl_Preserve/Release */
|
||||||
Tcl_Preserve((ClientData)ivq); /* XXXXXXXX */
|
Tcl_Preserve((ClientData)ivq); /* XXXXXXXX */
|
||||||
#endif
|
#endif
|
||||||
|
@ -9869,7 +9873,7 @@ lib_merge_tklist(argc, argv, obj)
|
||||||
|
|
||||||
/* based on Tcl/Tk's Tcl_Merge() */
|
/* based on Tcl/Tk's Tcl_Merge() */
|
||||||
/* flagPtr = ALLOC_N(int, argc); */
|
/* flagPtr = ALLOC_N(int, argc); */
|
||||||
flagPtr = (int *)ckalloc(sizeof(int) * argc);
|
flagPtr = RbTk_ALLOC_N(int, argc);
|
||||||
#if 0 /* use Tcl_Preserve/Release */
|
#if 0 /* use Tcl_Preserve/Release */
|
||||||
Tcl_Preserve((ClientData)flagPtr); /* XXXXXXXXXX */
|
Tcl_Preserve((ClientData)flagPtr); /* XXXXXXXXXX */
|
||||||
#endif
|
#endif
|
||||||
|
@ -9880,7 +9884,7 @@ lib_merge_tklist(argc, argv, obj)
|
||||||
if (OBJ_TAINTED(argv[num])) taint_flag = 1;
|
if (OBJ_TAINTED(argv[num])) taint_flag = 1;
|
||||||
dst = StringValuePtr(argv[num]);
|
dst = StringValuePtr(argv[num]);
|
||||||
#if TCL_MAJOR_VERSION >= 8
|
#if TCL_MAJOR_VERSION >= 8
|
||||||
len += Tcl_ScanCountedElement(dst, RSTRING_LEN(argv[num]),
|
len += Tcl_ScanCountedElement(dst, RSTRING_LENINT(argv[num]),
|
||||||
&flagPtr[num]) + 1;
|
&flagPtr[num]) + 1;
|
||||||
#else /* TCL_MAJOR_VERSION < 8 */
|
#else /* TCL_MAJOR_VERSION < 8 */
|
||||||
len += Tcl_ScanElement(dst, &flagPtr[num]) + 1;
|
len += Tcl_ScanElement(dst, &flagPtr[num]) + 1;
|
||||||
|
@ -9897,7 +9901,7 @@ lib_merge_tklist(argc, argv, obj)
|
||||||
for(num = 0; num < argc; num++) {
|
for(num = 0; num < argc; num++) {
|
||||||
#if TCL_MAJOR_VERSION >= 8
|
#if TCL_MAJOR_VERSION >= 8
|
||||||
len = Tcl_ConvertCountedElement(RSTRING_PTR(argv[num]),
|
len = Tcl_ConvertCountedElement(RSTRING_PTR(argv[num]),
|
||||||
RSTRING_LEN(argv[num]),
|
RSTRING_LENINT(argv[num]),
|
||||||
dst, flagPtr[num]);
|
dst, flagPtr[num]);
|
||||||
#else /* TCL_MAJOR_VERSION < 8 */
|
#else /* TCL_MAJOR_VERSION < 8 */
|
||||||
len = Tcl_ConvertElement(RSTRING_PTR(argv[num]), dst, flagPtr[num]);
|
len = Tcl_ConvertElement(RSTRING_PTR(argv[num]), dst, flagPtr[num]);
|
||||||
|
@ -9961,10 +9965,10 @@ lib_conv_listelement(self, src)
|
||||||
StringValue(src);
|
StringValue(src);
|
||||||
|
|
||||||
#if TCL_MAJOR_VERSION >= 8
|
#if TCL_MAJOR_VERSION >= 8
|
||||||
len = Tcl_ScanCountedElement(RSTRING_PTR(src), RSTRING_LEN(src),
|
len = Tcl_ScanCountedElement(RSTRING_PTR(src), RSTRING_LENINT(src),
|
||||||
&scan_flag);
|
&scan_flag);
|
||||||
dst = rb_str_new(0, len + 1);
|
dst = rb_str_new(0, len + 1);
|
||||||
len = Tcl_ConvertCountedElement(RSTRING_PTR(src), RSTRING_LEN(src),
|
len = Tcl_ConvertCountedElement(RSTRING_PTR(src), RSTRING_LENINT(src),
|
||||||
RSTRING_PTR(dst), scan_flag);
|
RSTRING_PTR(dst), scan_flag);
|
||||||
#else /* TCL_MAJOR_VERSION < 8 */
|
#else /* TCL_MAJOR_VERSION < 8 */
|
||||||
len = Tcl_ScanElement(RSTRING_PTR(src), &scan_flag);
|
len = Tcl_ScanElement(RSTRING_PTR(src), &scan_flag);
|
||||||
|
@ -10015,8 +10019,8 @@ static VALUE
|
||||||
tcltklib_compile_info()
|
tcltklib_compile_info()
|
||||||
{
|
{
|
||||||
volatile VALUE ret;
|
volatile VALUE ret;
|
||||||
int size;
|
size_t size;
|
||||||
char form[]
|
static CONST char form[]
|
||||||
= "tcltklib %s :: Ruby%s (%s) %s pthread :: Tcl%s(%s)/Tk%s(%s) %s";
|
= "tcltklib %s :: Ruby%s (%s) %s pthread :: Tcl%s(%s)/Tk%s(%s) %s";
|
||||||
char *info;
|
char *info;
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче