[#31927] Re: Problem with Ruby 1.8.6-p110 on DragonFly (was [PATCH] Problem with ruby 1.8.6-p36 (and p39) on Tiger) — Takahiro Kambe <taca@...>
こんばんは。
[#31928] securerandom.rb for 1.8 — Tanaka Akira <akr@...>
securerandom.rb を 1.8 に追加し、cgi/session.rb に使わせたい
At Wed, 3 Oct 2007 12:49:20 +0900,
In article <86k5pwinco.knu@iDaemons.org>,
-----BEGIN PGP SIGNED MESSAGE-----
まつもと ゆきひろです
-----BEGIN PGP SIGNED MESSAGE-----
まつもと ゆきひろです
-----BEGIN PGP SIGNED MESSAGE-----
[#31936] Rake添付 — Yukihiro Matsumoto <matz@...>
まつもと ゆきひろです
-----BEGIN PGP SIGNED MESSAGE-----
まつもと ゆきひろです
Yukihiro Matsumoto さんは書きました:
-----BEGIN PGP SIGNED MESSAGE-----
NAKAMURA, Hiroshi さんは書きました:
At Wed, 10 Oct 2007 16:46:01 +0900,
-----BEGIN PGP SIGNED MESSAGE-----
[#31941] Re: [ruby-list:44071] Re: Ruby 1.8.6-p111 / 1.8.5-p114 released (Security Fix) — Shugo Maeda <shugo@...>
前田です。
-----BEGIN PGP SIGNED MESSAGE-----
前田です。
-----BEGIN PGP SIGNED MESSAGE-----
前田です。
In message <47063403.3070402@ruby-lang.org>,
In message <20071006.101915.596518898.gotoyuzo@sawara.priv.tokyo.netlab.jp>,
前田です。
In message <4709852A.1020606@ruby-lang.org>,
-----BEGIN PGP SIGNED MESSAGE-----
In message <470D9227.9090008@sarion.co.jp>,
-----BEGIN PGP SIGNED MESSAGE-----
[#31959] pcc: constant too big for cross-compiler — "NARUSE, Yui" <naruse@...>
成瀬です。
In article <470884D1.9040401@airemix.com>,
[#31980] multibyte string/regex literal with escape sequence — "U.Nakamura" <usa@...>
こんにちは、なかむら(う)です。
まつもと ゆきひろです
こんにちは、なかむら(う)です。
まつもと ゆきひろです
こんにちは、なかむら(う)です。
まつもと ゆきひろです
成瀬です。
こんにちは、なかむら(う)です。
In article <20071010091006.1988.USA@garbagecollect.jp>,
成瀬です。
In article <471003CB.7060701@airemix.com>,
成瀬です。
[#32049] Re: iconv enhancement in Ruby 1.9 — Nobuyoshi Nakada <nobu@...>
なかだです。
[#32133] undefined method `now' for DateTime:Class (NoMethodError) — "NAKAMURA, Hiroshi" <nakahiro@...>
-----BEGIN PGP SIGNED MESSAGE-----
どういう状況かよくわかってないのですが、いっそ必ず date 丸ごと読むようにするか、
-----BEGIN PGP SIGNED MESSAGE-----
> もしかして、単にtime.rbの「require 'parsedate'」を削ればいいだけだったり
-----BEGIN PGP SIGNED MESSAGE-----
> 確かに。で、1.9でparsedate.rbがなくなることを考えると、とりあえずtime.rb
In article <4b1598ce0710231835p1a0b3040kcc89bf0017a60c21@mail.gmail.com>,
[ruby-dev:32161] extend load path
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]