mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/Win32API/Win32API.c (Win32API_initialize): use RSTRING_PTR and
RSTRING_LEN. * ext/tk/stubs.c, ext/tk/tcltklib.c, ext/tk/tkutil/tkutil.c: ditto. * ext/win32ole/win32ole.c (ole_val2olevariantdata): ditto. * lib/mkmf.rb (create_makefile): follow nil.to_s. * win32/resource.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10812 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5b5e4a6fc1
commit
6790891ef0
8 changed files with 146 additions and 135 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,9 @@
|
|||
Thu Aug 31 20:50:46 2006 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* lib/mkmf.rb (create_makefile): follow nil.to_s.
|
||||
|
||||
* win32/resource.rb: ditto.
|
||||
|
||||
Thu Aug 31 20:21:47 2006 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* file.c (test_identical, rb_file_s_truncate): use RSTRING_PTR and
|
||||
|
@ -9,6 +15,12 @@ Thu Aug 31 20:21:47 2006 NAKAMURA Usaku <usa@ruby-lang.org>
|
|||
|
||||
* util.c (ruby_add_suffix): ditto.
|
||||
|
||||
* ext/Win32API/Win32API.c (Win32API_initialize): ditto.
|
||||
|
||||
* ext/tk/stubs.c, ext/tk/tcltklib.c, ext/tk/tkutil/tkutil.c: ditto.
|
||||
|
||||
* ext/win32ole/win32ole.c (ole_val2olevariantdata): ditto.
|
||||
|
||||
Thu Aug 31 18:23:00 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* ruby.h (struct RString): embed small strings.
|
||||
|
|
|
@ -50,18 +50,18 @@ Win32API_initialize(self, dllname, proc, import, export)
|
|||
|
||||
SafeStringValue(dllname);
|
||||
SafeStringValue(proc);
|
||||
hdll = LoadLibrary(RSTRING(dllname)->ptr);
|
||||
hdll = LoadLibrary(RSTRING_PTR(dllname));
|
||||
if (!hdll)
|
||||
rb_raise(rb_eRuntimeError, "LoadLibrary: %s\n", RSTRING(dllname)->ptr);
|
||||
rb_raise(rb_eRuntimeError, "LoadLibrary: %s\n", RSTRING_PTR(dllname));
|
||||
rb_iv_set(self, "__hdll__", Data_Wrap_Struct(rb_cData, 0, Win32API_FreeLibrary, (void*)hdll));
|
||||
hproc = (HANDLE)GetProcAddress(hdll, RSTRING(proc)->ptr);
|
||||
hproc = (HANDLE)GetProcAddress(hdll, RSTRING_PTR(proc));
|
||||
if (!hproc) {
|
||||
str = rb_str_new3(proc);
|
||||
str = rb_str_cat(str, "A", 1);
|
||||
hproc = (HANDLE)GetProcAddress(hdll, RSTRING(str)->ptr);
|
||||
hproc = (HANDLE)GetProcAddress(hdll, RSTRING_PTR(str));
|
||||
if (!hproc)
|
||||
rb_raise(rb_eRuntimeError, "GetProcAddress: %s or %s\n",
|
||||
RSTRING(proc)->ptr, RSTRING(str)->ptr);
|
||||
RSTRING_PTR(proc), RSTRING_PTR(str));
|
||||
}
|
||||
rb_iv_set(self, "__dll__", UINT2NUM((unsigned long)hdll));
|
||||
rb_iv_set(self, "__dllname__", dllname);
|
||||
|
@ -75,7 +75,7 @@ Win32API_initialize(self, dllname, proc, import, export)
|
|||
ptr = RARRAY(import)->ptr;
|
||||
for (i = 0, len = RARRAY(import)->len; i < len; i++) {
|
||||
SafeStringValue(ptr[i]);
|
||||
switch (*(char *)RSTRING(ptr[i])->ptr) {
|
||||
switch (*(char *)RSTRING_PTR(ptr[i])) {
|
||||
case 'N': case 'n': case 'L': case 'l':
|
||||
rb_ary_push(a_import, INT2FIX(_T_NUMBER));
|
||||
break;
|
||||
|
@ -90,8 +90,8 @@ Win32API_initialize(self, dllname, proc, import, export)
|
|||
break;
|
||||
default:
|
||||
SafeStringValue(import);
|
||||
s = RSTRING(import)->ptr;
|
||||
for (i = 0, len = RSTRING(import)->len; i < len; i++) {
|
||||
s = RSTRING_PTR(import);
|
||||
for (i = 0, len = RSTRING_LEN(import); i < len; i++) {
|
||||
switch (*s++) {
|
||||
case 'N': case 'n': case 'L': case 'l':
|
||||
rb_ary_push(a_import, INT2FIX(_T_NUMBER));
|
||||
|
@ -117,7 +117,7 @@ Win32API_initialize(self, dllname, proc, import, export)
|
|||
ex = _T_VOID;
|
||||
} else {
|
||||
SafeStringValue(export);
|
||||
switch (*RSTRING(export)->ptr) {
|
||||
switch (*RSTRING_PTR(export)) {
|
||||
case 'V': case 'v':
|
||||
ex = _T_VOID;
|
||||
break;
|
||||
|
|
|
@ -140,8 +140,8 @@ ruby_open_tk_dll()
|
|||
char tk_name[20];
|
||||
|
||||
if (!tcl_dll) {
|
||||
/* int ret = ruby_open_tcl_dll(RSTRING(rb_argv0)->ptr); */
|
||||
int ret = ruby_open_tcl_dll(rb_argv0 ? RSTRING(rb_argv0)->ptr : 0);
|
||||
/* int ret = ruby_open_tcl_dll(RSTRING_PTR(rb_argv0)); */
|
||||
int ret = ruby_open_tcl_dll(rb_argv0 ? RSTRING_PTR(rb_argv0) : 0);
|
||||
if (ret != TCLTK_STUBS_OK) return ret;
|
||||
}
|
||||
|
||||
|
@ -210,8 +210,8 @@ ruby_tcl_create_ip_and_stubs_init(int *st)
|
|||
Tcl_Interp *(*p_Tcl_DeleteInterp)();
|
||||
|
||||
if (!tcl_dll) {
|
||||
/* int ret = ruby_open_tcl_dll(RSTRING(rb_argv0)->ptr); */
|
||||
int ret = ruby_open_tcl_dll(rb_argv0 ? RSTRING(rb_argv0)->ptr : 0);
|
||||
/* int ret = ruby_open_tcl_dll(RSTRING_PTR(rb_argv0)); */
|
||||
int ret = ruby_open_tcl_dll(rb_argv0 ? RSTRING_PTR(rb_argv0) : 0);
|
||||
|
||||
if (ret != TCLTK_STUBS_OK) {
|
||||
if (st) *st = ret;
|
||||
|
@ -343,8 +343,8 @@ ruby_tcltk_stubs()
|
|||
int st;
|
||||
Tcl_Interp *tcl_ip;
|
||||
|
||||
/* st = ruby_open_tcltk_dll(RSTRING(rb_argv0)->ptr); */
|
||||
st = ruby_open_tcltk_dll(rb_argv0 ? RSTRING(rb_argv0)->ptr : 0);
|
||||
/* st = ruby_open_tcltk_dll(RSTRING_PTR(rb_argv0)); */
|
||||
st = ruby_open_tcltk_dll(rb_argv0 ? RSTRING_PTR(rb_argv0) : 0);
|
||||
switch(st) {
|
||||
case NO_FindExecutable:
|
||||
return -7;
|
||||
|
@ -405,8 +405,8 @@ ruby_open_tcl_dll(char *appname)
|
|||
int ruby_open_tk_dll()
|
||||
{
|
||||
if (!open_tcl_dll) {
|
||||
/* ruby_open_tcl_dll(RSTRING(rb_argv0)->ptr); */
|
||||
ruby_open_tcl_dll(rb_argv0 ? RSTRING(rb_argv0)->ptr : 0);
|
||||
/* ruby_open_tcl_dll(RSTRING_PTR(rb_argv0)); */
|
||||
ruby_open_tcl_dll(rb_argv0 ? RSTRING_PTR(rb_argv0) : 0);
|
||||
}
|
||||
|
||||
return TCLTK_STUBS_OK;
|
||||
|
@ -435,8 +435,8 @@ ruby_tcl_create_ip_and_stubs_init(int *st)
|
|||
Tcl_Interp *tcl_ip;
|
||||
|
||||
if (!open_tcl_dll) {
|
||||
/* ruby_open_tcl_dll(RSTRING(rb_argv0)->ptr); */
|
||||
ruby_open_tcl_dll(rb_argv0 ? RSTRING(rb_argv0)->ptr : 0);
|
||||
/* ruby_open_tcl_dll(RSTRING_PTR(rb_argv0)); */
|
||||
ruby_open_tcl_dll(rb_argv0 ? RSTRING_PTR(rb_argv0) : 0);
|
||||
}
|
||||
|
||||
if (st) *st = 0;
|
||||
|
@ -498,8 +498,8 @@ ruby_tk_stubs_safeinit(Tcl_Interp *tcl_ip)
|
|||
int
|
||||
ruby_tcltk_stubs()
|
||||
{
|
||||
/* Tcl_FindExecutable(RSTRING(rb_argv0)->ptr); */
|
||||
Tcl_FindExecutable(rb_argv0 ? RSTRING(rb_argv0)->ptr : 0);
|
||||
/* Tcl_FindExecutable(RSTRING_PTR(rb_argv0)); */
|
||||
Tcl_FindExecutable(rb_argv0 ? RSTRING_PTR(rb_argv0) : 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -896,7 +896,7 @@ call_original_exit(ptr, state)
|
|||
char **argv;
|
||||
argv = (char **)ALLOC_N(char *, 3);
|
||||
argv[0] = "exit";
|
||||
argv[1] = RSTRING(rb_fix2str(INT2NUM(state), 10))->ptr;
|
||||
argv[1] = RSTRING_PTR(rb_fix2str(INT2NUM(state), 10));
|
||||
argv[2] = (char *)NULL;
|
||||
|
||||
ptr->return_value = (*(info->proc))(info->clientData, ptr->ip,
|
||||
|
@ -2151,20 +2151,20 @@ ip_set_exc_message(interp, exc)
|
|||
if (NIL_P(enc)) {
|
||||
encoding = (Tcl_Encoding)NULL;
|
||||
} else if (TYPE(enc) == T_STRING) {
|
||||
encoding = Tcl_GetEncoding(interp, RSTRING(enc)->ptr);
|
||||
encoding = Tcl_GetEncoding(interp, RSTRING_PTR(enc));
|
||||
} else {
|
||||
enc = rb_funcall(enc, ID_to_s, 0, 0);
|
||||
encoding = Tcl_GetEncoding(interp, RSTRING(enc)->ptr);
|
||||
encoding = Tcl_GetEncoding(interp, RSTRING_PTR(enc));
|
||||
}
|
||||
|
||||
/* to avoid a garbled error message dialog */
|
||||
buf = ALLOC_N(char, (RSTRING(msg)->len)+1);
|
||||
memcpy(buf, RSTRING(msg)->ptr, RSTRING(msg)->len);
|
||||
buf[RSTRING(msg)->len] = 0;
|
||||
buf = ALLOC_N(char, (RSTRING_LEN(msg))+1);
|
||||
memcpy(buf, RSTRING_PTR(msg), RSTRING_LEN(msg));
|
||||
buf[RSTRING_LEN(msg)] = 0;
|
||||
|
||||
Tcl_DStringInit(&dstr);
|
||||
Tcl_DStringFree(&dstr);
|
||||
Tcl_ExternalToUtfDString(encoding, buf, RSTRING(msg)->len, &dstr);
|
||||
Tcl_ExternalToUtfDString(encoding, buf, RSTRING_LEN(msg), &dstr);
|
||||
|
||||
Tcl_AppendResult(interp, Tcl_DStringValue(&dstr), (char*)NULL);
|
||||
DUMP2("error message:%s", Tcl_DStringValue(&dstr));
|
||||
|
@ -2172,7 +2172,7 @@ ip_set_exc_message(interp, exc)
|
|||
free(buf);
|
||||
|
||||
#else /* TCL_VERSION <= 8.0 */
|
||||
Tcl_AppendResult(interp, RSTRING(msg)->ptr, (char*)NULL);
|
||||
Tcl_AppendResult(interp, RSTRING_PTR(msg), (char*)NULL);
|
||||
#endif
|
||||
|
||||
rb_thread_critical = thr_crit_bup;
|
||||
|
@ -2367,12 +2367,12 @@ tcl_protect_core(interp, proc, data) /* should not raise exception */
|
|||
|
||||
ret = TkStringValue(ret);
|
||||
DUMP1("Tcl_AppendResult");
|
||||
Tcl_AppendResult(interp, RSTRING(ret)->ptr, (char *)NULL);
|
||||
Tcl_AppendResult(interp, RSTRING_PTR(ret), (char *)NULL);
|
||||
|
||||
rb_thread_critical = thr_crit_bup;
|
||||
}
|
||||
|
||||
DUMP2("(result) %s", NIL_P(ret) ? "nil" : RSTRING(ret)->ptr);
|
||||
DUMP2("(result) %s", NIL_P(ret) ? "nil" : RSTRING_PTR(ret));
|
||||
|
||||
return TCL_OK;
|
||||
}
|
||||
|
@ -5413,25 +5413,25 @@ get_obj_from_str(str)
|
|||
const char *s = StringValuePtr(str);
|
||||
|
||||
#if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0
|
||||
return Tcl_NewStringObj((char*)s, RSTRING(str)->len);
|
||||
return Tcl_NewStringObj((char*)s, RSTRING_LEN(str));
|
||||
#else /* TCL_VERSION >= 8.1 */
|
||||
VALUE enc = rb_attr_get(str, ID_at_enc);
|
||||
|
||||
if (!NIL_P(enc)) {
|
||||
StringValue(enc);
|
||||
if (strcmp(RSTRING(enc)->ptr, "binary") == 0) {
|
||||
if (strcmp(RSTRING_PTR(enc), "binary") == 0) {
|
||||
/* binary string */
|
||||
return Tcl_NewByteArrayObj(s, RSTRING(str)->len);
|
||||
return Tcl_NewByteArrayObj(s, RSTRING_LEN(str));
|
||||
} else {
|
||||
/* text string */
|
||||
return Tcl_NewStringObj(s, RSTRING(str)->len);
|
||||
return Tcl_NewStringObj(s, RSTRING_LEN(str));
|
||||
}
|
||||
} else if (strlen(s) != RSTRING(str)->len) {
|
||||
} else if (strlen(s) != RSTRING_LEN(str)) {
|
||||
/* probably binary string */
|
||||
return Tcl_NewByteArrayObj(s, RSTRING(str)->len);
|
||||
return Tcl_NewByteArrayObj(s, RSTRING_LEN(str));
|
||||
} else {
|
||||
/* probably text string */
|
||||
return Tcl_NewStringObj(s, RSTRING(str)->len);
|
||||
return Tcl_NewStringObj(s, RSTRING_LEN(str));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -5875,7 +5875,7 @@ ip_eval(self, str)
|
|||
} else {
|
||||
DUMP2("eval from current eventloop %lx", current);
|
||||
}
|
||||
result = ip_eval_real(self, RSTRING(str)->ptr, RSTRING(str)->len);
|
||||
result = ip_eval_real(self, RSTRING_PTR(str), RSTRING_LEN(str));
|
||||
if (rb_obj_is_kind_of(result, rb_eException)) {
|
||||
rb_exc_raise(result);
|
||||
}
|
||||
|
@ -5891,9 +5891,9 @@ ip_eval(self, str)
|
|||
alloc_done = (int*)ALLOC(int);
|
||||
*alloc_done = 0;
|
||||
|
||||
eval_str = ALLOC_N(char, RSTRING(str)->len + 1);
|
||||
memcpy(eval_str, RSTRING(str)->ptr, RSTRING(str)->len);
|
||||
eval_str[RSTRING(str)->len] = 0;
|
||||
eval_str = ALLOC_N(char, RSTRING_LEN(str) + 1);
|
||||
memcpy(eval_str, RSTRING_PTR(str), RSTRING_LEN(str));
|
||||
eval_str[RSTRING_LEN(str)] = 0;
|
||||
|
||||
/* allocate memory (freed by Tcl_ServiceEvent) */
|
||||
evq = (struct eval_queue *)Tcl_Alloc(sizeof(struct eval_queue));
|
||||
|
@ -5907,7 +5907,7 @@ ip_eval(self, str)
|
|||
/* construct event data */
|
||||
evq->done = alloc_done;
|
||||
evq->str = eval_str;
|
||||
evq->len = RSTRING(str)->len;
|
||||
evq->len = RSTRING_LEN(str);
|
||||
evq->interp = ip_obj;
|
||||
evq->result = result;
|
||||
evq->thread = current;
|
||||
|
@ -6102,21 +6102,21 @@ lib_toUTF8_core(ip_obj, src, encodename)
|
|||
encoding = (Tcl_Encoding)NULL;
|
||||
} else {
|
||||
StringValue(enc);
|
||||
encoding = Tcl_GetEncoding(interp, RSTRING(enc)->ptr);
|
||||
encoding = Tcl_GetEncoding(interp, RSTRING_PTR(enc));
|
||||
if (encoding == (Tcl_Encoding)NULL) {
|
||||
rb_warning("Tk-interp has unknown encoding information (@encoding:'%s')", RSTRING(enc)->ptr);
|
||||
rb_warning("Tk-interp has unknown encoding information (@encoding:'%s')", RSTRING_PTR(enc));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
StringValue(enc);
|
||||
if (strcmp(RSTRING(enc)->ptr, "binary") == 0) {
|
||||
if (strcmp(RSTRING_PTR(enc), "binary") == 0) {
|
||||
rb_thread_critical = thr_crit_bup;
|
||||
return str;
|
||||
}
|
||||
encoding = Tcl_GetEncoding(interp, RSTRING(enc)->ptr);
|
||||
encoding = Tcl_GetEncoding(interp, RSTRING_PTR(enc));
|
||||
if (encoding == (Tcl_Encoding)NULL) {
|
||||
rb_warning("string has unknown encoding information (@encoding:'%s')", RSTRING(enc)->ptr);
|
||||
rb_warning("string has unknown encoding information (@encoding:'%s')", RSTRING_PTR(enc));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -6124,30 +6124,30 @@ lib_toUTF8_core(ip_obj, src, encodename)
|
|||
}
|
||||
} else {
|
||||
StringValue(encodename);
|
||||
encoding = Tcl_GetEncoding(interp, RSTRING(encodename)->ptr);
|
||||
encoding = Tcl_GetEncoding(interp, RSTRING_PTR(encodename));
|
||||
if (encoding == (Tcl_Encoding)NULL) {
|
||||
/*
|
||||
rb_warning("unknown encoding name '%s'",
|
||||
RSTRING(encodename)->ptr);
|
||||
RSTRING_PTR(encodename));
|
||||
*/
|
||||
rb_raise(rb_eArgError, "unknown encoding name '%s'",
|
||||
RSTRING(encodename)->ptr);
|
||||
RSTRING_PTR(encodename));
|
||||
}
|
||||
}
|
||||
|
||||
StringValue(str);
|
||||
if (!RSTRING(str)->len) {
|
||||
if (!RSTRING_LEN(str)) {
|
||||
rb_thread_critical = thr_crit_bup;
|
||||
return str;
|
||||
}
|
||||
buf = ALLOC_N(char,(RSTRING(str)->len)+1);
|
||||
memcpy(buf, RSTRING(str)->ptr, RSTRING(str)->len);
|
||||
buf[RSTRING(str)->len] = 0;
|
||||
buf = ALLOC_N(char,RSTRING_LEN(str)+1);
|
||||
memcpy(buf, RSTRING_PTR(str), RSTRING_LEN(str));
|
||||
buf[RSTRING_LEN(str)] = 0;
|
||||
|
||||
Tcl_DStringInit(&dstr);
|
||||
Tcl_DStringFree(&dstr);
|
||||
/* Tcl_ExternalToUtfDString(encoding,buf,strlen(buf),&dstr); */
|
||||
Tcl_ExternalToUtfDString(encoding, buf, RSTRING(str)->len, &dstr);
|
||||
Tcl_ExternalToUtfDString(encoding, buf, RSTRING_LEN(str), &dstr);
|
||||
|
||||
/* str = rb_tainted_str_new2(Tcl_DStringValue(&dstr)); */
|
||||
/* str = rb_str_new2(Tcl_DStringValue(&dstr)); */
|
||||
|
@ -6238,7 +6238,7 @@ lib_fromUTF8_core(ip_obj, src, encodename)
|
|||
enc = rb_attr_get(str, ID_at_enc);
|
||||
if (!NIL_P(enc)) {
|
||||
StringValue(enc);
|
||||
if (strcmp(RSTRING(enc)->ptr, "binary") == 0) {
|
||||
if (strcmp(RSTRING_PTR(enc), "binary") == 0) {
|
||||
rb_thread_critical = thr_crit_bup;
|
||||
return str;
|
||||
}
|
||||
|
@ -6253,9 +6253,9 @@ lib_fromUTF8_core(ip_obj, src, encodename)
|
|||
encoding = (Tcl_Encoding)NULL;
|
||||
} else {
|
||||
StringValue(enc);
|
||||
encoding = Tcl_GetEncoding(interp, RSTRING(enc)->ptr);
|
||||
encoding = Tcl_GetEncoding(interp, RSTRING_PTR(enc));
|
||||
if (encoding == (Tcl_Encoding)NULL) {
|
||||
rb_warning("Tk-interp has unknown encoding information (@encoding:'%s')", RSTRING(enc)->ptr);
|
||||
rb_warning("Tk-interp has unknown encoding information (@encoding:'%s')", RSTRING_PTR(enc));
|
||||
} else {
|
||||
encodename = rb_obj_dup(enc);
|
||||
}
|
||||
|
@ -6265,13 +6265,13 @@ lib_fromUTF8_core(ip_obj, src, encodename)
|
|||
} else {
|
||||
StringValue(encodename);
|
||||
|
||||
if (strcmp(RSTRING(encodename)->ptr, "binary") == 0) {
|
||||
if (strcmp(RSTRING_PTR(encodename), "binary") == 0) {
|
||||
char *s;
|
||||
int len;
|
||||
|
||||
StringValue(str);
|
||||
s = Tcl_GetByteArrayFromObj(Tcl_NewStringObj(RSTRING(str)->ptr,
|
||||
RSTRING(str)->len),
|
||||
s = Tcl_GetByteArrayFromObj(Tcl_NewStringObj(RSTRING_PTR(str),
|
||||
RSTRING_LEN(str)),
|
||||
&len);
|
||||
str = rb_tainted_str_new(s, len);
|
||||
rb_ivar_set(str, ID_at_enc, rb_tainted_str_new2("binary"));
|
||||
|
@ -6280,33 +6280,33 @@ lib_fromUTF8_core(ip_obj, src, encodename)
|
|||
return str;
|
||||
}
|
||||
|
||||
encoding = Tcl_GetEncoding(interp, RSTRING(encodename)->ptr);
|
||||
encoding = Tcl_GetEncoding(interp, RSTRING_PTR(encodename));
|
||||
if (encoding == (Tcl_Encoding)NULL) {
|
||||
/*
|
||||
rb_warning("unknown encoding name '%s'",
|
||||
RSTRING(encodename)->ptr);
|
||||
RSTRING_PTR(encodename));
|
||||
encodename = Qnil;
|
||||
*/
|
||||
rb_raise(rb_eArgError, "unknown encoding name '%s'",
|
||||
RSTRING(encodename)->ptr);
|
||||
RSTRING_PTR(encodename));
|
||||
}
|
||||
}
|
||||
|
||||
StringValue(str);
|
||||
|
||||
if (RSTRING(str)->len == 0) {
|
||||
if (RSTRING_LEN(str) == 0) {
|
||||
rb_thread_critical = thr_crit_bup;
|
||||
return rb_tainted_str_new2("");
|
||||
}
|
||||
|
||||
buf = ALLOC_N(char,strlen(RSTRING(str)->ptr)+1);
|
||||
memcpy(buf, RSTRING(str)->ptr, RSTRING(str)->len);
|
||||
buf[RSTRING(str)->len] = 0;
|
||||
buf = ALLOC_N(char,strlen(RSTRING_PTR(str))+1);
|
||||
memcpy(buf, RSTRING_PTR(str), RSTRING_LEN(str));
|
||||
buf[RSTRING_LEN(str)] = 0;
|
||||
|
||||
Tcl_DStringInit(&dstr);
|
||||
Tcl_DStringFree(&dstr);
|
||||
/* Tcl_UtfToExternalDString(encoding,buf,strlen(buf),&dstr); */
|
||||
Tcl_UtfToExternalDString(encoding,buf,RSTRING(str)->len,&dstr);
|
||||
Tcl_UtfToExternalDString(encoding,buf,RSTRING_LEN(str),&dstr);
|
||||
|
||||
/* str = rb_tainted_str_new2(Tcl_DStringValue(&dstr)); */
|
||||
/* str = rb_str_new2(Tcl_DStringValue(&dstr)); */
|
||||
|
@ -6371,21 +6371,21 @@ lib_UTF_backslash_core(self, str, all_bs)
|
|||
tcl_stubs_check();
|
||||
|
||||
StringValue(str);
|
||||
if (!RSTRING(str)->len) {
|
||||
if (!RSTRING_LEN(str)) {
|
||||
return str;
|
||||
}
|
||||
|
||||
thr_crit_bup = rb_thread_critical;
|
||||
rb_thread_critical = Qtrue;
|
||||
|
||||
src_buf = ALLOC_N(char,(RSTRING(str)->len)+1);
|
||||
memcpy(src_buf, RSTRING(str)->ptr, RSTRING(str)->len);
|
||||
src_buf[RSTRING(str)->len] = 0;
|
||||
src_buf = ALLOC_N(char,RSTRING_LEN(str)+1);
|
||||
memcpy(src_buf, RSTRING_PTR(str), RSTRING_LEN(str));
|
||||
src_buf[RSTRING_LEN(str)] = 0;
|
||||
|
||||
dst_buf = ALLOC_N(char,(RSTRING(str)->len)+1);
|
||||
dst_buf = ALLOC_N(char,RSTRING_LEN(str)+1);
|
||||
|
||||
ptr = src_buf;
|
||||
while(RSTRING(str)->len > ptr - src_buf) {
|
||||
while(RSTRING_LEN(str) > ptr - src_buf) {
|
||||
if (*ptr == '\\' && (all_bs || *(ptr + 1) == 'u')) {
|
||||
dst_len += Tcl_UtfBackslash(ptr, &read_len, (dst_buf + dst_len));
|
||||
ptr += read_len;
|
||||
|
@ -6451,7 +6451,7 @@ lib_set_system_encoding(self, enc_name)
|
|||
if (Tcl_SetSystemEncoding((Tcl_Interp *)NULL,
|
||||
StringValuePtr(enc_name)) != TCL_OK) {
|
||||
rb_raise(rb_eArgError, "unknown encoding name '%s'",
|
||||
RSTRING(enc_name)->ptr);
|
||||
RSTRING_PTR(enc_name));
|
||||
}
|
||||
|
||||
return enc_name;
|
||||
|
@ -7101,8 +7101,8 @@ ip_get_variable2_core(interp, argc, argv)
|
|||
} else {
|
||||
/* Tcl_Preserve(ptr->ip); */
|
||||
rbtk_preserve_ip(ptr);
|
||||
ret = Tcl_GetVar2Ex(ptr->ip, RSTRING(varname)->ptr,
|
||||
NIL_P(index) ? NULL : RSTRING(index)->ptr,
|
||||
ret = Tcl_GetVar2Ex(ptr->ip, RSTRING_PTR(varname),
|
||||
NIL_P(index) ? NULL : RSTRING_PTR(index),
|
||||
FIX2INT(flag));
|
||||
}
|
||||
|
||||
|
@ -7139,8 +7139,8 @@ ip_get_variable2_core(interp, argc, argv)
|
|||
} else {
|
||||
/* Tcl_Preserve(ptr->ip); */
|
||||
rbtk_preserve_ip(ptr);
|
||||
ret = Tcl_GetVar2(ptr->ip, RSTRING(varname)->ptr,
|
||||
NIL_P(index) ? NULL : RSTRING(index)->ptr,
|
||||
ret = Tcl_GetVar2(ptr->ip, RSTRING_PTR(varname),
|
||||
NIL_P(index) ? NULL : RSTRING_PTR(index),
|
||||
FIX2INT(flag));
|
||||
}
|
||||
|
||||
|
@ -7238,8 +7238,8 @@ ip_set_variable2_core(interp, argc, argv)
|
|||
} else {
|
||||
/* Tcl_Preserve(ptr->ip); */
|
||||
rbtk_preserve_ip(ptr);
|
||||
ret = Tcl_SetVar2Ex(ptr->ip, RSTRING(varname)->ptr,
|
||||
NIL_P(index) ? NULL : RSTRING(index)->ptr,
|
||||
ret = Tcl_SetVar2Ex(ptr->ip, RSTRING_PTR(varname),
|
||||
NIL_P(index) ? NULL : RSTRING_PTR(index),
|
||||
valobj, FIX2INT(flag));
|
||||
}
|
||||
|
||||
|
@ -7279,9 +7279,9 @@ ip_set_variable2_core(interp, argc, argv)
|
|||
} else {
|
||||
/* Tcl_Preserve(ptr->ip); */
|
||||
rbtk_preserve_ip(ptr);
|
||||
ret = Tcl_SetVar2(ptr->ip, RSTRING(varname)->ptr,
|
||||
NIL_P(index) ? NULL : RSTRING(index)->ptr,
|
||||
RSTRING(value)->ptr, FIX2INT(flag));
|
||||
ret = Tcl_SetVar2(ptr->ip, RSTRING_PTR(varname),
|
||||
NIL_P(index) ? NULL : RSTRING_PTR(index),
|
||||
RSTRING_PTR(value), FIX2INT(flag));
|
||||
}
|
||||
|
||||
if (ret == (char*)NULL) {
|
||||
|
@ -7361,8 +7361,8 @@ ip_unset_variable2_core(interp, argc, argv)
|
|||
return Qtrue;
|
||||
}
|
||||
|
||||
ptr->return_value = Tcl_UnsetVar2(ptr->ip, RSTRING(varname)->ptr,
|
||||
NIL_P(index) ? NULL : RSTRING(index)->ptr,
|
||||
ptr->return_value = Tcl_UnsetVar2(ptr->ip, RSTRING_PTR(varname),
|
||||
NIL_P(index) ? NULL : RSTRING_PTR(index),
|
||||
FIX2INT(flag));
|
||||
|
||||
if (ptr->return_value == TCL_ERROR) {
|
||||
|
@ -7555,7 +7555,7 @@ lib_split_tklist_core(ip_obj, list_str)
|
|||
int argc;
|
||||
char **argv;
|
||||
|
||||
if (Tcl_SplitList(interp, RSTRING(list_str)->ptr,
|
||||
if (Tcl_SplitList(interp, RSTRING_PTR(list_str),
|
||||
&argc, &argv) == TCL_ERROR) {
|
||||
if (interp == (Tcl_Interp*)NULL) {
|
||||
rb_raise(rb_eRuntimeError, "can't get elements from list");
|
||||
|
@ -7635,7 +7635,7 @@ lib_merge_tklist(argc, argv, obj)
|
|||
if (OBJ_TAINTED(argv[num])) taint_flag = 1;
|
||||
dst = StringValuePtr(argv[num]);
|
||||
#if TCL_MAJOR_VERSION >= 8
|
||||
len += Tcl_ScanCountedElement(dst, RSTRING(argv[num])->len,
|
||||
len += Tcl_ScanCountedElement(dst, RSTRING_LEN(argv[num]),
|
||||
&flagPtr[num]) + 1;
|
||||
#else /* TCL_MAJOR_VERSION < 8 */
|
||||
len += Tcl_ScanElement(dst, &flagPtr[num]) + 1;
|
||||
|
@ -7647,11 +7647,11 @@ lib_merge_tklist(argc, argv, obj)
|
|||
dst = result;
|
||||
for(num = 0; num < argc; num++) {
|
||||
#if TCL_MAJOR_VERSION >= 8
|
||||
len = Tcl_ConvertCountedElement(RSTRING(argv[num])->ptr,
|
||||
RSTRING(argv[num])->len,
|
||||
len = Tcl_ConvertCountedElement(RSTRING_PTR(argv[num]),
|
||||
RSTRING_LEN(argv[num]),
|
||||
dst, flagPtr[num]);
|
||||
#else /* TCL_MAJOR_VERSION < 8 */
|
||||
len = Tcl_ConvertElement(RSTRING(argv[num])->ptr, dst, flagPtr[num]);
|
||||
len = Tcl_ConvertElement(RSTRING_PTR(argv[num]), dst, flagPtr[num]);
|
||||
#endif
|
||||
dst += len;
|
||||
*dst = ' ';
|
||||
|
@ -7694,19 +7694,18 @@ lib_conv_listelement(self, src)
|
|||
StringValue(src);
|
||||
|
||||
#if TCL_MAJOR_VERSION >= 8
|
||||
len = Tcl_ScanCountedElement(RSTRING(src)->ptr, RSTRING(src)->len,
|
||||
len = Tcl_ScanCountedElement(RSTRING_PTR(src), RSTRING_LEN(src),
|
||||
&scan_flag);
|
||||
dst = rb_str_new(0, len + 1);
|
||||
len = Tcl_ConvertCountedElement(RSTRING(src)->ptr, RSTRING(src)->len,
|
||||
RSTRING(dst)->ptr, scan_flag);
|
||||
len = Tcl_ConvertCountedElement(RSTRING_PTR(src), RSTRING_LEN(src),
|
||||
RSTRING_PTR(dst), scan_flag);
|
||||
#else /* TCL_MAJOR_VERSION < 8 */
|
||||
len = Tcl_ScanElement(RSTRING(src)->ptr, &scan_flag);
|
||||
len = Tcl_ScanElement(RSTRING_PTR(src), &scan_flag);
|
||||
dst = rb_str_new(0, len + 1);
|
||||
len = Tcl_ConvertElement(RSTRING(src)->ptr, RSTRING(dst)->ptr, scan_flag);
|
||||
len = Tcl_ConvertElement(RSTRING_PTR(src), RSTRING_PTR(dst), scan_flag);
|
||||
#endif
|
||||
|
||||
RSTRING(dst)->len = len;
|
||||
RSTRING(dst)->ptr[len] = '\0';
|
||||
rb_str_resize(dst, len);
|
||||
if (taint_flag) OBJ_TAINT(dst);
|
||||
|
||||
rb_thread_critical = thr_crit_bup;
|
||||
|
@ -7828,7 +7827,7 @@ ip_make_menu_embeddable(interp, menu_path)
|
|||
|
||||
StringValue(menu_path);
|
||||
|
||||
menuRefPtr = TkFindMenuReferences(ptr->ip, RSTRING(menu_path)->ptr);
|
||||
menuRefPtr = TkFindMenuReferences(ptr->ip, RSTRING_PTR(menu_path));
|
||||
if (menuRefPtr == (struct dummy_TkMenuRef *) NULL) {
|
||||
rb_raise(rb_eArgError, "not a menu widget, or invalid widget path");
|
||||
}
|
||||
|
@ -8118,7 +8117,7 @@ Init_tcltklib()
|
|||
|
||||
/* --------------------------------------------------------------- */
|
||||
|
||||
ret = ruby_open_tcl_dll(rb_argv0 ? RSTRING(rb_argv0)->ptr : 0);
|
||||
ret = ruby_open_tcl_dll(rb_argv0 ? RSTRING_PTR(rb_argv0) : 0);
|
||||
switch(ret) {
|
||||
case TCLTK_STUBS_OK:
|
||||
break;
|
||||
|
|
|
@ -155,16 +155,16 @@ tk_uninstall_cmd(self, cmd_id)
|
|||
int prefix_len = strlen(cmd_id_prefix);
|
||||
|
||||
StringValue(cmd_id);
|
||||
if (strncmp(cmd_id_head, RSTRING(cmd_id)->ptr, head_len) != 0) {
|
||||
if (strncmp(cmd_id_head, RSTRING_PTR(cmd_id), head_len) != 0) {
|
||||
return Qnil;
|
||||
}
|
||||
if (strncmp(cmd_id_prefix,
|
||||
RSTRING(cmd_id)->ptr + head_len, prefix_len) != 0) {
|
||||
RSTRING_PTR(cmd_id) + head_len, prefix_len) != 0) {
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
return rb_hash_delete(CALLBACK_TABLE,
|
||||
rb_str_new2(RSTRING(cmd_id)->ptr + head_len));
|
||||
rb_str_new2(RSTRING_PTR(cmd_id) + head_len));
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
@ -862,7 +862,7 @@ get_eval_string_core(obj, enc_flag, self)
|
|||
}
|
||||
|
||||
rb_warning("fail to convert '%s' to string for Tk",
|
||||
RSTRING(rb_funcall(obj, rb_intern("inspect"), 0, 0))->ptr);
|
||||
RSTRING_PTR(rb_funcall(obj, rb_intern("inspect"), 0, 0)));
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
@ -966,13 +966,13 @@ tcl2rb_bool(self, value)
|
|||
|
||||
value = rb_funcall(value, ID_downcase, 0);
|
||||
|
||||
if (RSTRING(value)->ptr == (char*)NULL) return Qnil;
|
||||
if (RSTRING_PTR(value) == (char*)NULL) return Qnil;
|
||||
|
||||
if (RSTRING(value)->ptr[0] == '\0'
|
||||
|| strcmp(RSTRING(value)->ptr, "0") == 0
|
||||
|| strcmp(RSTRING(value)->ptr, "no") == 0
|
||||
|| strcmp(RSTRING(value)->ptr, "off") == 0
|
||||
|| strcmp(RSTRING(value)->ptr, "false") == 0) {
|
||||
if (RSTRING_PTR(value)[0] == '\0'
|
||||
|| strcmp(RSTRING_PTR(value), "0") == 0
|
||||
|| strcmp(RSTRING_PTR(value), "no") == 0
|
||||
|| strcmp(RSTRING_PTR(value), "off") == 0
|
||||
|| strcmp(RSTRING_PTR(value), "false") == 0) {
|
||||
return Qfalse;
|
||||
} else {
|
||||
return Qtrue;
|
||||
|
@ -983,21 +983,21 @@ static VALUE
|
|||
tkstr_to_dec(value)
|
||||
VALUE value;
|
||||
{
|
||||
return rb_cstr_to_inum(RSTRING(value)->ptr, 10, 1);
|
||||
return rb_cstr_to_inum(RSTRING_PTR(value), 10, 1);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
tkstr_to_int(value)
|
||||
VALUE value;
|
||||
{
|
||||
return rb_cstr_to_inum(RSTRING(value)->ptr, 0, 1);
|
||||
return rb_cstr_to_inum(RSTRING_PTR(value), 0, 1);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
tkstr_to_float(value)
|
||||
VALUE value;
|
||||
{
|
||||
return rb_float_new(rb_cstr_to_dbl(RSTRING(value)->ptr, 1));
|
||||
return rb_float_new(rb_cstr_to_dbl(RSTRING_PTR(value), 1));
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
@ -1005,7 +1005,7 @@ tkstr_invalid_numstr(value)
|
|||
VALUE value;
|
||||
{
|
||||
rb_raise(rb_eArgError,
|
||||
"invalid value for Number: '%s'", RSTRING(value)->ptr);
|
||||
"invalid value for Number: '%s'", RSTRING_PTR(value));
|
||||
return Qnil; /*dummy*/
|
||||
}
|
||||
|
||||
|
@ -1024,7 +1024,7 @@ tkstr_to_number(value)
|
|||
{
|
||||
rb_check_type(value, T_STRING);
|
||||
|
||||
if (RSTRING(value)->ptr == (char*)NULL) return INT2FIX(0);
|
||||
if (RSTRING_PTR(value) == (char*)NULL) return INT2FIX(0);
|
||||
|
||||
return rb_rescue2(tkstr_to_int, value,
|
||||
tkstr_rescue_float, value,
|
||||
|
@ -1046,8 +1046,8 @@ tkstr_to_str(value)
|
|||
char * ptr;
|
||||
int len;
|
||||
|
||||
ptr = RSTRING(value)->ptr;
|
||||
len = RSTRING(value)->len;
|
||||
ptr = RSTRING_PTR(value);
|
||||
len = RSTRING_LEN(value);
|
||||
|
||||
if (len > 1 && *ptr == '{' && *(ptr + len - 1) == '}') {
|
||||
return rb_str_new(ptr + 1, len - 2);
|
||||
|
@ -1062,7 +1062,7 @@ tcl2rb_string(self, value)
|
|||
{
|
||||
rb_check_type(value, T_STRING);
|
||||
|
||||
if (RSTRING(value)->ptr == (char*)NULL) return rb_tainted_str_new2("");
|
||||
if (RSTRING_PTR(value) == (char*)NULL) return rb_tainted_str_new2("");
|
||||
|
||||
return tkstr_to_str(value);
|
||||
}
|
||||
|
@ -1074,7 +1074,7 @@ tcl2rb_num_or_str(self, value)
|
|||
{
|
||||
rb_check_type(value, T_STRING);
|
||||
|
||||
if (RSTRING(value)->ptr == (char*)NULL) return rb_tainted_str_new2("");
|
||||
if (RSTRING_PTR(value) == (char*)NULL) return rb_tainted_str_new2("");
|
||||
|
||||
return rb_rescue2(tkstr_to_number, value,
|
||||
tkstr_to_str, value,
|
||||
|
@ -1181,7 +1181,7 @@ each_attr_def(key, value, klass)
|
|||
|
||||
switch(TYPE(key)) {
|
||||
case T_STRING:
|
||||
key_id = rb_intern(RSTRING(key)->ptr);
|
||||
key_id = rb_intern(RSTRING_PTR(key));
|
||||
break;
|
||||
case T_SYMBOL:
|
||||
key_id = SYM2ID(key);
|
||||
|
@ -1193,7 +1193,7 @@ each_attr_def(key, value, klass)
|
|||
|
||||
switch(TYPE(value)) {
|
||||
case T_STRING:
|
||||
value_id = rb_intern(RSTRING(value)->ptr);
|
||||
value_id = rb_intern(RSTRING_PTR(value));
|
||||
break;
|
||||
case T_SYMBOL:
|
||||
value_id = SYM2ID(value);
|
||||
|
@ -1250,7 +1250,7 @@ cbsubst_get_subst_arg(argc, argv, self)
|
|||
for(i = 0; i < argc; i++) {
|
||||
switch(TYPE(argv[i])) {
|
||||
case T_STRING:
|
||||
str = RSTRING(argv[i])->ptr;
|
||||
str = RSTRING_PTR(argv[i]);
|
||||
arg_sym = ID2SYM(rb_intern(str));
|
||||
break;
|
||||
case T_SYMBOL:
|
||||
|
@ -1265,7 +1265,7 @@ cbsubst_get_subst_arg(argc, argv, self)
|
|||
str = rb_id2name(SYM2ID(ret));
|
||||
}
|
||||
|
||||
id = rb_intern(RSTRING(rb_str_cat2(rb_str_new2("@"), str))->ptr);
|
||||
id = rb_intern(RSTRING_PTR(rb_str_cat2(rb_str_new2("@"), str)));
|
||||
|
||||
for(j = 0; j < len; j++) {
|
||||
if (inf->ivar[j] == id) break;
|
||||
|
@ -1305,7 +1305,7 @@ cbsubst_get_subst_key(self, str)
|
|||
buf = ALLOC_N(char, len + 1);
|
||||
|
||||
for(i = 0; i < len; i++) {
|
||||
ptr = RSTRING(RARRAY(list)->ptr[i])->ptr;
|
||||
ptr = RSTRING_PTR(RARRAY(list)->ptr[i]);
|
||||
if (*ptr == '%' && *(ptr + 2) == '\0') {
|
||||
*(buf + i) = *(ptr + 1);
|
||||
} else {
|
||||
|
@ -1388,10 +1388,10 @@ cbsubst_table_setup(self, key_inf, proc_inf)
|
|||
|
||||
*(ivar + real_len)
|
||||
= rb_intern(
|
||||
RSTRING(
|
||||
RSTRING_PTR(
|
||||
rb_str_cat2(rb_str_new2("@"),
|
||||
rb_id2name(SYM2ID(RARRAY(inf)->ptr[2])))
|
||||
)->ptr
|
||||
)
|
||||
);
|
||||
|
||||
rb_attr(self, SYM2ID(RARRAY(inf)->ptr[2]), 1, 0, Qtrue);
|
||||
|
@ -1453,12 +1453,12 @@ cbsubst_scan_args(self, arg_key, val_ary)
|
|||
|
||||
RARRAY(dst)->len = 0;
|
||||
for(idx = 0; idx < len; idx++) {
|
||||
if (idx >= RSTRING(arg_key)->len) {
|
||||
if (idx >= RSTRING_LEN(arg_key)) {
|
||||
proc = Qnil;
|
||||
} else if (*(RSTRING(arg_key)->ptr + idx) == ' ') {
|
||||
} else if (*(RSTRING_PTR(arg_key) + idx) == ' ') {
|
||||
proc = Qnil;
|
||||
} else {
|
||||
ptr = strchr(inf->key, *(RSTRING(arg_key)->ptr + idx));
|
||||
ptr = strchr(inf->key, *(RSTRING_PTR(arg_key) + idx));
|
||||
if (ptr == (char*)NULL) {
|
||||
proc = Qnil;
|
||||
} else {
|
||||
|
|
|
@ -1069,7 +1069,7 @@ ole_val2olevariantdata(VALUE val, VARTYPE vtype, struct olevariantdata *pvar)
|
|||
VARIANT var;
|
||||
|
||||
if (((vtype & ~VT_BYREF) == (VT_ARRAY | VT_UI1)) && TYPE(val) == T_STRING) {
|
||||
long len = RSTRING(val)->len;
|
||||
long len = RSTRING_LEN(val);
|
||||
char *pdest = NULL;
|
||||
SAFEARRAY *psa = SafeArrayCreateVector(VT_UI1, 0, len);
|
||||
if (!psa) {
|
||||
|
@ -1077,7 +1077,7 @@ ole_val2olevariantdata(VALUE val, VARTYPE vtype, struct olevariantdata *pvar)
|
|||
}
|
||||
hr = SafeArrayAccessData(psa, (void **)&pdest);
|
||||
if (SUCCEEDED(hr)) {
|
||||
memcpy(pdest, RSTRING(val)->ptr, len);
|
||||
memcpy(pdest, RSTRING_PTR(val), len);
|
||||
SafeArrayUnaccessData(psa);
|
||||
V_VT(&(pvar->realvar)) = vtype;
|
||||
V_ARRAY(&(pvar->realvar)) = psa;
|
||||
|
|
|
@ -1335,7 +1335,7 @@ site-install-rb: install-rb
|
|||
end
|
||||
mfile.print "\n\n"
|
||||
if makedef
|
||||
mfile.print "$(DEFFILE): #{origdef}\n"
|
||||
mfile.print "$(DEFFILE): #{origdef || ''}\n"
|
||||
mfile.print "\t$(RUBY) #{makedef} #{origdef} > $@\n\n"
|
||||
end
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ end
|
|||
#include <winver.h>
|
||||
#endif
|
||||
|
||||
#{icons}
|
||||
#{icons || ''}
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION #{fversion}
|
||||
PRODUCTVERSION #{fversion}
|
||||
|
|
Loading…
Reference in a new issue