なかだです。

At Wed, 3 Apr 2002 20:18:51 +0900,
Takaaki Tateishi wrote:
> > それもちょっと思ったんですが、とりあえず手元で通らない部分だけ。
> 
> ありがとうございます.パッチをそのまま使わせてもらいます.

すいません、ちょっと古いパッチを送ってしまいました。無駄に
StringValue()しすぎてました。それと、1.7の標準ライブラリなので
1.6用のマクロは不要なのでは。


Index: ext/dl/dl.c =================================================================== RCS file: /cvs/ruby/src/ruby/ext/dl/dl.c,v retrieving revision 1.2 diff -u -2 -p -r1.2 dl.c --- ext/dl/dl.c 2002/04/03 11:59:01 1.2 +++ ext/dl/dl.c 2002/04/03 15:06:36 @@ -324,5 +324,5 @@ c_parray(VALUE v, long *size) { char *str, *src; - src = StringValuePtr(e); + src = RSTRING(e)->ptr; str = dlstrdup(src); ary[i] = (void*)str; @@ -473,5 +473,5 @@ rb_dl_strdup(VALUE self, VALUE str) str = rb_String(str); - return rb_dlptr_new(strdup(StringValuePtr(str)), RSTRING(str)->len, dlfree); + return rb_dlptr_new(strdup(RSTRING(str)->ptr), RSTRING(str)->len, dlfree); } @@ -483,5 +483,5 @@ rb_dl_sizeof(VALUE self, VALUE str) static VALUE -rb_dl_callback_type(VALUE str) +rb_dl_callback_type(VALUE *str) { char *type; @@ -491,6 +491,6 @@ rb_dl_callback_type(VALUE str) ftype = 0; - type = StringValuePtr(str); - len = RSTRING(str)->len; + type = StringValuePtr(*str); + len = RSTRING(*str)->len; if( len - 1 > MAX_CBARG ){ @@ -568,5 +568,5 @@ rb_dl_set_callback(int argc, VALUE argv[ }; - key = rb_dl_callback_type(types); + key = rb_dl_callback_type(&types); entry = rb_hash_aref(DLFuncTable, key); if( entry == Qnil ){ @@ -579,5 +579,5 @@ rb_dl_set_callback(int argc, VALUE argv[ rb_hash_aset(entry, num, proc); snprintf(func_name, 1023, "rb_dl_func%d_%d", NUM2INT(key), NUM2INT(num)); - return rb_dlsym_new(func, func_name, StringValuePtr(types)); + return rb_dlsym_new(func, func_name, RSTRING(types)->ptr); } else{ @@ -592,5 +592,5 @@ rb_dl_get_callback(VALUE self, VALUE typ VALUE entry; - key = rb_dl_callback_type(types); + key = rb_dl_callback_type(&types); entry = rb_hash_aref(DLFuncTable, key); if( entry == Qnil ){ Index: ext/dl/sym.c =================================================================== RCS file: /cvs/ruby/src/ruby/ext/dl/sym.c,v retrieving revision 1.2 diff -u -2 -p -r1.2 sym.c --- ext/dl/sym.c 2002/04/03 11:59:01 1.2 +++ ext/dl/sym.c 2002/04/03 15:07:03 @@ -143,14 +143,5 @@ rb_dlsym_s_new(int argc, VALUE argv[], V const char *sname, *stype; - switch( rb_scan_args(argc, argv, "12", &addr, &name, &type) ){ - case 3: - break; - case 2: - type = Qnil; - break; - case 1: - name = Qnil; - type = Qnil; - }; + rb_scan_args(argc, argv, "12", &addr, &name, &type); saddr = (void*)(DLNUM2LONG(rb_Integer(addr))); @@ -271,5 +262,5 @@ rb_dlsym_inspect(VALUE self) snprintf(str, str_size - 1, "#<DL::Symbol:0x%x func=0x%x '%s'>", - sym, sym->func, StringValuePtr(proto)); + sym, sym->func, RSTRING(proto)->len); val = rb_tainted_str_new2(str); dlfree(str); @@ -419,14 +410,17 @@ rb_dlsym_call(int argc, VALUE argv[], VA } else{ - ANY2S(args[i]) = DLSTR(StringValuePtr(argv[i])); + if( TYPE(argv[i]) != T_STRING ){ + raise(rb_eDLError, "#%d must be a string",i); + }; + ANY2S(args[i]) = DLSTR(argv[i]); }; PUSH_P(ftype); break; case 's': - if( argv[i] == Qnil ){ + if( TYPE(argv[i]) != T_STRING ){ raise(rb_eDLError, "#%d must be a string",i); }; ANY2S(args[i]) = DLSTR(dlmalloc(RSTRING(argv[i])->len + 1)); - memcpy((char*)(ANY2S(args[i])), StringValuePtr(argv[i]), RSTRING(argv[i])->len + 1); + memcpy((char*)(ANY2S(args[i])), RSTRING(argv[i])->ptr, RSTRING(argv[i])->len + 1); dtypes[i] = 's'; PUSH_P(ftype);
-- --- 僕の前にBugはない。 --- 僕の後ろにBugはできる。 中田 伸悦