[#31928] securerandom.rb for 1.8 — Tanaka Akira <akr@...>

securerandom.rb を 1.8 に追加し、cgi/session.rb に使わせたい

18 messages 2007/10/03
[#31990] Re: securerandom.rb for 1.8 — "Akinori MUSHA" <knu@...> 2007/10/09

At Wed, 3 Oct 2007 12:49:20 +0900,

[#31992] Re: securerandom.rb for 1.8 — Tanaka Akira <akr@...> 2007/10/09

In article <86k5pwinco.knu@iDaemons.org>,

[#31993] Re: securerandom.rb for 1.8 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/10/09

-----BEGIN PGP SIGNED MESSAGE-----

[#31936] Rake添付 — Yukihiro Matsumoto <matz@...>

まつもと ゆきひろです

21 messages 2007/10/04
[#31937] Re: Rake添付 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/10/04

-----BEGIN PGP SIGNED MESSAGE-----

[#31938] Re: Rake添付 — Yukihiro Matsumoto <matz@...> 2007/10/04

まつもと ゆきひろです

[#31941] Re: [ruby-list:44071] Re: Ruby 1.8.6-p111 / 1.8.5-p114 released (Security Fix) — Shugo Maeda <shugo@...>

前田です。

20 messages 2007/10/04
[#31943] Re: [ruby-list:44071] Re: Ruby 1.8.6-p111 / 1.8.5-p114 released (Security Fix) — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/10/05

-----BEGIN PGP SIGNED MESSAGE-----

[#31945] Re: [ruby-list:44071] Re: Ruby 1.8.6-p111 / 1.8.5-p114 released (Security Fix) — Shugo Maeda <shugo@...> 2007/10/05

前田です。

[#31948] Re: [ruby-list:44071] Re: Ruby 1.8.6-p111 / 1.8.5-p114 released (Security Fix) — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/10/05

-----BEGIN PGP SIGNED MESSAGE-----

[#31952] Re: [ruby-list:44071] Re: Ruby 1.8.6-p111 / 1.8.5-p114 released (Security Fix) — Shugo Maeda <shugo@...> 2007/10/05

前田です。

[#31956] Re: [ruby-list:44071] Re: Ruby 1.8.6-p111 / 1.8.5-p114 released (Security Fix) — GOTOU Yuuzou <gotoyuzo@...> 2007/10/06

In message <47063403.3070402@ruby-lang.org>,

[#31960] Re: [ruby-list:44071] Re: Ruby 1.8.6-p111 / 1.8.5-p114 released (Security Fix) — GOTOU Yuuzou <gotoyuzo@...> 2007/10/07

In message <20071006.101915.596518898.gotoyuzo@sawara.priv.tokyo.netlab.jp>,

[#31980] multibyte string/regex literal with escape sequence — "U.Nakamura" <usa@...>

こんにちは、なかむら(う)です。

24 messages 2007/10/09
[#31981] Re: multibyte string/regex literal with escape sequence — Yukihiro Matsumoto <matz@...> 2007/10/09

まつもと ゆきひろです

[#31983] Re: multibyte string/regex literal with escape sequence — "U.Nakamura" <usa@...> 2007/10/09

こんにちは、なかむら(う)です。

[#31984] Re: multibyte string/regex literal with escape sequence — Yukihiro Matsumoto <matz@...> 2007/10/09

まつもと ゆきひろです

[#31986] Re: multibyte string/regex literal with escape sequence — "U.Nakamura" <usa@...> 2007/10/09

こんにちは、なかむら(う)です。

[#31987] Re: multibyte string/regex literal with escape sequence — Yukihiro Matsumoto <matz@...> 2007/10/09

まつもと ゆきひろです

[#32003] Re: multibyte string/regex literal with escape sequence — "U.Nakamura" <usa@...> 2007/10/10

こんにちは、なかむら(う)です。

[#32133] undefined method `now' for DateTime:Class (NoMethodError) — "NAKAMURA, Hiroshi" <nakahiro@...>

-----BEGIN PGP SIGNED MESSAGE-----

12 messages 2007/10/23
[#32135] Re: undefined method `now' for DateTime:Class (NoMethodError) — tadf@... 2007/10/23

どういう状況かよくわかってないのですが、いっそ必ず date 丸ごと読むようにするか、

[#32136] Re: undefined method `now' for DateTime:Class (NoMethodError) — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/10/23

-----BEGIN PGP SIGNED MESSAGE-----

[ruby-dev:32161] extend load path

From: Tanaka Akira <akr@...>
Date: 2007-10-30 10:49:39 UTC
List: ruby-dev #32161
In article <87tzoji0tf.fsf@fsij.org>,
  Tanaka Akira <akr@fsij.org> writes:

> 中田さんの案を検討した結果、パッケージシステムとして
> RubyGems だけを考えた場合でも、RubyGems を最初にロードするコー
> ドを RubyGems ロード時点でで取り除けるなど、いくつもの利点が
> あると思うようになりました。[ruby-core:12783]
>
> で、[ruby-dev:31321] の一案というものの実装ってあるんでしょ
> うか?

作ってみました。

これにより、

loader1 = Object.new
def loader1.find_file(feature, exts) ... end
$: << loader1
...
$: << loader2
...
$: << loader3
...
$: << loader4
...
$:.delete loader2

というように、$: に付け加えたものを削除することが容易にでき
るようになります。

どうでしょうか?

Index: file.c
===================================================================
--- file.c	(リビジョン 13793)
+++ file.c	(作業コピー)
@@ -4162,7 +4162,44 @@
 }
 
 extern VALUE rb_load_path;
+static ID id_find_file, id_load_file;
 
+static int check_object_path(VALUE obj, VALUE feature, const char *const *ext, VALUE *path)
+{
+    int j;
+    VALUE exts = Qnil;
+    VALUE found;
+    if (ext) {
+        exts = rb_ary_new2(2);
+        for (j = 0; ext[j]; j++)
+            rb_ary_store(exts, j, rb_str_new2(ext[j]));
+    }
+    found = rb_funcall(obj, id_find_file, 2, rb_str_dup(feature), exts);
+    if (!RTEST(found))
+        return 0;
+    if (rb_respond_to(found, id_load_file)) {
+        *path = found;
+        return -1;
+    }
+    FilePathValue(found);
+    if (ext) {
+        for (j = 0; ext[j]; j++) {
+            int extlen = strlen(ext[j]);
+            if (extlen <= RSTRING_LEN(found) &&
+                strcmp(RSTRING_PTR(found)+RSTRING_LEN(found)-extlen,
+                       ext[j]) == 0) {
+                *path = found;
+                return j+1;
+            }
+        }
+    }
+    else {
+        *path = found;
+        return 1;
+    }
+    rb_raise(rb_eArgError, "invalid library name: %s", RSTRING_PTR(found));
+}
+
 int
 rb_find_file_ext(VALUE *filep, const char *const *ext)
 {
@@ -4200,6 +4237,13 @@
     for (i=0;i<RARRAY_LEN(rb_load_path);i++) {
 	VALUE str = RARRAY_PTR(rb_load_path)[i];
 
+        if (rb_respond_to(str, id_find_file)) {
+            int ret = check_object_path(str, *filep, ext, filep);
+            if (ret == 0)
+                continue;
+            return ret;
+        }
+
 	FilePathValue(str);
 	if (RSTRING_LEN(str) == 0) continue;
 	path = RSTRING_PTR(str);
@@ -4222,7 +4266,7 @@
 {
     VALUE tmp;
     char *f = StringValueCStr(path);
-    char *lpath;
+    int i;
 
     if (f[0] == '~') {
 	path = rb_file_expand_path(path, Qnil);
@@ -4253,36 +4297,34 @@
 	rb_raise(rb_eSecurityError, "loading from non-absolute path %s", f);
     }
 
-    if (rb_load_path) {
-	long i;
+    if (!rb_load_path) {
+	return 0;		/* no path, no load */
+    }
 
-	Check_Type(rb_load_path, T_ARRAY);
-	tmp = rb_ary_new();
-	for (i=0;i<RARRAY_LEN(rb_load_path);i++) {
-	    VALUE str = RARRAY_PTR(rb_load_path)[i];
-	    FilePathValue(str);
-	    if (RSTRING_LEN(str) > 0) {
-		rb_ary_push(tmp, str);
-	    }
-	}
-	tmp = rb_ary_join(tmp, rb_str_new2(PATH_SEP));
-	if (RSTRING_LEN(tmp) == 0) {
-	    lpath = 0;
-	}
-	else {
-	    lpath = RSTRING_PTR(tmp);
-	}
+    Check_Type(rb_load_path, T_ARRAY);
+    for (i=0;i<RARRAY_LEN(rb_load_path);i++) {
+        VALUE str = RARRAY_PTR(rb_load_path)[i];
+        char *found;
+
+        if (rb_respond_to(str, id_find_file)) {
+            VALUE file = Qnil;
+            if (check_object_path(str, path, 0, &file) == 0)
+                continue;
+            f = StringValueCStr(file);
+            goto found;
+        }
+
+        FilePathValue(str);
+        if (RSTRING_LEN(str) == 0) continue;
+        found = dln_find_file(f, RSTRING_PTR(str));
+        if (found) {
+            f = found;
+            goto found;
+        }
     }
-    else {
-	lpath = 0;
-    }
+    return 0;
 
-    if (!lpath) {
-	return 0;		/* no path, no load */
-    }
-    if (!(f = dln_find_file(f, lpath))) {
-	return 0;
-    }
+found:
     if (rb_safe_level() >= 1 && !fpath_check(f)) {
 	rb_raise(rb_eSecurityError, "loading from unsafe file %s", f);
     }
@@ -4492,4 +4534,7 @@
     rb_define_method(rb_cStat, "setuid?",  rb_stat_suid, 0);
     rb_define_method(rb_cStat, "setgid?",  rb_stat_sgid, 0);
     rb_define_method(rb_cStat, "sticky?",  rb_stat_sticky, 0);
+
+    id_find_file = rb_intern("find_file");
+    id_load_file = rb_intern("load_file");
 }
Index: eval_load.c
===================================================================
--- eval_load.c	(リビジョン 13793)
+++ eval_load.c	(作業コピー)
@@ -21,6 +21,7 @@
 #endif
     0
 };
+static ID id_load_file;
 
 static VALUE
 get_loaded_features(void)
@@ -364,6 +365,10 @@
     }
     tmp = fname;
     type = rb_find_file_ext(&tmp, loadable_ext);
+    if (type == -1) {
+        *path = tmp;
+        return 'o';
+    }
     tmp = rb_file_expand_path(tmp, Qnil);
     switch (type) {
       case 0:
@@ -421,7 +426,10 @@
 	FilePathValue(fname);
 	*(volatile VALUE *)&fname = rb_str_new4(fname);
 	found = search_required(fname, &path);
-	if (found) {
+        if (found == 'o') {
+            result = rb_funcall(path, id_load_file, 0);
+        }
+        else if (found) {
 	    if (!path || !(ftptr = load_lock(RSTRING_PTR(path)))) {
 		result = Qfalse;
 	    }
@@ -578,4 +586,6 @@
 
     ruby_dln_librefs = rb_ary_new();
     rb_register_mark_object(ruby_dln_librefs);
+
+    id_load_file = rb_intern("load_file");
 }


-- 
[田中 哲][たなか あきら][Tanaka Akira]

In This Thread