[#16211] pstore.rb and sync.rb — Kazuhiro NISHIYAMA <zn@...>

西山和広です。

19 messages 2002/03/04
[#16245] Re: pstore.rb and sync.rb — keiju@... (石塚圭樹) 2002/03/07

けいじゅ@日本ラショナルソフトウェアです.

[#16240] [Oni Guruma] look behind — nobu.nakada@...

なかだです。

14 messages 2002/03/07

[#16283] ライブラリ拡大計画 — matz@... (Yukihiro Matsumoto)

まつもと ゆきひろです

124 messages 2002/03/08
[#16307] Re: ライブラリ拡大計画 — TAKAHASHI Masayoshi <maki@...> 2002/03/10

高橋征義です。

[#16317] Re: ライブラリ拡大計画 — matz@... (Yukihiro Matsumoto) 2002/03/11

まつもと ゆきひろです

[#16318] Re: ライブラリ拡大計画 — Tanaka Akira <akr@...17n.org> 2002/03/11

In article <1015827556.101112.6552.nullmailer@ev.netlab.jp>,

[#16320] Re: ライブラリ拡大計画 — matz@... (Yukihiro Matsumoto) 2002/03/11

まつもと ゆきひろです

[#16347] Re: ライブラリ拡大計画 — Minero Aoki <aamine@...> 2002/03/12

あおきです。

[#16308] Re: ライブラリ拡大計画 — WATANABE Hirofumi <eban@...> 2002/03/11

わたなべです。

[#16626] Re: ライブラリ拡大計画 — matz@... (Yukihiro Matsumoto) 2002/03/27

まつもと ゆきひろです

[#16628] Re: ライブラリ拡大計画 — Takaaki Tateishi <ttate@...> 2002/03/27

At Wed, 27 Mar 2002 18:56:03 +0900,

[#16629] Re: ライブラリ拡大計画 — matz@... (Yukihiro Matsumoto) 2002/03/27

まつもと ゆきひろです

[#16647] Re: ライブラリ拡大計画 — Takaaki Tateishi <ttate@...> 2002/03/28

At Thu, 28 Mar 2002 00:12:49 +0900,

[#16674] Re: ライブラリ拡大計画 — Takaaki Tateishi <ttate@...> 2002/03/29

At Thu, 28 Mar 2002 23:45:49 +0900,

[#16675] Re: ライブラリ拡大計画 — matz@... (Yukihiro Matsumoto) 2002/03/29

まつもと ゆきひろです

[#16680] Re: ライブラリ拡大計画 — nobu.nakada@... 2002/03/29

なかだです。

[#16681] Re: ライブラリ拡大計画 — matz@... (Yukihiro Matsumoto) 2002/03/29

まつもと ゆきひろです

[#16683] Re: ライブラリ拡大計画 — nobu.nakada@... 2002/03/29

なかだです。

[#16687] Re: ライブラリ拡大計画 — Takaaki Tateishi <ttate@...> 2002/03/30

At Fri, 29 Mar 2002 20:32:17 +0900,

[#16718] Re: ライブラリ拡大計画 — Takaaki Tateishi <ttate@...> 2002/04/02

At Sun, 31 Mar 2002 02:20:04 +0900,

[#16371] Re: ライブラリ拡大計画 — Takaaki Tateishi <ttate@...> 2002/03/13

At Fri, 8 Mar 2002 18:05:01 +0900,

[#16373] Re: ライブラリ拡大計画 — matz@... (Yukihiro Matsumoto) 2002/03/14

まつもと ゆきひろです

[#16397] Re: ライブラリ拡大計画 — nobu.nakada@... 2002/03/14

なかだです。

[#16404] Re: ライブラリ拡大計画 — Tanaka Akira <akr@...17n.org> 2002/03/14

In article <20020314133401.3918E10F3@sharui.nakada.kanuma.tochigi.jp>,

[#16406] Re: ライブラリ拡大計画 — nobu.nakada@... 2002/03/15

なかだです。

[#16290] IO#gets improvement — nobu.nakada@...

なかだです。

27 messages 2002/03/08
[#16291] Re: IO#gets improvement — Tanaka Akira <akr@...17n.org> 2002/03/08

In article <20020308131426.8C36123B9@sharui.nakada.kanuma.tochigi.jp>,

[#16294] Re: IO#gets improvement — nobu.nakada@... 2002/03/09

なかだです。

[#16549] Re: IO#gets improvement — nobu.nakada@... 2002/03/23

なかだです。

[#16486] mswin32 configuration — nobu.nakada@...

なかだです。

20 messages 2002/03/19
[#16488] Re: mswin32 configuration — "U.Nakamura" <usa@...> 2002/03/19

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

[#16489] Re: mswin32 configuration — nobu.nakada@... 2002/03/19

なかだです。

[#16490] Re: mswin32 configuration — "U.Nakamura" <usa@...> 2002/03/19

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

[#16545] BigFloat — matz@... (Yukihiro Matsumoto)

まつもと ゆきひろです

51 messages 2002/03/23
[#16547] Re: BigFloat — "Akinori MUSHA" <knu@...> 2002/03/23

At Sat, 23 Mar 2002 22:55:45 +0900,

[#16548] Re: BigFloat — "Akinori MUSHA" <knu@...> 2002/03/23

At Sun, 24 Mar 2002 02:20:26 +0900,

[#16550] Re: BigFloat — Tanaka Akira <akr@...17n.org> 2002/03/23

In article <867ko3yyik.wl@archon.local.idaemons.org>,

[#16551] Re: BigFloat — "Akinori MUSHA" <knu@...> 2002/03/23

At Sun, 24 Mar 2002 04:21:59 +0900,

[#16552] Re: BigFloat — Tanaka Akira <akr@...17n.org> 2002/03/23

In article <864rj7yljs.wl@archon.local.idaemons.org>,

[#16553] Re: BigFloat — "Akinori MUSHA" <knu@...> 2002/03/23

At Sun, 24 Mar 2002 07:44:15 +0900,

[#16560] Re: BigFloat — Tanaka Akira <akr@...17n.org> 2002/03/24

In article <861yeazvtg.wl@archon.local.idaemons.org>,

[#16565] Re: BigFloat — "Akinori MUSHA" <knu@...> 2002/03/24

At Sun, 24 Mar 2002 15:41:18 +0900,

[#16575] Re: if Re: BigFloat — keiju@... (石塚圭樹) 2002/03/24

けいじゅ@日本ラショナルソフトウェアです.

[#16715] Re: if Re: BigFloat — keiju@... (石塚圭樹) 2002/04/02

けいじゅ@日本ラショナルソフトウェアです.

[#16725] Re: if Re: BigFloat — "Akinori MUSHA" <knu@...> 2002/04/02

At Tue, 2 Apr 2002 16:16:04 +0900,

[#16789] Re: if Re: BigFloat — "Shigeo Kobayashi" <shigeo@...> 2002/04/08

[#16805] Re: if Re: BigFloat — Shin-ichiro HARA <sinara@...> 2002/04/09

原です。

[#16811] Re: if Re: BigFloat — "Shigeo Kobayashi" <shigeo@...> 2002/04/09

[#16555] File.fnmatch (Re: [rubyist:1286] Re: ARGV の機能) — Koji Arai <JCA02266@...>

新井です。

11 messages 2002/03/24

[#16593] Oniguruma and multibyte character literal — TAKAHASHI Masayoshi <maki@...>

高橋征義です。

15 messages 2002/03/25
[#16594] Re: Oniguruma and multibyte character literal — matz@... (Yukihiro Matsumoto) 2002/03/25

まつもと ゆきひろです

[#16652] [OniGuruma] nested repeat operator — "K.Kosako" <kosako@...>

[ruby-talk:36959]で指摘された

31 messages 2002/03/29
[#16669] Re: [OniGuruma] nested repeat operator — Tanaka Akira <akr@...17n.org> 2002/03/29

In article <20020329022810.68F9E17@helium.ruby-lang.org>,

[#16676] Re: [OniGuruma] nested repeat operator — "K.Kosako" <kosako@...> 2002/03/29

Tanaka Akiraさんの<hvohemzoku6.fsf@coulee.a02.aist.go.jp>から

[ruby-dev:16188] Re: Defining (Python) Source Code Encoding

From: nobu.nakada@...
Date: 2002-03-03 17:24:20 UTC
List: ruby-dev #16188
なかだです。

At Sun, 3 Mar 2002 16:14:58 +0900,
TAKAHASHI Masayoshi wrote:
> > > PEP(RCRのPython版)の263番で、「Defining Python Source Code Encoding」
> > > というdraftが出ています。要するに、ソースコードのencodingの判別に、
> > > 
> > >   #!/usr/bin/python
> > >   # -*- coding: <encoding name> -*-
> > > 
> > > というEmacs互換(?)な感じのコメントを書いておけば、処理系側でも
> > > その値を使うようにする、というものです。
> > 
> > この形式も考えてはいたんですが、Emacsってencodingも-*-で指定で
> > きましたっけ。
> 
> python-dev では「GNU Emacs21ならutf-8でもおーけー。XEmacs
> はだめみたいだけど、どうするつもりかXEmacs communityに聞いて
> みる」と言っています。vim6ではpluginで対応できるそうです。
> 
> この辺は仕様が乱立してもうれしくないので、協調してほしいところ
> ですね。

なるほど。とりあえず合わせてみますか。ってかなり手抜き。あと、
かなり謎なmodesetという単語を、もうちょっとマシなものにしないと。

> # なお、彼らは「JapaneseCodesも取り込めば、Rubyも敵じゃないよん」
> # (超意訳)とかゆってます :-)
> # http://mail.python.org/pipermail/python-dev/2002-February/020483.html

Rubyの場合、Unicodizationを考えない分codecのサイズとかは気にす
る必要はないわけですが、個別の対応が要りますからねぇ。そろそろ
m17nを取り込みたいところです。


Index: intern.h
===================================================================
RCS file: /cvs/ruby/src/ruby/intern.h,v
retrieving revision 1.81
diff -u -2 -p -r1.81 intern.h
--- intern.h	2002/02/20 06:33:24	1.81
+++ intern.h	2002/03/03 10:13:34
@@ -332,4 +332,5 @@ void ruby_load_script _((void));
 void ruby_init_loadpath _((void));
 void ruby_incpush _((const char*));
+void ruby_modeset _((const char*, int));
 /* signal.c */
 VALUE rb_f_kill _((int, VALUE*));
Index: parse.y
===================================================================
RCS file: /cvs/ruby/src/ruby/parse.y,v
retrieving revision 1.156
diff -u -2 -p -r1.156 parse.y
--- parse.y	2002/02/20 04:31:50	1.156
+++ parse.y	2002/03/03 14:54:31
@@ -2985,7 +2985,7 @@ yylex()
 
       case '#':		/* it's a comment */
-	while ((c = nextc()) != '\n') {
-	    if (c == -1)
-		return 0;
+	while (lex_p < lex_pend) {
+	    ruby_modeset(lex_p, lex_pend - lex_p);
+	    lex_p = lex_pend;
 	}
 	/* fall through */
Index: ruby.c
===================================================================
RCS file: /cvs/ruby/src/ruby/ruby.c,v
retrieving revision 1.56
diff -u -2 -p -r1.56 ruby.c
--- ruby.c	2002/02/10 07:55:40	1.56
+++ ruby.c	2002/03/03 17:08:44
@@ -19,4 +19,5 @@
 #include "dln.h"
 #include "node.h"
+#include "regex.h"
 #include <stdio.h>
 #include <sys/types.h>
@@ -335,5 +336,82 @@ require_libraries()
 }
 
+/* emacsen -*- hack */
+typedef void (*rb_modeset_setter_t) _((const char *val, const char *name));
+
+struct modeset {
+    const char *name;
+    rb_modeset_setter_t func;
+};
+
+static const struct modeset modesets[] = {
+    {"coding", (rb_modeset_setter_t)rb_set_kcode},
+};
+
+static const char modeset_pattern[] = ".*-\\*-\\s*(.*?)\\s*-\\*-";
+static struct re_pattern_buffer modeset_re;
+
+static const char modeset_scan_pattern[] =
+"([^\\s\'\":;]+)\\s*:\\s*(\"(?:\\\\.|[^\"])*\"|[^\"\\s;]+)[\\s;]*";
+static struct re_pattern_buffer modeset_scan_re;
+
 static void
+Init_modeset _((void))
+{
+    re_compile_pattern(modeset_pattern,
+		       sizeof(modeset_pattern) - 1,
+		       &modeset_re);
+    re_compile_pattern(modeset_scan_pattern,
+		       sizeof(modeset_scan_pattern) - 1,
+		       &modeset_scan_re);
+}
+
+void
+ruby_modeset(str, len)
+    const char *str;
+    int len;
+{
+#define str_copy(_s, _p, _n) ((_s) \
+	? (rb_str_resize((_s), (_n)), \
+	   MEMCPY(RSTRING(_s)->ptr, (_p), char, (_n)), (_s)) \
+	: ((_s) = rb_str_new((_p), (_n))))
+#define match(_re, _p, _n) (MEMZERO(&regs, struct re_registers, 1), \
+			    re_match(&(_re), (_p), (_n), 0, &regs))
+    struct re_registers regs;
+    VALUE name = 0, val = 0;
+
+    if (match(modeset_re, str, len) < 0) return;
+
+    len = regs.end[1] - regs.beg[1];
+    str += regs.beg[1];
+    re_free_registers(&regs);
+
+    while (match(modeset_scan_re, str, len) >= 0) {
+	const struct modeset *p = modesets;
+	int e0 = regs.end[0];
+	int n1 = regs.end[1] - regs.beg[1];
+	int s2 = regs.beg[2];
+	int n2 = regs.end[2] - s2;
+	re_free_registers(&regs);
+
+	str_copy(name, str, n1);
+	rb_funcall(name, rb_intern("downcase!"), 0);
+
+	do {
+	    if (strncmp(p->name, RSTRING(name)->ptr, n1) == 0) {
+		str_copy(val, str + s2, n2);
+		(*p->func)(RSTRING(val)->ptr, RSTRING(name)->ptr);
+		break;
+	    }
+	} while (++p < modesets + sizeof(modesets) / sizeof(*p));
+
+	len -= e0;
+	str += e0;
+    }
+
+    if (name) rb_gc_force_recycle(name);
+    if (val) rb_gc_force_recycle(val);
+}
+
+static void
 process_sflag()
 {
@@ -843,4 +921,7 @@ load_file(fname, script)
 		}
 	    }
+	    if (RSTRING(line)->len > 1) {
+		ruby_modeset(RSTRING(line)->ptr, RSTRING(line)->len);
+	    }
 	}
 	else if (!NIL_P(c)) {
@@ -1007,4 +1088,6 @@ ruby_prog_init()
     rb_define_readonly_variable("$-a", &do_split);
     rb_global_variable(&rb_argv0);
+
+    Init_modeset();
 
 #ifdef MSDOS


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

In This Thread