[#2367] Standard libraries — Dave Thomas <dave@...>

From ruby-dev summary:

60 messages 2004/02/11

[#2397] PATCH: deprecate cgi-lib, getopts, importenv, parsearg from standard library — Gavin Sinclair <gsinclair@...>

Index: cgi-lib.rb

15 messages 2004/02/12

[#2465] PATCH: OpenStruct#initialize to yield self — Gavin Sinclair <gsinclair@...>

This is a common approach I use to object initialization; I don't know

24 messages 2004/02/19

Maybe bug

From: "Dmitry V. Sabanin" <sdmitry@...>
Date: 2004-02-09 20:23:48 UTC
List: ruby-core #2364
Hi there
I was writing my C extension for ruby, and when it comes to use it I found that strange behavior.
When i.e. I have source file extensionbla.so, and Init_extensionbla function is defined inside it.
But when I'm trying to symlink that file to, for example, 
cd lib
ln -s ../ext/extensionbla.so extension.so
after a simple ruby -e 'require "extension.so"' I see message like: "Init_extension" is not defined.
I found the problem, it's ruby that tries to match Init_ function by using symlink name, not the real file one.
Here is the patch, I have no hope that it will be commited to cvs as it is, but maybe you could understand better
what the problem is about.
-- 
sdmitry -=- Dmitry V. Sabanin
MuraveyLabs.
Spam Here -> postmaster@sco.com

Attachments (1)

eval.c.patch (1.13 KB, text/x-diff)
Index: eval.c
===================================================================
RCS file: /src/ruby/eval.c,v
retrieving revision 1.634
diff -u -3 -p -r1.634 eval.c
--- eval.c	22 Jan 2004 08:31:32 -0000	1.634
+++ eval.c	9 Feb 2004 20:12:58 -0000
@@ -6651,6 +6651,7 @@ rb_require_safe(fname, safe)
 {
     VALUE result = Qnil;
     int state;
+		char *real_path;    
     struct {
 	NODE *node;
 	ID func;
@@ -6703,7 +6704,14 @@ rb_require_safe(fname, safe)
 		    ruby_sourcefile = rb_source_filename(RSTRING(path)->ptr);
 		    ruby_sourceline = 0;
 		    ruby_frame->last_func = 0;
-		    SCOPE_SET(SCOPE_PUBLIC);
+        real_path = ALLOC_N(char,1024);
+        MEMZERO(real_path,char,1024);
+        if(readlink(ruby_sourcefile,real_path,1024) > 0) {
+          path = rb_funcall(rb_const_get(rb_cObject,rb_intern("File")),rb_intern("dirname"),1,path);
+          rb_funcall(path,rb_intern("<<"),1,rb_str_new2("/"));
+          rb_funcall(path,rb_intern("<<"),1,rb_str_new2(real_path));
+        }
+        SCOPE_SET(SCOPE_PUBLIC);
 		    handle = (long)dln_load(RSTRING(path)->ptr);
 		    rb_ary_push(ruby_dln_librefs, LONG2NUM(handle));
 		    break;

In This Thread

Prev Next