1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@527 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 1999-09-16 09:40:33 +00:00
parent 69a3aaf154
commit 9e3d9a2a00
19 changed files with 397 additions and 163 deletions

View file

@ -1,3 +1,56 @@
Thu Sep 16 18:40:08 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* stable version 1.4.1 released.
Thu Sep 16 11:33:22 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
* string.c (rb_str_match): should return false.
Wed Sep 15 22:46:37 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* re.c (rb_reg_s_quote): should quote `-' too.
Tue Sep 14 15:23:22 1999 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
* parse.y (yylex): no need to ignore `\r' here.
* parse.y (nextc): strip `\r' from text.
* parse.y (nextc): support `__END__\r\n' type terminator.
Mon Sep 13 10:49:19 1999 WATANABE Hirofumi <watanabe@ase.ptg.sony.co.jp>
* eval.c (rb_eval): needless RTEST(ruby_verbose) removed.
Wed Sep 8 11:37:38 1999 Tadayoshi Funaba <tadf@kt.rim.or.jp>
* time.c (make_time_t): bit more strict comparison.
Tue Sep 7 00:50:56 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* range.c (range_each): use rb_str_upto() for strings.
* string.c (rb_str_upto): set upper limit by comparing curr <= end.
* range.c (range_each): should check equality to handle magic
increment.
Mon Sep 6 22:43:33 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* eval.c (rb_eval): break/next/redo available within -n/-p loop.
Fri Sep 3 11:14:31 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* compar.c (cmp_equal): should not raise exception; protect by
rb_rescue().
Thu Sep 2 05:23:05 1999 WATANABE Hirofumi <eban@os.rim.or.jp>
* file.c (rb_file_s_expand_path): use dirsep, instead of character
literal '/'.
* file.c (rb_file_s_expand_path): reduce multiple dirsep at the top.
Wed Sep 1 00:28:27 1999 Yukihiro Matsumoto <matz@netlab.co.jp> Wed Sep 1 00:28:27 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* eval.c (rb_call): call rb_undefined() if a method appears not to * eval.c (rb_call): call rb_undefined() if a method appears not to

View file

@ -88,6 +88,7 @@ lib/English.rb
lib/Env.rb lib/Env.rb
lib/README lib/README
lib/base64.rb lib/base64.rb
lib/cgi.rb
lib/cgi-lib.rb lib/cgi-lib.rb
lib/complex.rb lib/complex.rb
lib/date.rb lib/date.rb
@ -104,6 +105,18 @@ lib/ftools.rb
lib/getopts.rb lib/getopts.rb
lib/getoptlong.rb lib/getoptlong.rb
lib/importenv.rb lib/importenv.rb
lib/irb/bind.rb
lib/irb/completion.rb
lib/irb/frame.rb
lib/irb/input-method.rb
lib/irb/loader.rb
lib/irb/main.rb
lib/irb/multi-irb.rb
lib/irb/ruby-lex.rb
lib/irb/ruby-token.rb
lib/irb/slex.rb
lib/irb/version.rb
lib/irb/xmp.rb
lib/jcode.rb lib/jcode.rb
lib/mailread.rb lib/mailread.rb
lib/mathn.rb lib/mathn.rb
@ -111,6 +124,9 @@ lib/matrix.rb
lib/mkmf.rb lib/mkmf.rb
lib/monitor.rb lib/monitor.rb
lib/mutex_m.rb lib/mutex_m.rb
lib/net/pop.rb
lib/net/session.rb
lib/net/smtp.rb
lib/observer.rb lib/observer.rb
lib/open3.rb lib/open3.rb
lib/ostruct.rb lib/ostruct.rb

View file

