[#30872] segv when reentering into Fiber with callcc — sheepman <sheepman@...>

こんばんは、sheepman です。

15 messages 2007/06/01
[#30899] Re: segv when reentering into Fiber with callcc — SASADA Koichi <ko1@...> 2007/06/06

 ささだです。

[#30905] Re: segv when reentering into Fiber with callcc — "Yusuke ENDOH" <mame@...> 2007/06/06

遠藤と申します。

[#30906] Re: segv when reentering into Fiber with callcc — SASADA Koichi <ko1@...> 2007/06/06

 ささだです。

[#30929] secrand.rb — "NAKAMURA, Hiroshi" <nakahiro@...>

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

51 messages 2007/06/08
[#30930] Re: secrand.rb — Tanaka Akira <akr@...> 2007/06/08

In article <4669066C.2080307@sarion.co.jp>,

[#30934] Re: secrand.rb — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/06/08

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

[#30935] Re: secrand.rb — Tanaka Akira <akr@...> 2007/06/08

In article <46694461.4060706@sarion.co.jp>,

[#30936] Re: secrand.rb — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/06/08

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

[#30938] Re: secrand.rb — Tanaka Akira <akr@...> 2007/06/08

In article <46697C0B.8060402@sarion.co.jp>,

[#30939] Re: secrand.rb — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/06/08

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

[#30940] Re: secrand.rb — Tanaka Akira <akr@...> 2007/06/08

In article <4669DAB0.4050705@sarion.co.jp>,

[#30944] Re: secrand.rb — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/06/09

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

[#30945] Re: secrand.rb — Tanaka Akira <akr@...> 2007/06/09

In article <466AA73C.9030407@sarion.co.jp>,

[#30946] Re: secrand.rb — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/06/09

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

[#30950] Re: secrand.rb — Nobuyoshi Nakada <nobu@...> 2007/06/11

なかだです。

[#31173] Re: Random — Tanaka Akira <akr@...> 2007/07/10

In article <469253E9.9010203@sarion.co.jp>,

[#31174] Re: Random — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/07/10

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

[#31178] Re: Random — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/07/11

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

[#31179] Re: Random — Tanaka Akira <akr@...> 2007/07/11

In article <4694338C.7090303@sarion.co.jp>,

[#31183] Re: Random — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/07/11

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

[#30971] Linux/ia64で'ucontext_t' undeclared — akira yamada / やまだあきら <akira@...>

最近のRuby 1.9をLinux/ia64上でmakeしようとすると

16 messages 2007/06/13
[#30973] Re: Linux/ia64で'ucontext_t' undeclared — Yukihiro Matsumoto <matz@...> 2007/06/13

まつもと ゆきひろです

[#30974] Re: Linux/ia64で'ucontext_t' undeclared — akira@... 2007/06/13

Yukihiro Matsumoto さんは書きました:

[#30975] Re: Linux/ia64で'ucontext_t' undeclared — Yukihiro Matsumoto <matz@...> 2007/06/13

まつもと ゆきひろです

[ruby-dev:31028] rb_get_interned

From: Nobuyoshi Nakada <nobu@...>
Date: 2007-06-20 05:44:57 UTC
List: ruby-dev #31028
なかだです。

以前追加されたrb_sym_interned_p()は結局、intern.hに宣言だけ残し
て消されてしまったようですが、変数や定数が定義されているかを調
べようとするだけで新しい名前が登録されてしまうのは無駄のような
気がします。

  ID rb_get_interned(const char *name, long len);

のような形で既存の名前だけを探すというのはどうでしょうか。
とりあえずvariable.c:rb_path2class()を例に。


Index: parse.y
===================================================================
--- parse.y	(revision 12575)
+++ parse.y	(working copy)
@@ -8418,17 +8418,57 @@ rb_symname_p(const char *name)
 }
 
+static ID
+id_register(VALUE str, ID id)
+{
+    OBJ_FREEZE(str);
+    st_add_direct(global_symbols.sym_id, (st_data_t)str, id);
+    st_add_direct(global_symbols.id_str, id, (st_data_t)str);
+    return id;
+}
+
+static ID
+get_interned(VALUE str)
+{
+    st_data_t id;
+
+    if (st_lookup(global_symbols.sym_id, (st_data_t)str, &id))
+	return (ID)id;
+
+    if (RSTRING_LEN(str) > 0) {
+	const char *name = RSTRING_PTR(str);
+	char c = *name;
+
+	if (c != '_' && c != '$' && c != '@' && ISASCII(c) && !ISALNUM(c)) {
+	    /* operators */
+	    int i;
+
+	    for (i = 0; op_tbl[i].token; i++) {
+		if (*op_tbl[i].name == *name &&
+		    strcmp(op_tbl[i].name, name) == 0) {
+		    return id_register(str, op_tbl[i].token);
+		}
+	    }
+	}
+    }
+
+    return 0;
+}
+
+ID
+rb_get_interned(const char *name, long len)
+{
+    return get_interned(rb_str_new(name, len));
+}
+
 ID
 rb_intern2(const char *name, long len)
 {
     const char *m = name;
-    VALUE str = rb_str_new(name, len);
-    ID id;
     int last;
+    VALUE str = rb_str_new(name, len);
+    ID id = get_interned(str);
 
-    if (st_lookup(global_symbols.sym_id, (st_data_t)str, (st_data_t *)&id))
-	return id;
-
+    if (id) return id;
     last = len-1;
-    id = 0;
     switch (*name) {
       case '$':
@@ -8447,23 +8487,9 @@ rb_intern2(const char *name, long len)
 	break;
       default:
-	if (name[0] != '_' && ISASCII(name[0]) && !ISALNUM(name[0])) {
-	    /* operators */
-	    int i;
-
-	    for (i=0; op_tbl[i].token; i++) {
-		if (*op_tbl[i].name == *name &&
-		    strcmp(op_tbl[i].name, name) == 0) {
-		    id = op_tbl[i].token;
-		    goto id_register;
-		}
-	    }
-	}
-
-	if (name[last] == '=') {
+	if (name[last] == '=' && last > 1 && name[last-1] != '=') {
 	    /* attribute assignment */
 	    id = rb_intern2(name, last);
 	    if (id > tLAST_TOKEN && !is_attrset_id(id)) {
-		id = rb_id_attrset(id);
-		goto id_register;
+		return id_register(str, rb_id_attrset(id));
 	    }
 	    id = ID_ATTRSET;
@@ -8485,9 +8511,5 @@ rb_intern2(const char *name, long len)
   new_id:
     id |= ++global_symbols.last_id << ID_SCOPE_SHIFT;
-  id_register:
-    OBJ_FREEZE(str);
-    st_add_direct(global_symbols.sym_id, (st_data_t)str, id);
-    st_add_direct(global_symbols.id_str, id, (st_data_t)str);
-    return id;
+    return id_register(str, id);
 }
 
Index: variable.c
===================================================================
--- variable.c	(revision 12575)
+++ variable.c	(working copy)
@@ -237,5 +237,6 @@ rb_path2class(const char *path)
     while (*p) {
 	while (*p && *p != ':') p++;
-	id = rb_intern2(pbeg, p-pbeg);
+	id = rb_get_interned(pbeg, p-pbeg);
+	if (!id) goto undefined_class;
 	if (p[0] == ':') {
 	    if (p[1] != ':') goto undefined_class;
Index: include/ruby/intern.h
===================================================================
--- include/ruby/intern.h	(revision 12575)
+++ include/ruby/intern.h	(working copy)
@@ -408,5 +409,4 @@ int rb_is_local_id(ID);
 int rb_is_junk_id(ID);
 int rb_symname_p(const char*);
-int rb_sym_interned_p(VALUE);
 void rb_gc_mark_symbols(void);
 VALUE rb_backref_get(void);
Index: include/ruby/ruby.h
===================================================================
--- include/ruby/ruby.h	(revision 12575)
+++ include/ruby/ruby.h	(working copy)
@@ -614,4 +614,5 @@ void rb_gc_unregister_address(VALUE*);
 ID rb_intern(const char*);
 ID rb_intern2(const char*, long);
+ID rb_get_interned(const char*, long);
 const char *rb_id2name(ID);
 ID rb_to_id(VALUE);


-- 
--- 僕の前にBugはない。
--- 僕の後ろにBugはできる。
    中田 伸悦

In This Thread

Prev Next