summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog13
-rw-r--r--README.EXT.jp7
-rw-r--r--ext/gtk/depend2
-rw-r--r--io.c25
-rw-r--r--keywords2
-rw-r--r--lex.c44
-rw-r--r--lib/date.rb26
-rw-r--r--lib/delegate.rb18
-rw-r--r--lib/final.rb16
-rw-r--r--lib/parsedate.rb4
-rw-r--r--lib/tempfile.rb11
-rw-r--r--lib/weakref.rb2
-rw-r--r--node.h6
-rw-r--r--parse.y16
-rw-r--r--rubytest.rb1
-rw-r--r--sample/fib.scm4
-rw-r--r--sample/ruby-mode.el7
17 files changed, 144 insertions, 60 deletions
diff --git a/ChangeLog b/ChangeLog
index 5286843b09..6029e13952 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,11 @@ Thu Jan 29 18:36:25 1998 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
* process.c (rb_proc_exec): check `sh' to be exist.
+Thu Jan 29 18:18:19 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (io_stdio_set): assignment to $stdin or $stdout does
+ reopen() as well as $stderr.
+
Thu Jan 29 14:18:40 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
* class.c (mod_ancestors): should not include singleton classes.
@@ -14,6 +19,10 @@ Thu Jan 29 11:50:35 1998 Toshihiko SHIMOKAWA <toshi@csce.kyushu-u.ac.jp>
* ext/socket/socket.c (udp_addrsetup): forgot to use htons().
+Tue Jan 27 23:15:24 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * keywords: __FILE__, __LINE__ are available again.
+
Fri Jan 23 14:19:28 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
* version 1.1b6 released.
@@ -35,8 +44,8 @@ Thu Jan 22 16:21:08 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
* eval.c (rb_eval): some singleton class def cause SEGV.
- * eval.c (ALLOCTMP): replace ALLOCA_N, where thread context switch
- may happen.
+ * eval.c (TMP_ALLOC): replace ALLOCA_N, where thread context
+ switch may happen.
Wed Jan 21 01:43:42 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
diff --git a/README.EXT.jp b/README.EXT.jp
index 3b430de65a..980aff0394 100644
--- a/README.EXT.jp
+++ b/README.EXT.jp
@@ -712,6 +712,13 @@ rubyのディレクトリでmakeを実行するとMakefileを生成からmake,
してくれます.extconf.rbを書き換えるなどしてMakefileの再生成
が必要な時はまたrubyディレクトリでmakeしてください.
+動的リンクライブラリはmake installでrubyライブラリのディレク
+トリの下にコピーされます.もしモジュールと協調して使うrubyで
+記述されたプログラムがあり,rubyライブラリに置きたい場合には,
+拡張モジュール用のディレクトリの下に lib というディレクトリ
+を作り,そこに 拡張子 .rb のファイルを置いておけば同時にイン
+ストールされます.
+
(9) デバッグ
まあ,デバッグしないと動かないでしょうね.ext/Setupにディレ
diff --git a/ext/gtk/depend b/ext/gtk/depend
new file mode 100644
index 0000000000..4cd0e181d4
--- /dev/null
+++ b/ext/gtk/depend
@@ -0,0 +1,2 @@
+gtk.o: gtk.c $(hdrdir)/ruby.h $(hdrdir)/config.h $(hdrdir)/defines.h \
+ $(hdrdir)/intern.h $(hdrdir)/sig.h
diff --git a/io.c b/io.c
index 0975ab8f11..5b10bb6091 100644
--- a/io.c
+++ b/io.c
@@ -1394,18 +1394,27 @@ io_defset(val, id)
}
static void
-io_errset(val, id)
+io_stdio_set(val, id, var)
VALUE val;
ID id;
+ VALUE *var;
{
- OpenFile *fptr;
+ OpenFile *fptr, *fptr2;
int fd;
- FILE *f;
if (TYPE(val) != T_FILE) {
- TypeError("$stderr must be IO Object");
+ TypeError("%s must be IO object", rb_id2name(id));
+ }
+ GetOpenFile(*var, fptr);
+ fd = fileno(fptr->f);
+ GetOpenFile(val, fptr);
+ if (fd == 0) {
+ io_readable(fptr);
+ }
+ else {
+ io_writable(fptr);
}
- io_reopen(rb_stderr, val);
+ io_reopen(*var, val);
}
static VALUE
@@ -2363,11 +2372,11 @@ Init_IO()
rb_define_method(cIO, "fcntl", io_fcntl, -1);
rb_stdin = prep_stdio(stdin, FMODE_READABLE);
- rb_define_readonly_variable("$stdin", &rb_stdin);
+ rb_define_hooked_variable("$stdin", &rb_stdin, 0, io_stdio_set);
rb_stdout = prep_stdio(stdout, FMODE_WRITABLE);
- rb_define_readonly_variable("$stdout", &rb_stdout);
+ rb_define_hooked_variable("$stdout", &rb_stdout, 0, io_stdio_set);
rb_stderr = prep_stdio(stderr, FMODE_WRITABLE);
- rb_define_hooked_variable("$stderr", &rb_stderr, 0, io_errset);
+ rb_define_hooked_variable("$stderr", &rb_stderr, 0, io_stdio_set);
rb_defout = rb_stdout;
rb_define_hooked_variable("$>", &rb_defout, 0, io_defset);
diff --git a/keywords b/keywords
index 9e3870d1a6..1772de42b0 100644
--- a/keywords
+++ b/keywords
@@ -1,5 +1,7 @@
struct kwtable {char *name; int id[2]; enum lex_state state;};
%%
+__LINE__, k__LINE__, k__LINE__, EXPR_END
+__FILE__, k__FILE__, k__FILE__, EXPR_END
BEGIN, klBEGIN, klBEGIN, EXPR_END
END, klEND, klEND, EXPR_END
alias, kALIAS, kALIAS, EXPR_FNAME
diff --git a/lex.c b/lex.c
index 390471c424..1abc048638 100644
--- a/lex.c
+++ b/lex.c
@@ -2,12 +2,12 @@
/* Command-line: gperf -p -j1 -i 1 -g -o -t -N rb_reserved_word -k1,3,$ keywords */
struct kwtable {char *name; int id[2]; enum lex_state state;};
-#define TOTAL_KEYWORDS 38
+#define TOTAL_KEYWORDS 40
#define MIN_WORD_LENGTH 2
#define MAX_WORD_LENGTH 8
#define MIN_HASH_VALUE 6
-#define MAX_HASH_VALUE 52
-/* maximum key range = 47, duplicates = 0 */
+#define MAX_HASH_VALUE 55
+/* maximum key range = 50, duplicates = 0 */
#ifdef __GNUC__
inline
@@ -19,19 +19,19 @@ hash (str, len)
{
static unsigned char asso_values[] =
{
- 53, 53, 53, 53, 53, 53, 53, 53, 53, 53,
- 53, 53, 53, 53, 53, 53, 53, 53, 53, 53,
- 53, 53, 53, 53, 53, 53, 53, 53, 53, 53,
- 53, 53, 53, 53, 53, 53, 53, 53, 53, 53,
- 53, 53, 53, 53, 53, 53, 53, 53, 53, 53,
- 53, 53, 53, 53, 53, 53, 53, 53, 53, 53,
- 53, 53, 53, 11, 53, 53, 34, 53, 1, 35,
- 53, 1, 53, 53, 53, 53, 53, 53, 1, 53,
- 53, 53, 53, 53, 53, 53, 53, 53, 53, 53,
- 53, 53, 53, 53, 53, 53, 53, 29, 1, 2,
- 1, 1, 4, 24, 53, 17, 53, 20, 9, 2,
- 9, 26, 14, 53, 5, 1, 1, 16, 53, 21,
- 24, 9, 53, 53, 53, 53, 53, 53,
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 11, 56, 56, 36, 56, 1, 37,
+ 31, 1, 56, 56, 56, 56, 29, 56, 1, 56,
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 1, 56, 32, 1, 2,
+ 1, 1, 4, 23, 56, 17, 56, 20, 9, 2,
+ 9, 26, 14, 56, 5, 1, 1, 16, 56, 21,
+ 20, 9, 56, 56, 56, 56, 56, 56,
};
register int hval = len;
@@ -87,17 +87,19 @@ rb_reserved_word (str, len)
{"until", kUNTIL, kUNTIL_MOD, EXPR_BEG},
{"unless", kUNLESS, kUNLESS_MOD, EXPR_BEG},
{"or", kOR, kOR, EXPR_BEG},
- {"and", kAND, kAND, EXPR_BEG},
+ {"next", kNEXT, kNEXT, EXPR_END},
{"when", kWHEN, kWHEN, EXPR_BEG},
{"redo", kREDO, kREDO, EXPR_END},
- {"class", kCLASS, kCLASS, EXPR_CLASS},
- {"next", kNEXT, kNEXT, EXPR_END},
+ {"and", kAND, kAND, EXPR_BEG},
{"begin", kBEGIN, kBEGIN, EXPR_BEG},
+ {"__LINE__", k__LINE__, k__LINE__, EXPR_END},
+ {"class", kCLASS, kCLASS, EXPR_CLASS},
+ {"__FILE__", k__FILE__, k__FILE__, EXPR_END},
{"END", klEND, klEND, EXPR_END},
{"BEGIN", klBEGIN, klBEGIN, EXPR_END},
- {"",}, {"",},
{"while", kWHILE, kWHILE_MOD, EXPR_BEG},
- {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",},
+ {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",},
+ {"",},
{"alias", kALIAS, kALIAS, EXPR_FNAME},
};
diff --git a/lib/date.rb b/lib/date.rb
index 24731d7c68..0f14d59ff5 100644
--- a/lib/date.rb
+++ b/lib/date.rb
@@ -1,8 +1,8 @@
#
# Date.rb -
# $Release Version: $
-# $Revision: 1.1.1.1 $
-# $Date: 1998/01/16 04:05:49 $
+# $Revision: 1.1.1.1.4.1 $
+# $Date: 1998/01/16 12:36:04 $
# by Yasuo OHBA(SHL Japan Inc. Technology Dept.)
#
# --
@@ -17,6 +17,20 @@
class Date
include Comparable
+ Weektag = [
+ "Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"
+ ]
+
+ Monthtag = [
+ "January","February","March","April", "May", "June","July",
+ "August", "September", "October", "November", "December"
+ ]
+
+ Monthtab = {
+ "jan"=>1, "feb"=>2, "mar"=>3, "apr"=>4, "may"=>5, "jun"=>6,
+ "jul"=>7, "aug"=>8, "sep"=>9, "oct"=>10, "nov"=>11, "dec"=>12
+ }
+
def initialize(y = 1, m = 1, d = 1)
if y.kind_of?(String) && y.size == 8
@year = y[0,4].to_i
@@ -24,8 +38,7 @@ class Date
@day = y[6,2].to_i
else
if m.kind_of?(String)
- ml = {"jan"=>1, "feb"=>2, "mar"=>3, "apr"=>4, "may"=>5, "jun"=>6, "jul"=>7, "aug"=>8, "sep"=>9, "oct"=>10, "nov"=>11, "dec"=>12}
- m = ml[m.downcase]
+ m = Monthtab[m.downcase]
if m.nil?
raise ArgumentError, "Wrong argument. (month)"
end
@@ -67,11 +80,14 @@ class Date
return (d % 7)
end
- Weektag = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
def name_of_week
return Weektag[self.day_of_week]
end
+ def name_of_month
+ return Monthtag[@month-1]
+ end
+
def +(o)
if o.kind_of?(Numeric)
d = Integer(self.period + o)
diff --git a/lib/delegate.rb b/lib/delegate.rb
index cb3c730787..571bf87510 100644
--- a/lib/delegate.rb
+++ b/lib/delegate.rb
@@ -7,16 +7,16 @@
#
# Usage:
# foo = Object.new
-# foo = SimpleDelegater.new(foo)
+# foo = SimpleDelegator.new(foo)
# foo.type # => Object
-class Delegater
+class Delegator
def initialize(obj)
preserved = ["id", "equal?", "__getobj__"]
for t in self.type.ancestors
preserved |= t.instance_methods
- break if t == Delegater
+ break if t == Delegator
end
for method in obj.methods
next if preserved.include? method
@@ -30,7 +30,7 @@ class Delegater
end
-class SimpleDelegater<Delegater
+class SimpleDelegator<Delegator
def initialize(obj)
super
@@ -45,3 +45,13 @@ class SimpleDelegater<Delegater
@obj = obj
end
end
+
+# backword compatibility ^_^;;;
+Delegater = Delegator
+SimpleDelegater = SimpleDelegator
+
+if __FILE__ == $0
+ foo = Object.new
+ foo = SimpleDelegator.new(foo)
+ p foo.type # => Object
+end
diff --git a/lib/final.rb b/lib/final.rb
index 566d1aae42..fc17dce289 100644
--- a/lib/final.rb
+++ b/lib/final.rb
@@ -15,26 +15,26 @@
#
module ObjectSpace
- Finalizer = {}
+ Finalizers = {}
def define_finalizer(obj, proc=lambda())
ObjectSpace.call_finalizer(obj)
- if assoc = Finalizer[obj.id]
+ if assoc = Finalizers[obj.id]
assoc.push(proc)
else
- Finalizer[obj.id] = [proc]
+ Finalizers[obj.id] = [proc]
end
end
def undefine_finalizer(obj)
- Finalizer.delete(obj.id)
+ Finalizers.delete(obj.id)
end
- module_function :define_finalizer, :remove_finalizer
+ module_function :define_finalizer, :undefine_finalizer
Generic_Finalizer = proc {|id|
- if Finalizer.key? id
- for proc in Finalizer[id]
+ if Finalizers.key? id
+ for proc in Finalizers[id]
proc.call(id)
end
- Finalizer.delete(id)
+ Finalizers.delete(id)
end
}
add_finalizer Generic_Finalizer
diff --git a/lib/parsedate.rb b/lib/parsedate.rb
index 1c1dda76bc..2ec54b0125 100644
--- a/lib/parsedate.rb
+++ b/lib/parsedate.rb
@@ -13,8 +13,8 @@ module ParseDate
if date.sub!(/\s+(\d+:\d+(:\d+)?)/, ' ')
time = $1
end
- if date =~ /19(\d\d)/
- year = Integer($1)
+ if date =~ /(19|20)(\d\d)/
+ year = Integer($2)
end
if date.sub!(/\s*(\d+)\s+(#{MONTHPAT})\S*\s+/i, ' ')
dayofmonth = $1.to_i
diff --git a/lib/tempfile.rb b/lib/tempfile.rb
index 66d96200b5..78b770c5a4 100644
--- a/lib/tempfile.rb
+++ b/lib/tempfile.rb
@@ -12,7 +12,7 @@
require 'delegate'
require 'final'
-class Tempfile < SimpleDelegater
+class Tempfile < SimpleDelegator
Max_try = 10
def initialize(basename, tmpdir = '/tmp')
@@ -70,3 +70,12 @@ class Tempfile < SimpleDelegater
end
end
end
+
+if __FILE__ == $0
+ f = Tempfile.new("foo")
+ f.print("foo\n")
+ f.close
+ f.open
+ p f.gets # => "foo\n"
+ f.close(true)
+end
diff --git a/lib/weakref.rb b/lib/weakref.rb
index 93b2c65ecd..18d3bbc9a3 100644
--- a/lib/weakref.rb
+++ b/lib/weakref.rb
@@ -10,7 +10,7 @@
require "delegate"
-class WeakRef<Delegater
+class WeakRef<Delegator
Exception :RefError
diff --git a/node.h b/node.h
index 832b8ca827..b5a837a091 100644
--- a/node.h
+++ b/node.h
@@ -119,15 +119,15 @@ typedef struct RNode {
union {
struct RNode *node;
ID id;
- int argc;
+ INT argc;
VALUE value;
} u2;
union {
struct RNode *node;
ID id;
- int state;
+ INT state;
struct global_entry *entry;
- int cnt;
+ INT cnt;
VALUE value;
} u3;
} NODE;
diff --git a/parse.y b/parse.y
index 99bbf8e1c4..1033f60e7a 100644
--- a/parse.y
+++ b/parse.y
@@ -158,6 +158,8 @@ static void top_local_setup();
kDEFINED
klBEGIN
klEND
+ k__LINE__
+ k__FILE__
%token <id> IDENTIFIER FID GVAR IVAR CONSTANT
%token <val> INTEGER FLOAT STRING XSTRING REGEXP
@@ -1232,6 +1234,8 @@ variable : IDENTIFIER
| kSELF {$$ = kSELF;}
| kTRUE {$$ = kTRUE;}
| kFALSE {$$ = kFALSE;}
+ | k__FILE__ {$$ = k__FILE__;}
+ | k__LINE__ {$$ = k__LINE__;}
var_ref : variable
{
@@ -3222,6 +3226,12 @@ gettable(id)
else if (id == kFALSE) {
return NEW_FALSE();
}
+ else if (id == k__FILE__) {
+ return NEW_STR(str_new2(sourcefile));
+ }
+ else if (id == k__LINE__) {
+ return NEW_LIT(INT2FIX(sourceline));
+ }
else if (is_local_id(id)) {
if (local_id(id)) return NEW_LVAR(id);
if (dyna_var_defined(id)) return NEW_DVAR(id);
@@ -3260,6 +3270,12 @@ assignable(id, val)
else if (id == kFALSE) {
yyerror("Can't assign to false");
}
+ else if (id == k__FILE__) {
+ yyerror("Can't assign to __FILE__");
+ }
+ else if (id == k__LINE__) {
+ yyerror("Can't assign to __LINE__");
+ }
else if (is_local_id(id)) {
if (local_id(id) || !dyna_in_block()) {
lhs = NEW_LASGN(id, val);
diff --git a/rubytest.rb b/rubytest.rb
index f0e4bf8c8e..4830c9a261 100644
--- a/rubytest.rb
+++ b/rubytest.rb
@@ -1,3 +1,4 @@
+#! ./miniruby
require 'rbconfig'
include Config
diff --git a/sample/fib.scm b/sample/fib.scm
index 8eba75bb9e..5c2b86e656 100644
--- a/sample/fib.scm
+++ b/sample/fib.scm
@@ -3,4 +3,6 @@
n
(+ (fib (- n 2)) (fib (- n 1)))))
-(fib 20)
+(display (fib 20))
+(newline)
+
diff --git a/sample/ruby-mode.el b/sample/ruby-mode.el
index a09205e859..d31b2d196e 100644
--- a/sample/ruby-mode.el
+++ b/sample/ruby-mode.el
@@ -84,7 +84,7 @@
(modify-syntax-entry ?\` "\"" ruby-mode-syntax-table)
(modify-syntax-entry ?# "<" ruby-mode-syntax-table)
(modify-syntax-entry ?\n ">" ruby-mode-syntax-table)
- (modify-syntax-entry ?\\ "'" ruby-mode-syntax-table)
+ (modify-syntax-entry ?\\ "\\" ruby-mode-syntax-table)
(modify-syntax-entry ?$ "/" ruby-mode-syntax-table)
(modify-syntax-entry ?? "_" ruby-mode-syntax-table)
(modify-syntax-entry ?_ "_" ruby-mode-syntax-table)
@@ -640,7 +640,7 @@ An end of a defun is found by moving forward from the beginning of one."
'("^\\s *def[ \t]+[^ \t(]*"
0 font-lock-function-name-face t))
"*Additional expressions to highlight in ruby mode.")
- (if (and (>= (string-to-int emacs-version) 20)
+ (if (and (>= (string-to-int emacs-version) 19)
(not (featurep 'xemacs)))
(add-hook
'ruby-mode-hook
@@ -650,5 +650,4 @@ An end of a defun is found by moving forward from the beginning of one."
'((ruby-font-lock-keywords) nil nil ((?\_ . "w"))))))
(add-hook 'ruby-mode-hook
(lambda ()
- (setq font-lock-keywords ruby-font-lock-keywords)
- (font-lock-mode 1))))))
+ (setq font-lock-keywords ruby-font-lock-keywords))))))