@ -17,16 +17,34 @@ VALUE rb_mComparable;
static ID cmp; static ID cmp;
static VALUE static VALUE
cmp_eq(x, y) cmp_eq(a)
VALUE x, y; VALUE *a;
{ {
VALUE c = rb_funcall(x, cmp, 1, y); VALUE c = rb_funcall(a[0], cmp, 1, a[1]);
int t = NUM2INT(c); int t = NUM2INT(c);
if (t == 0) return Qtrue; if (t == 0) return Qtrue;
return Qfalse; return Qfalse;
} }
static VALUE
cmp_failed()
{
return Qfalse;
}
static VALUE
cmp_equal(x, y)
VALUE x, y;
{
VALUE a[2];
if (x == y) return Qtrue;
a[0] = x; a[1] = y;
return rb_rescue(cmp_eq, (VALUE)a, cmp_failed, 0);
}
static VALUE static VALUE
cmp_gt(x, y) cmp_gt(x, y)
VALUE x, y; VALUE x, y;
@ -89,7 +107,7 @@ void
Init_Comparable() Init_Comparable()
{ {
rb_mComparable = rb_define_module("Comparable"); rb_mComparable = rb_define_module("Comparable");
rb_define_method(rb_mComparable, "==", cmp_eq, 1); rb_define_method(rb_mComparable, "==", cmp_equal, 1);
rb_define_method(rb_mComparable, ">", cmp_gt, 1); rb_define_method(rb_mComparable, ">", cmp_gt, 1);
rb_define_method(rb_mComparable, ">=", cmp_ge, 1); rb_define_method(rb_mComparable, ">=", cmp_ge, 1);
rb_define_method(rb_mComparable, "<", cmp_lt, 1); rb_define_method(rb_mComparable, "<", cmp_lt, 1);

34
eval.c
View file

@ -169,7 +169,7 @@ rb_get_method_body(klassp, idp, noexp)
struct cache_entry *ent; struct cache_entry *ent;
if ((body = search_method(klass, id, &origin)) == 0 || !body->nd_body) { if ((body = search_method(klass, id, &origin)) == 0 || !body->nd_body) {
/* store in cache */ /* store empty info in cache */
ent = cache + EXPR1(klass, id); ent = cache + EXPR1(klass, id);
ent->klass = klass; ent->klass = klass;
ent->origin = klass; ent->origin = klass;
@ -1795,11 +1795,31 @@ rb_eval(self, node)
} }
break; break;
/* nodes for speed-up(top-level loop for -n/-p) */ /* node for speed-up(top-level loop for -n/-p) */
case NODE_OPT_N: case NODE_OPT_N:
while (!NIL_P(rb_gets())) { PUSH_TAG(PROT_NONE);
rb_eval(self, node->nd_body); switch (state = EXEC_TAG()) {
case 0:
opt_n_next:
while (!NIL_P(rb_gets())) {
opt_n_redo:
rb_eval(self, node->nd_body);
}
break;
case TAG_REDO:
state = 0;
goto opt_n_redo;
case TAG_NEXT:
state = 0;
goto opt_n_next;
case TAG_BREAK:
state = 0;
default:
break;
} }
POP_TAG();
if (state) JUMP_TAG(state);
RETURN(Qnil); RETURN(Qnil);
case NODE_SELF: case NODE_SELF:
@ -2371,10 +2391,8 @@ rb_eval(self, node)
/* check for static scope constants */ /* check for static scope constants */
if (RTEST(ruby_verbose) && if (RTEST(ruby_verbose) &&
ev_const_defined((NODE*)ruby_frame->cbase, node->nd_vid)) { ev_const_defined((NODE*)ruby_frame->cbase, node->nd_vid)) {
if (RTEST(ruby_verbose)) { rb_warn("already initialized constant %s",
rb_warning("already initialized constant %s", rb_id2name(node->nd_vid));
rb_id2name(node->nd_vid));
}
} }
rb_const_set(ruby_class, node->nd_vid, result); rb_const_set(ruby_class, node->nd_vid, result);
break; break;

9
file.c
View file

@ -1107,7 +1107,7 @@ rb_file_s_expand_path(argc, argv)
} }
} }
#endif #endif
else if (s[0] != '/') { else if (!isdirsep(*s)) {
if (argc == 2) { if (argc == 2) {
dname = rb_file_s_expand_path(1, &dname); dname = rb_file_s_expand_path(1, &dname);
strcpy(buf, RSTRING(dname)->ptr); strcpy(buf, RSTRING(dname)->ptr);
@ -1122,6 +1122,13 @@ rb_file_s_expand_path(argc, argv)
p = &buf[strlen(buf)]; p = &buf[strlen(buf)];
while (p > buf && *(p - 1) == '/') p--; while (p > buf && *(p - 1) == '/') p--;
} }
else if (isdirsep(*s)) {
while (*s && isdirsep(*s)) {
*p++ = '/';
s++;
}
if (p > buf && *s) p--;
}
*p = '/'; *p = '/';
for ( ; *s; s++) { for ( ; *s; s++) {

View file

@ -1,10 +1,12 @@
# date2.rb: Written by Tadayoshi Funaba 1998, 1999 # date2.rb: Written by Tadayoshi Funaba 1998, 1999
# $Id: date2.rb,v 1.15 1999/08/29 15:23:52 tadf Exp $ # $Id: date2.rb,v 1.17 1999/09/15 05:34:07 tadf Exp $
class Date class Date
include Comparable include Comparable
IDENT = 2
MONTHNAMES = [ nil, 'January', 'February', 'March', MONTHNAMES = [ nil, 'January', 'February', 'March',
'April', 'May', 'June', 'July', 'August', 'April', 'May', 'June', 'July', 'August',
'September', 'October', 'November', 'December' ] 'September', 'October', 'November', 'December' ]
@ -12,8 +14,10 @@ class Date
DAYNAMES = [ 'Sunday', 'Monday', 'Tuesday', DAYNAMES = [ 'Sunday', 'Monday', 'Tuesday',
'Wednesday', 'Thursday', 'Friday', 'Saturday' ] 'Wednesday', 'Thursday', 'Friday', 'Saturday' ]
ITALY = 2299161 # Oct 15, 1582 ITALY = 2299161 # 1582-10-15
ENGLAND = 2361222 # Sept 14, 1752 ENGLAND = 2361222 # 1752-09-14
JULIAN = false
GREGORIAN = true
class << self class << self
@ -26,7 +30,7 @@ class Date
def ns? (jd, sg) not os?(jd, sg) end def ns? (jd, sg) not os?(jd, sg) end
def civil_to_jd(y, m, d, sg=true) def civil_to_jd(y, m, d, sg=GREGORIAN)
if m <= 2 if m <= 2
y -= 1 y -= 1
m += 12 m += 12
@ -42,7 +46,7 @@ class Date
jd jd
end end
def jd_to_civil(jd, sg=true) def jd_to_civil(jd, sg=GREGORIAN)
if os?(jd, sg) if os?(jd, sg)
a = jd a = jd
else else
@ -64,16 +68,44 @@ class Date
return y, m, dom return y, m, dom
end end
def ordinal_to_jd(y, d, sg=true) def ordinal_to_jd(y, d, sg=GREGORIAN)
civil_to_jd(y, 1, d, sg) civil_to_jd(y, 1, d, sg)
end end
def jd_to_ordinal(jd, sg=true) def jd_to_ordinal(jd, sg=GREGORIAN)
y = jd_to_civil(jd, sg)[0] y = jd_to_civil(jd, sg)[0]
doy = jd - civil_to_jd(y - 1, 12, 31, ns?(jd, sg)) doy = jd - civil_to_jd(y - 1, 12, 31, ns?(jd, sg))
return y, doy return y, doy
end end
def jd_to_commercial(jd, sg=GREGORIAN)
ns = ns?(jd, sg)
a = jd_to_civil(jd - 3, ns)[0]
y = if jd >= commercial_to_jd(a + 1, 1, 1, ns) then a + 1 else a end
w = 1 + (jd - commercial_to_jd(y, 1, 1, ns)) / 7
d = (jd + 1) % 7
if d.zero? then d = 7 end
return y, w, d
end
def commercial_to_jd(y, w, d, ns=GREGORIAN)
jd = civil_to_jd(y, 1, 4, ns)
(jd - (((jd - 1) + 1) % 7)) +
7 * (w - 1) +
(d - 1)
end
def clfloor(x, y=1)
q = (x / y).to_i
z = (q * y)
q -= 1 if (y > 0 and x < z) or (y < 0 and x > z)
r = x - q * y
return q, r
end
def rjd_to_jd(rjd) clfloor(rjd + 0.5) end
def jd_to_rjd(jd, fr) jd + fr - 0.5 end
def mjd_to_jd(mjd) mjd + 2400000.5 end def mjd_to_jd(mjd) mjd + 2400000.5 end
def jd_to_mjd(jd) jd - 2400000.5 end def jd_to_mjd(jd) jd - 2400000.5 end
def tjd_to_jd(tjd) tjd + 2440000.5 end def tjd_to_jd(tjd) tjd + 2440000.5 end
@ -84,25 +116,25 @@ class Date
alias_method :leap?, :gregorian_leap? alias_method :leap?, :gregorian_leap?
def new1(jd=0, sg=ITALY) new(jd, sg) end
def exist3? (y, m, d, sg=ITALY) def exist3? (y, m, d, sg=ITALY)
if m < 0 if m < 0
m += 13 m += 13
end end
if d < 0 if d < 0
ljd = nil ny, nm = Date.clfloor(y * 12 + m, 12)
31.downto 1 do |ld| nm, = Date.clfloor(m + 1, 1)
break if ljd = exist3?(y, m, ld, sg) la = nil
31.downto 1 do |z|
break if la = exist3?(y, m, z, sg)
end end
x = y * 12 + m ns = ns?(la, sg)
ny = x / 12 d = jd_to_civil(civil_to_jd(ny, nm, 1, ns) + d, ns)[-1]
nm = x % 12 + 1
d = jd_to_civil(civil_to_jd(ny, nm, 1, ns?(ljd, sg)) + d,
ns?(ljd, sg))[-1]
end end
jd = civil_to_jd(y, m, d, sg) jd = civil_to_jd(y, m, d, sg)
if [y, m, d] == jd_to_civil(jd, sg) return unless [y, m, d] == jd_to_civil(jd, sg)
jd jd
end
end end
alias_method :exist?, :exist3? alias_method :exist?, :exist3?
@ -116,18 +148,17 @@ class Date
def exist2? (y, d, sg=ITALY) def exist2? (y, d, sg=ITALY)
if d < 0 if d < 0
ljd = nil
366.downto 1 do |ld|
break if ljd = exist2?(y, ld, sg)
end
ny = y + 1 ny = y + 1
d = jd_to_ordinal(ordinal_to_jd(ny, 1, ns?(ljd, sg)) + d, la = nil
ns?(ljd, sg))[-1] 366.downto 1 do |z|
break if la = exist2?(y, z, sg)
end
ns = ns?(la, sg)
d = jd_to_ordinal(ordinal_to_jd(ny, 1, ns) + d, ns)[-1]
end end
jd = ordinal_to_jd(y, d, sg) jd = ordinal_to_jd(y, d, sg)
if [y, d] == jd_to_ordinal(jd, sg) return unless [y, d] == jd_to_ordinal(jd, sg)
jd jd
end
end end
def new2(y=-4712, d=1, sg=ITALY) def new2(y=-4712, d=1, sg=ITALY)
@ -137,130 +168,179 @@ class Date
new(jd, sg) new(jd, sg)
end end
def existw? (y, w, d, sg=ITALY)
if d < 0
d += 8
end
if w < 0
w = jd_to_commercial(commercial_to_jd(y + 1, 1, 1) + w * 7)[1]
end
jd = commercial_to_jd(y, w, d)
return unless ns?(jd, sg)
return unless [y, w, d] == jd_to_commercial(jd)
jd
end
def neww(y=1582, w=41, d=5, sg=ITALY)
unless jd = existw?(y, w, d, sg)
fail ArgumentError, 'invalid date'
end
new(jd, sg)
end
def today(sg=ITALY) def today(sg=ITALY)
new(civil_to_jd(*(Time.now.to_a[3..5].reverse << sg)), sg) new(civil_to_jd(*(Time.now.to_a[3..5].reverse << sg)), sg)
end end
def once(*ids)
for id in ids
module_eval <<-"end;"
alias_method :__#{id}__, #{id}
def #{id.id2name}(*args, &block)
def self.#{id.id2name}(*args, &block); @__#{id}__ end
@__#{id}__ = __#{id}__(*args, &block)
end
end;
end
end
private :once
end end
def initialize(jd=0, sg=ITALY) @jd, @sg = jd, sg end def initialize(rjd=0, sg=ITALY) @rjd, @sg = rjd, sg end
def jd() @jd end def rjd() @rjd end
def rmjd() Date.jd_to_mjd(@rjd) end
def rtjd() Date.jd_to_tjd(@rjd) end
def mjd once :rmjd, :rtjd
def self.mjd() @mjd end
@mjd = Date.jd_to_mjd(@jd)
end
def tjd def jd() Date.rjd_to_jd(@rjd)[0] end
def self.tjd() @tjd end def fr1() Date.rjd_to_jd(@rjd)[1] end
@tjd = Date.jd_to_tjd(@jd) def mjd() Date.jd_to_mjd(jd) end
end def tjd() Date.jd_to_tjd(jd) end
def civil once :jd, :fr1, :mjd, :tjd
def self.year() @year end
def self.mon() @mon end
def self.month() @mon end
def self.mday() @mday end
def self.day() @mday end
@year, @mon, @mday = Date.jd_to_civil(@jd, @sg)
end
private :civil def civil() Date.jd_to_civil(jd, @sg) end
def ordinal() Date.jd_to_ordinal(jd, @sg) end
def commercial() Date.jd_to_commercial(jd, @sg) end
def year once :civil, :ordinal, :commercial
civil
@year
end
def yday def year() civil[0] end
def self.yday() @yday end def yday() ordinal[1] end
@yday = Date.jd_to_ordinal(@jd, @sg)[-1] def mon() civil[1] end
@yday
end
def mon
civil
@mon
end
alias_method :month, :mon alias_method :month, :mon
once :year, :yday, :mon, :month
def mday def mday() civil[2] end
civil
@mday
end
alias_method :day, :mday alias_method :day, :mday
once :mday, :day
def wday def cwyear() commercial[0] end
def self.wday() @wday end def cweek() commercial[1] end
@wday = (@jd + 1) % 7 def cwday() commercial[2] end
end
def os? () Date.os?(@jd, @sg) end once :cwyear, :cweek, :cwday
def ns? () Date.ns?(@jd, @sg) end
def wday() (jd + 1) % 7 end
once :wday
def os? () Date.os?(jd, @sg) end
def ns? () Date.ns?(jd, @sg) end
once :os?, :ns?
def leap? def leap?
def self.leap?() @leap_p end Date.jd_to_civil(Date.civil_to_jd(year, 3, 1, ns?) - 1,
@leap_p = Date.jd_to_civil(Date.civil_to_jd(year, 3, 1, ns?) - 1, ns?)[-1] == 29
ns?)[-1] == 29
end end
def + (other) once :leap?
case other
when Numeric; return Date.new(@jd + other, @sg) def sg() @sg end
def newsg(sg=Date::ITALY) Date.new(@rjd, sg) end
def italy() newsg(Date::ITALY) end
def england() newsg(Date::ENGLAND) end
def julian() newsg(Date::JULIAN) end
def gregorian() newsg(Date::GREGORIAN) end
def + (n)
case n
when Numeric; return Date.new(@rjd + n, @sg)
end end
fail TypeError, 'expected numeric' fail TypeError, 'expected numeric'
end end
def - (other) def - (x)
case other case x
when Numeric; return Date.new(@jd - other, @sg) when Numeric; return Date.new(@rjd - x, @sg)
when Date; return @jd - other.jd when Date; return @rjd - x.rjd
end end
fail TypeError, 'expected numeric or date' fail TypeError, 'expected numeric or date'
end end
def <=> (other) def <=> (other)
case other case other
when Numeric; return @jd <=> other when Numeric; return @rjd <=> other
when Date; return @jd <=> other.jd when Date; return @rjd <=> other.rjd
end end
fail TypeError, 'expected numeric or date' fail TypeError, 'expected numeric or date'
end end
def downto(min) def === (other)
@jd.downto(min.jd) do |jd| case other
yield Date.new(jd, @sg) when Numeric; return jd == other
when Date; return jd == other.jd
end end
self fail TypeError, 'expected numeric or date'
end end
def upto(max) def >> (n)
@jd.upto(max.jd) do |jd| y, m = Date.clfloor(year * 12 + (mon - 1) + n, 12)
yield Date.new(jd, @sg) m, = Date.clfloor(m + 1, 1)
end d = mday
self d -= 1 until jd2 = Date.exist3?(y, m, d, ns?)
self + (jd2 - jd)
end end
def << (n) self >> -n end
def step(limit, step) def step(limit, step)
@jd.step(limit.jd, step) do |jd| rjd = @rjd
yield Date.new(jd, @sg) if (step > 0)
while rjd <= limit.rjd
yield Date.new(rjd, @sg)
rjd += step
end
else
while rjd >= limit.rjd
yield Date.new(rjd, @sg)
rjd += step
end
end end
self self
end end
def upto(max, &block) step(max, +1, &block) end
def downto(min, &block) step(min, -1, &block) end
def succ() self + 1 end def succ() self + 1 end
alias_method :next, :succ alias_method :next, :succ
def eql? (other) self == other end def eql? (other) Date === other and self == other end
def hash() @jd end def hash() Date.clfloor(@rjd)[0] end
def inspect() format('#<Date: %s,%s>', @jd, @sg) end def inspect() format('#<Date: %s,%s>', @rjd, @sg) end
def to_s() format('%.4d-%02d-%02d', year, mon, mday) end def to_s() format('%.4d-%02d-%02d', year, mon, mday) end
def _dump(limit) Marshal.dump([@jd, @sg], -1) end def _dump(limit) Marshal.dump([@rjd, @sg], -1) end
def Date._load(str) Date.new(*Marshal.load(str)) end def Date._load(str) Date.new(*Marshal.load(str)) end
end end

View file

@ -67,7 +67,6 @@ module ParseDate
mon = MONTHS[$2.downcase] mon = MONTHS[$2.downcase]
year = $3.to_i year = $3.to_i
end end
p date
if date.sub!(/\d{4}/i, ' ') if date.sub!(/\d{4}/i, ' ')
year = $&.to_i year = $&.to_i
elsif date.sub!(/\d\d/i, ' ') elsif date.sub!(/\d\d/i, ' ')

View file

@ -1,11 +1,11 @@
=begin =begin
$Date: 1999/08/10 05:20:21 $ $Date: 1999/09/14 23:09:05 $
== SIMPLE TELNET CLIANT LIBRARY == SIMPLE TELNET CLIANT LIBRARY
telnet.rb telnet.rb
Version 0.232 Version 0.30
Wakou Aoyama <wakou@fsinet.or.jp> Wakou Aoyama <wakou@fsinet.or.jp>
@ -34,7 +34,7 @@ the network or the host is very heavy, the value is enlarged.
=== STATUS OUTPUT === STATUS OUTPUT
host = Telnet.new({"Host" => "localhost"){|c| print c } host = Telnet.new({"Host" => "localhost"}){|c| print c }
connection status output. connection status output.
@ -110,6 +110,13 @@ of cource, set sync=true or flush is necessary.
"Prompt" => /[$%#>] \z/n, "Prompt" => /[$%#>] \z/n,
"Timeout" => 10}) "Timeout" => 10})
if no password prompt.
host.login("username")
host.login({"Name" => "username",
"Prompt" => /[$%#>] \z/n,
"Timeout" => 10})
==== REALTIME OUTPUT ==== REALTIME OUTPUT
@ -147,13 +154,28 @@ of cource, set sync=true or flush is necessary.
== HISTORY == HISTORY
=== Version 0.30
1999/09/14 23:09:05
- change prompt check order.
not IO::select([@sock], nil, nil, waittime) and prompt === line
--> prompt === line and not IO::select([@sock], nil, nil, waittime)
=== Version 0.24
1999/09/13 22:28:33
- Telnet#login
if ommit password, then not require password prompt.
=== Version 0.232 === Version 0.232
1999/08/10 05:20:21 1999/08/10 05:20:21
- STATUS OUTPUT sample code typo. thanks to Tadayoshi Funaba <tadf@kt.rim.or.jp> - STATUS OUTPUT sample code typo. thanks to Tadayoshi Funaba <tadf@kt.rim.or.jp>
host = Telnet.new({"Hosh" => "localhost"){|c| print c } host = Telnet.new({"Hosh" => "localhost"){|c| print c }
host = Telnet.new({"Host" => "localhost"){|c| print c } --> host = Telnet.new({"Host" => "localhost"){|c| print c }
=== Version 0.231 === Version 0.231
@ -370,8 +392,8 @@ class Telnet < SimpleDelegator
EOL = CR + LF EOL = CR + LF
v = $-v v = $-v
$-v = false $-v = false
VERSION = "0.232" VERSION = "0.30"
RELEASE_DATE = "$Date: 1999/08/10 05:20:21 $" RELEASE_DATE = "$Date: 1999/09/14 23:09:05 $"
$-v = v $-v = v
def initialize(options) def initialize(options)
@ -540,7 +562,7 @@ $-v = v
line = '' line = ''
buf = '' buf = ''
until(not IO::select([@sock], nil, nil, waittime) and prompt === line) until(prompt === line and not IO::select([@sock], nil, nil, waittime))
unless IO::select([@sock], nil, nil, time_out) unless IO::select([@sock], nil, nil, time_out)
raise TimeOut, "timed-out; wait for the next data" raise TimeOut, "timed-out; wait for the next data"
end end
@ -611,7 +633,7 @@ $-v = v
end end
end end
def login(options, password = '') def login(options, password = nil)
if options.kind_of?(Hash) if options.kind_of?(Hash)
username = options["Name"] username = options["Name"]
password = options["Password"] password = options["Password"]
@ -621,14 +643,22 @@ $-v = v
if iterator? if iterator?
line = waitfor(/login[: ]*\z/n){|c| yield c } line = waitfor(/login[: ]*\z/n){|c| yield c }
line.concat( cmd({"String" => username, if password
"Match" => /Password[: ]*\z/n}){|c| yield c } ) line.concat( cmd({"String" => username,
line.concat( cmd(password){|c| yield c } ) "Match" => /Password[: ]*\z/n}){|c| yield c } )
line.concat( cmd(password){|c| yield c } )
else
line.concat( cmd(username){|c| yield c } )
end
else else
line = waitfor(/login[: ]*\z/n) line = waitfor(/login[: ]*\z/n)
line.concat( cmd({"String" => username, if password
"Match" => /Password[: ]*\z/n}) ) line.concat( cmd({"String" => username,
line.concat( cmd(password) ) "Match" => /Password[: ]*\z/n}) )
line.concat( cmd(password) )
else
line.concat( cmd(username) )
end
end end
line line
end end

View file

@ -376,7 +376,6 @@ num_eql(x, y)
return rb_equal(x, y); return rb_equal(x, y);
} }
static VALUE static VALUE
num_equal(x, y) num_equal(x, y)
VALUE x, y; VALUE x, y;

18
parse.y
View file

@ -1840,7 +1840,8 @@ nextc()
ruby_sourceline++; ruby_sourceline++;
lex_pbeg = lex_p = RSTRING(v)->ptr; lex_pbeg = lex_p = RSTRING(v)->ptr;
lex_pend = lex_p + RSTRING(v)->len; lex_pend = lex_p + RSTRING(v)->len;
if (strncmp(lex_pbeg, "__END__", 7) == 0 && lex_pbeg[7] == '\n') { if (strncmp(lex_pbeg, "__END__", 7) == 0 &&
(RSTRING(v)->len == 7 || lex_pbeg[7] == '\n' || lex_pbeg[7] == '\r')) {
ruby__end__seen = 1; ruby__end__seen = 1;
lex_lastline = 0; lex_lastline = 0;
return -1; return -1;
@ -1853,6 +1854,10 @@ nextc()
} }
} }
c = (unsigned char)*lex_p++; c = (unsigned char)*lex_p++;
if (c == '\r' && lex_p <= lex_pend && *lex_p == '\n') {
lex_p++;
c = '\n';
}
return c; return c;
} }
@ -2916,7 +2921,7 @@ yylex()
case ':': case ':':
c = nextc(); c = nextc();
if (c == ':') { if (c == ':') {
if (lex_state == EXPR_BEG) { if (lex_state == EXPR_BEG || lex_state == EXPR_MID) {
lex_state = EXPR_BEG; lex_state = EXPR_BEG;
return tCOLON3; return tCOLON3;
} }
@ -3019,10 +3024,6 @@ yylex()
case '\\': case '\\':
c = nextc(); c = nextc();
if (c == '\r') {
c = nextc();
if (c != '\n') pushback(c);
}
if (c == '\n') { if (c == '\n') {
space_seen = 1; space_seen = 1;
goto retry; /* skip \\n */ goto retry; /* skip \\n */
@ -3230,7 +3231,8 @@ yylex()
} }
else if (toklast() == '!' || toklast() == '?') { else if (toklast() == '!' || toklast() == '?') {
result = tFID; result = tFID;
} else { }
else {
result = tIDENTIFIER; result = tIDENTIFIER;
if (lex_state == EXPR_FNAME || lex_state == EXPR_DOT) { if (lex_state == EXPR_FNAME || lex_state == EXPR_DOT) {
if ((c = nextc()) == '=' && !peek('=')) { if ((c = nextc()) == '=' && !peek('=')) {
@ -3243,7 +3245,7 @@ yylex()
} }
if (lex_state == EXPR_BEG || if (lex_state == EXPR_BEG ||
lex_state == EXPR_DOT || lex_state == EXPR_DOT ||
lex_state == EXPR_ARG){ lex_state == EXPR_ARG) {
lex_state = EXPR_ARG; lex_state = EXPR_ARG;
} }
else { else {

2
prec.c
View file

@ -1,6 +1,6 @@
/************************************************ /************************************************
ruby.h - prec.c -
$Author$ $Author$
$Date$ $Date$

View file

@ -92,10 +92,11 @@ rb_f_srand(argc, argv, obj)
static int saved_seed; static int saved_seed;
if (rb_scan_args(argc, argv, "01", &seed) == 0) { if (rb_scan_args(argc, argv, "01", &seed) == 0) {
static int n = 0;
struct timeval tv; struct timeval tv;
gettimeofday(&tv, 0); gettimeofday(&tv, 0);
seed = tv.tv_sec ^ tv.tv_usec ^ getpid(); seed = tv.tv_sec ^ tv.tv_usec ^ getpid() ^ n++;
} }
else { else {
seed = NUM2UINT(seed); seed = NUM2UINT(seed);

24
range.c
View file

@ -134,14 +134,28 @@ range_each(range)
rb_yield(INT2NUM(i)); rb_yield(INT2NUM(i));
} }
} }
else { /* generic each */ else if (TYPE(b) == T_STRING) {
rb_str_upto(b, e, EXCL(range));
}
else { /* generic each */
VALUE v = b; VALUE v = b;
ID le = EXCL(range)?'<':rb_intern("<=");
ID succ = rb_intern("succ"); ID succ = rb_intern("succ");
while (rb_funcall(v, le, 1, e)) { if (EXCL(range)) {
rb_yield(v); while (RTEST(rb_funcall(v, '<', 1, e))) {
v = rb_funcall(v, succ, 0, 0); if (rb_equal(v, e)) break;
rb_yield(v);
v = rb_funcall(v, succ, 0, 0);
}
}
else {
ID le = rb_intern("<=");
while (RTEST(rb_funcall(v, le, 1, e))) {
rb_yield(v);
if (rb_equal(v, e)) break;
v = rb_funcall(v, succ, 0, 0);
}
} }
} }

2
re.c
View file

@ -964,7 +964,7 @@ rb_reg_s_quote(argc, argv)
if (*s == '[' || *s == ']' if (*s == '[' || *s == ']'
|| *s == '{' || *s == '}' || *s == '{' || *s == '}'
|| *s == '(' || *s == ')' || *s == '(' || *s == ')'
|| *s == '|' || *s == '|' || *s == '-'
|| *s == '*' || *s == '.' || *s == '\\' || *s == '*' || *s == '.' || *s == '\\'
|| *s == '?' || *s == '+' || *s == '?' || *s == '+'
|| *s == '^' || *s == '$') { || *s == '^' || *s == '$') {

View file

@ -22,8 +22,8 @@ from.rb scan mail spool
fullpath.rb convert ls -lR to fullpath format fullpath.rb convert ls -lR to fullpath format
getopts.test test fot getopt.rb getopts.test test fot getopt.rb
goodfriday.rb print various christian calendar event. goodfriday.rb print various christian calendar event.
inf-ruby.el program to run ruby under emacs
io.rb io test io.rb io test
irb.rb interactive ruby
less.rb front end for less less.rb front end for less
list.rb stupid object sample list.rb stupid object sample
list2.rb stupid object sample list2.rb stupid object sample
@ -38,15 +38,11 @@ occur.rb count word occurrence (Ruby)
occur2.rb count word occurrence - another style occur2.rb count word occurrence - another style
philos.rb famous dining philosophers philos.rb famous dining philosophers
pi.rb calculate PI pi.rb calculate PI
rbc.rb interactive ruby, to be removed by irb
rcs.awk random character stereogram (AWK) rcs.awk random character stereogram (AWK)
rcs.rb random character stereogram (Ruby) rcs.rb random character stereogram (Ruby)
rcs.dat data for random character stereogram rcs.dat data for random character stereogram
rd2html.rb rd (Ruby Document) to HTML translator rd2html.rb rd (Ruby Document) to HTML translator
regx.rb regular expression tester regx.rb regular expression tester
ruby-mode.el ruby mode for emacs
rubydb2x.el ruby debugger support for emacs 19.2x or before
rubydb3x.el ruby debugger support for emacs 19.3x or later
sieve.rb sieve of Eratosthenes sieve.rb sieve of Eratosthenes
svr.rb socket server svr.rb socket server
test.rb test suite used by `make test' test.rb test suite used by `make test'

View file

@ -1,7 +1,7 @@
#! /usr/local/bin/ruby #! /usr/local/bin/ruby
# cal.rb: Written by Tadayoshi Funaba 1998, 1999 # cal.rb: Written by Tadayoshi Funaba 1998, 1999
# $Id: cal.rb,v 1.5 1999/08/04 14:54:18 tadf Exp $ # $Id: cal.rb,v 1.6 1999/09/15 05:35:25 tadf Exp $
require 'date2' require 'date2'
@ -39,7 +39,7 @@ def cal(m, y, sg)
for d in 1..31 for d in 1..31
break if jd = Date.exist?(y, m, d, sg) break if jd = Date.exist?(y, m, d, sg)
end end
fst = cur = Date.new(jd, sg) fst = cur = Date.new1(jd, sg)
ti = Date::MONTHNAMES[m] ti = Date::MONTHNAMES[m]
ti << ' ' << y.to_s unless $yr ti << ' ' << y.to_s unless $yr
mo = ti.center((($w + 1) * 7) - 1) << "\n" mo = ti.center((($w + 1) * 7) - 1) << "\n"

View file

@ -520,7 +520,7 @@ rb_str_match(x, y)
reg = rb_reg_regcomp(y); reg = rb_reg_regcomp(y);
start = rb_reg_search(reg, x, 0, 0); start = rb_reg_search(reg, x, 0, 0);
if (start == -1) { if (start == -1) {
return Qfalse; return Qnil;
} }
return INT2NUM(start); return INT2NUM(start);
@ -760,7 +760,7 @@ rb_str_upto(beg, end, excl)
if (TYPE(end) != T_STRING) end = rb_str_to_str(end); if (TYPE(end) != T_STRING) end = rb_str_to_str(end);
current = beg; current = beg;
for (;;) { while (rb_str_cmp(current, end) <= 0) {
rb_yield(current); rb_yield(current);
if (!excl && rb_str_equal(current, end)) break; if (!excl && rb_str_equal(current, end)) break;
current = rb_str_succ(current); current = rb_str_succ(current);

17
time.c
View file

@ -208,8 +208,8 @@ time_arg(argc, argv, tm)
} }
tm->tm_year = obj2long(v[0]); tm->tm_year = obj2long(v[0]);
if (tm->tm_year < 69) tm->tm_year += 100; if (0 < tm->tm_year && tm->tm_year < 69) tm->tm_year += 100;
if (tm->tm_year >= 1000) tm->tm_year -= 1900; if (tm->tm_year >= 1900) tm->tm_year -= 1900;
if (NIL_P(v[1])) { if (NIL_P(v[1])) {
tm->tm_mon = 0; tm->tm_mon = 0;
} }
@ -263,9 +263,9 @@ make_time_t(tptr, fn)
struct tm *(*fn)(); struct tm *(*fn)();
{ {
struct timeval tv; struct timeval tv;
time_t guess, t; time_t oguess, guess;
struct tm *tm; struct tm *tm;
long diff; long t, diff;
if (gettimeofday(&tv, 0) < 0) { if (gettimeofday(&tv, 0) < 0) {
rb_sys_fail("gettimeofday"); rb_sys_fail("gettimeofday");
@ -276,9 +276,10 @@ make_time_t(tptr, fn)
if (!tm) goto error; if (!tm) goto error;
t = tptr->tm_year; t = tptr->tm_year;
if (t < 69) goto out_of_range; if (t < 69) goto out_of_range;
while (diff = t - (tm->tm_year)) { while (diff = t - tm->tm_year) {
oguess = guess;
guess += diff * 364 * 24 * 3600; guess += diff * 364 * 24 * 3600;
if (diff > 0 && guess < 0) goto out_of_range; if (diff > 0 && guess <= oguess) goto out_of_range;
tm = (*fn)(&guess); tm = (*fn)(&guess);
if (!tm) goto error; if (!tm) goto error;
} }
@ -292,7 +293,7 @@ make_time_t(tptr, fn)
guess += (tptr->tm_mday - tm->tm_mday) * 3600 * 24; guess += (tptr->tm_mday - tm->tm_mday) * 3600 * 24;
guess += (tptr->tm_hour - tm->tm_hour) * 3600; guess += (tptr->tm_hour - tm->tm_hour) * 3600;
guess += (tptr->tm_min - tm->tm_min) * 60; guess += (tptr->tm_min - tm->tm_min) * 60;
guess += tptr->tm_sec - tm->tm_sec; guess += (tptr->tm_sec - tm->tm_sec);
if (guess < 0) goto out_of_range; if (guess < 0) goto out_of_range;
return guess; return guess;
@ -302,7 +303,7 @@ make_time_t(tptr, fn)
error: error:
rb_raise(rb_eArgError, "gmtime/localtime error"); rb_raise(rb_eArgError, "gmtime/localtime error");
return Qnil; /* not reached */ return 0; /* not reached */
} }
static VALUE static VALUE

View file

@ -1,4 +1,4 @@
#define RUBY_VERSION "1.4.0" #define RUBY_VERSION "1.4.1"
#define RUBY_RELEASE_DATE "1999-08-13" #define RUBY_RELEASE_DATE "1999-09-16"
#define RUBY_VERSION_CODE 140 #define RUBY_VERSION_CODE 141
#define RUBY_RELEASE_CODE 19990813 #define RUBY_RELEASE_CODE 19990916