summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-09-16 09:40:33 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-09-16 09:40:33 +0000
commit9e3d9a2a009d2a0281802a84e1c5cc1c887edc71 (patch)
treeea994af7deeef43977f60a9ab26131e8cd90a9a0
parent69a3aaf154948d653fa3653cd2b3c3b3af979769 (diff)
1.4.1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@527 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog53
-rw-r--r--MANIFEST16
-rw-r--r--compar.c26
-rw-r--r--eval.c34
-rw-r--r--file.c9
-rw-r--r--lib/date2.rb274
-rw-r--r--lib/parsedate.rb1
-rw-r--r--lib/telnet.rb58
-rw-r--r--numeric.c1
-rw-r--r--parse.y18
-rw-r--r--prec.c2
-rw-r--r--random.c3
-rw-r--r--range.c24
-rw-r--r--re.c2
-rw-r--r--sample/README6
-rw-r--r--sample/cal.rb4
-rw-r--r--string.c4
-rw-r--r--time.c17
-rw-r--r--version.h8
19 files changed, 397 insertions, 163 deletions
diff --git a/ChangeLog b/ChangeLog
index 3703d8e239..211bbc0498 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
* eval.c (rb_call): call rb_undefined() if a method appears not to
diff --git a/MANIFEST b/MANIFEST
index b0fe477bd3..2cf27f2509 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -88,6 +88,7 @@ lib/English.rb
lib/Env.rb
lib/README
lib/base64.rb
+lib/cgi.rb
lib/cgi-lib.rb
lib/complex.rb
lib/date.rb
@@ -104,6 +105,18 @@ lib/ftools.rb
lib/getopts.rb
lib/getoptlong.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/mailread.rb
lib/mathn.rb
@@ -111,6 +124,9 @@ lib/matrix.rb
lib/mkmf.rb
lib/monitor.rb
lib/mutex_m.rb
+lib/net/pop.rb
+lib/net/session.rb
+lib/net/smtp.rb
lib/observer.rb
lib/open3.rb
lib/ostruct.rb
diff --git a/compar.c b/compar.c
index 50e4fa3a87..677b6a3cbd 100644
--- a/compar.c
+++ b/compar.c
@@ -17,10 +17,10 @@ VALUE rb_mComparable;
static ID cmp;
static VALUE
-cmp_eq(x, y)
- VALUE x, y;
+cmp_eq(a)
+ VALUE *a;
{
- VALUE c = rb_funcall(x, cmp, 1, y);
+ VALUE c = rb_funcall(a[0], cmp, 1, a[1]);
int t = NUM2INT(c);
if (t == 0) return Qtrue;
@@ -28,6 +28,24 @@ cmp_eq(x, y)
}
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
cmp_gt(x, y)
VALUE x, y;
{
@@ -89,7 +107,7 @@ void
Init_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_ge, 1);
rb_define_method(rb_mComparable, "<", cmp_lt, 1);
diff --git a/eval.c b/eval.c
index 579b3c54ae..98ae96c684 100644
--- a/eval.c
+++ b/eval.c
@@ -169,7 +169,7 @@ rb_get_method_body(klassp, idp, noexp)
struct cache_entry *ent;
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->klass = klass;
ent->origin = klass;
@@ -1795,11 +1795,31 @@ rb_eval(self, node)
}
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:
- while (!NIL_P(rb_gets())) {
- rb_eval(self, node->nd_body);
+ PUSH_TAG(PROT_NONE);
+ 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);
case NODE_SELF:
@@ -2371,10 +2391,8 @@ rb_eval(self, node)
/* check for static scope constants */
if (RTEST(ruby_verbose) &&
ev_const_defined((NODE*)ruby_frame->cbase, node->nd_vid)) {
- if (RTEST(ruby_verbose)) {
- rb_warning("already initialized constant %s",
- rb_id2name(node->nd_vid));
- }
+ rb_warn("already initialized constant %s",
+ rb_id2name(node->nd_vid));
}
rb_const_set(ruby_class, node->nd_vid, result);
break;
diff --git a/file.c b/file.c
index 9ac2db6b35..182c6d0b42 100644
--- a/file.c
+++ b/file.c
@@ -1107,7 +1107,7 @@ rb_file_s_expand_path(argc, argv)
}
}
#endif
- else if (s[0] != '/') {
+ else if (!isdirsep(*s)) {
if (argc == 2) {
dname = rb_file_s_expand_path(1, &dname);
strcpy(buf, RSTRING(dname)->ptr);
@@ -1122,6 +1122,13 @@ rb_file_s_expand_path(argc, argv)
p = &buf[strlen(buf)];
while (p > buf && *(p - 1) == '/') p--;
}
+ else if (isdirsep(*s)) {
+ while (*s && isdirsep(*s)) {
+ *p++ = '/';
+ s++;
+ }
+ if (p > buf && *s) p--;
+ }
*p = '/';
for ( ; *s; s++) {
diff --git a/lib/date2.rb b/lib/date2.rb
index cc5e7f4238..38d477b78d 100644
--- a/lib/date2.rb
+++ b/lib/date2.rb
@@ -1,10 +1,12 @@
# 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
include Comparable
+ IDENT = 2
+
MONTHNAMES = [ nil, 'January', 'February', 'March',
'April', 'May', 'June', 'July', 'August',
'September', 'October', 'November', 'December' ]
@@ -12,8 +14,10 @@ class Date
DAYNAMES = [ 'Sunday', 'Monday', 'Tuesday',
'Wednesday', 'Thursday', 'Friday', 'Saturday' ]
- ITALY = 2299161 # Oct 15, 1582
- ENGLAND = 2361222 # Sept 14, 1752
+ ITALY = 2299161 # 1582-10-15
+ ENGLAND = 2361222 # 1752-09-14
+ JULIAN = false
+ GREGORIAN = true
class << self
@@ -26,7 +30,7 @@ class Date
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
y -= 1
m += 12
@@ -42,7 +46,7 @@ class Date
jd
end
- def jd_to_civil(jd, sg=true)
+ def jd_to_civil(jd, sg=GREGORIAN)
if os?(jd, sg)
a = jd
else
@@ -64,16 +68,44 @@ class Date
return y, m, dom
end
- def ordinal_to_jd(y, d, sg=true)
+ def ordinal_to_jd(y, d, sg=GREGORIAN)
civil_to_jd(y, 1, d, sg)
end
- def jd_to_ordinal(jd, sg=true)
+ def jd_to_ordinal(jd, sg=GREGORIAN)
y = jd_to_civil(jd, sg)[0]
doy = jd - civil_to_jd(y - 1, 12, 31, ns?(jd, sg))
return y, doy
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 jd_to_mjd(jd) jd - 2400000.5 end
def tjd_to_jd(tjd) tjd + 2440000.5 end
@@ -84,25 +116,25 @@ class Date
alias_method :leap?, :gregorian_leap?
+ def new1(jd=0, sg=ITALY) new(jd, sg) end
+
def exist3? (y, m, d, sg=ITALY)
if m < 0
m += 13
end
if d < 0
- ljd = nil
- 31.downto 1 do |ld|
- break if ljd = exist3?(y, m, ld, sg)
+ ny, nm = Date.clfloor(y * 12 + m, 12)
+ nm, = Date.clfloor(m + 1, 1)
+ la = nil
+ 31.downto 1 do |z|
+ break if la = exist3?(y, m, z, sg)
end
- x = y * 12 + m
- ny = x / 12
- nm = x % 12 + 1
- d = jd_to_civil(civil_to_jd(ny, nm, 1, ns?(ljd, sg)) + d,
- ns?(ljd, sg))[-1]
+ ns = ns?(la, sg)
+ d = jd_to_civil(civil_to_jd(ny, nm, 1, ns) + d, ns)[-1]
end
jd = civil_to_jd(y, m, d, sg)
- if [y, m, d] == jd_to_civil(jd, sg)
- jd
- end
+ return unless [y, m, d] == jd_to_civil(jd, sg)
+ jd
end
alias_method :exist?, :exist3?
@@ -116,18 +148,17 @@ class Date
def exist2? (y, d, sg=ITALY)
if d < 0
- ljd = nil
- 366.downto 1 do |ld|
- break if ljd = exist2?(y, ld, sg)
- end
ny = y + 1
- d = jd_to_ordinal(ordinal_to_jd(ny, 1, ns?(ljd, sg)) + d,
- ns?(ljd, sg))[-1]
+ la = nil
+ 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
jd = ordinal_to_jd(y, d, sg)
- if [y, d] == jd_to_ordinal(jd, sg)
- jd
- end
+ return unless [y, d] == jd_to_ordinal(jd, sg)
+ jd
end
def new2(y=-4712, d=1, sg=ITALY)
@@ -137,130 +168,179 @@ class Date
new(jd, sg)
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)
new(civil_to_jd(*(Time.now.to_a[3..5].reverse << sg)), sg)
end
- end
-
- def initialize(jd=0, sg=ITALY) @jd, @sg = jd, sg 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
- def jd() @jd end
+ private :once
- def mjd
- def self.mjd() @mjd end
- @mjd = Date.jd_to_mjd(@jd)
end
- def tjd
- def self.tjd() @tjd end
- @tjd = Date.jd_to_tjd(@jd)
- end
+ def initialize(rjd=0, sg=ITALY) @rjd, @sg = rjd, sg end
- def civil
- 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
+ def rjd() @rjd end
+ def rmjd() Date.jd_to_mjd(@rjd) end
+ def rtjd() Date.jd_to_tjd(@rjd) end
- private :civil
+ once :rmjd, :rtjd
- def year
- civil
- @year
- end
+ def jd() Date.rjd_to_jd(@rjd)[0] end
+ def fr1() Date.rjd_to_jd(@rjd)[1] end
+ def mjd() Date.jd_to_mjd(jd) end
+ def tjd() Date.jd_to_tjd(jd) end
- def yday
- def self.yday() @yday end
- @yday = Date.jd_to_ordinal(@jd, @sg)[-1]
- @yday
- end
+ once :jd, :fr1, :mjd, :tjd
- def mon
- civil
- @mon
- end
+ 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
+
+ once :civil, :ordinal, :commercial
+
+ def year() civil[0] end
+ def yday() ordinal[1] end
+ def mon() civil[1] end
alias_method :month, :mon
+ once :year, :yday, :mon, :month
- def mday
- civil
- @mday
- end
+ def mday() civil[2] end
alias_method :day, :mday
+ once :mday, :day
- def wday
- def self.wday() @wday end
- @wday = (@jd + 1) % 7
- end
+ def cwyear() commercial[0] end
+ def cweek() commercial[1] end
+ def cwday() commercial[2] end
+
+ once :cwyear, :cweek, :cwday
+
+ def wday() (jd + 1) % 7 end
+
+ once :wday
+
+ def os? () Date.os?(jd, @sg) end
+ def ns? () Date.ns?(jd, @sg) end
- def os? () Date.os?(@jd, @sg) end
- def ns? () Date.ns?(@jd, @sg) end
+ once :os?, :ns?
def leap?
- def self.leap?() @leap_p end
- @leap_p = Date.jd_to_civil(Date.civil_to_jd(year, 3, 1, ns?) - 1,
- ns?)[-1] == 29
+ Date.jd_to_civil(Date.civil_to_jd(year, 3, 1, ns?) - 1,
+ ns?)[-1] == 29
end
- def + (other)
- case other
- when Numeric; return Date.new(@jd + other, @sg)
+ once :leap?
+
+ 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
fail TypeError, 'expected numeric'
end
- def - (other)
- case other
- when Numeric; return Date.new(@jd - other, @sg)
- when Date; return @jd - other.jd
+ def - (x)
+ case x
+ when Numeric; return Date.new(@rjd - x, @sg)
+ when Date; return @rjd - x.rjd
end
fail TypeError, 'expected numeric or date'
end
def <=> (other)
case other
- when Numeric; return @jd <=> other
- when Date; return @jd <=> other.jd
+ when Numeric; return @rjd <=> other
+ when Date; return @rjd <=> other.rjd
end
fail TypeError, 'expected numeric or date'
end
- def downto(min)
- @jd.downto(min.jd) do |jd|
- yield Date.new(jd, @sg)
+ def === (other)
+ case other
+ when Numeric; return jd == other
+ when Date; return jd == other.jd
end
- self
+ fail TypeError, 'expected numeric or date'
end
- def upto(max)
- @jd.upto(max.jd) do |jd|
- yield Date.new(jd, @sg)
- end
- self
+ def >> (n)
+ y, m = Date.clfloor(year * 12 + (mon - 1) + n, 12)
+ m, = Date.clfloor(m + 1, 1)
+ d = mday
+ d -= 1 until jd2 = Date.exist3?(y, m, d, ns?)
+ self + (jd2 - jd)
end
+ def << (n) self >> -n end
+
def step(limit, step)
- @jd.step(limit.jd, step) do |jd|
- yield Date.new(jd, @sg)
+ rjd = @rjd
+ 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
self
end
+ def upto(max, &block) step(max, +1, &block) end
+ def downto(min, &block) step(min, -1, &block) end
+
def succ() self + 1 end
alias_method :next, :succ
- def eql? (other) self == other end
- def hash() @jd end
- def inspect() format('#<Date: %s,%s>', @jd, @sg) end
+ def eql? (other) Date === other and self == other end
+ def hash() Date.clfloor(@rjd)[0] end
+ def inspect() format('#<Date: %s,%s>', @rjd, @sg) 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
end
diff --git a/lib/parsedate.rb b/lib/parsedate.rb
index f49266d2e5..29b3fa43b9 100644
--- a/lib/parsedate.rb
+++ b/lib/parsedate.rb
@@ -67,7 +67,6 @@ module ParseDate
mon = MONTHS[$2.downcase]
year = $3.to_i
end
- p date
if date.sub!(/\d{4}/i, ' ')
year = $&.to_i
elsif date.sub!(/\d\d/i, ' ')
diff --git a/lib/telnet.rb b/lib/telnet.rb
index 96e2cac100..9300bf6e18 100644
--- a/lib/telnet.rb
+++ b/lib/telnet.rb
@@ -1,11 +1,11 @@
=begin
-$Date: 1999/08/10 05:20:21 $
+$Date: 1999/09/14 23:09:05 $
== SIMPLE TELNET CLIANT LIBRARY
telnet.rb
-Version 0.232
+Version 0.30
Wakou Aoyama <wakou@fsinet.or.jp>
@@ -34,7 +34,7 @@ the network or the host is very heavy, the value is enlarged.
=== STATUS OUTPUT
- host = Telnet.new({"Host" => "localhost"){|c| print c }
+ host = Telnet.new({"Host" => "localhost"}){|c| print c }
connection status output.
@@ -110,6 +110,13 @@ of cource, set sync=true or flush is necessary.
"Prompt" => /[$%#>] \z/n,
"Timeout" => 10})
+if no password prompt.
+
+ host.login("username")
+ host.login({"Name" => "username",
+ "Prompt" => /[$%#>] \z/n,
+ "Timeout" => 10})
+
==== REALTIME OUTPUT
@@ -147,13 +154,28 @@ of cource, set sync=true or flush is necessary.
== 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
1999/08/10 05:20:21
- 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({"Host" => "localhost"){|c| print c }
+ --> host = Telnet.new({"Host" => "localhost"){|c| print c }
=== Version 0.231
@@ -370,8 +392,8 @@ class Telnet < SimpleDelegator
EOL = CR + LF
v = $-v
$-v = false
- VERSION = "0.232"
- RELEASE_DATE = "$Date: 1999/08/10 05:20:21 $"
+ VERSION = "0.30"
+ RELEASE_DATE = "$Date: 1999/09/14 23:09:05 $"
$-v = v
def initialize(options)
@@ -540,7 +562,7 @@ $-v = v
line = ''
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)
raise TimeOut, "timed-out; wait for the next data"
end
@@ -611,7 +633,7 @@ $-v = v
end
end
- def login(options, password = '')
+ def login(options, password = nil)
if options.kind_of?(Hash)
username = options["Name"]
password = options["Password"]
@@ -621,14 +643,22 @@ $-v = v
if iterator?
line = waitfor(/login[: ]*\z/n){|c| yield c }
- line.concat( cmd({"String" => username,
- "Match" => /Password[: ]*\z/n}){|c| yield c } )
- line.concat( cmd(password){|c| yield c } )
+ if password
+ line.concat( cmd({"String" => username,
+ "Match" => /Password[: ]*\z/n}){|c| yield c } )
+ line.concat( cmd(password){|c| yield c } )
+ else
+ line.concat( cmd(username){|c| yield c } )
+ end
else
line = waitfor(/login[: ]*\z/n)
- line.concat( cmd({"String" => username,
- "Match" => /Password[: ]*\z/n}) )
- line.concat( cmd(password) )
+ if password
+ line.concat( cmd({"String" => username,
+ "Match" => /Password[: ]*\z/n}) )
+ line.concat( cmd(password) )
+ else
+ line.concat( cmd(username) )
+ end
end
line
end
diff --git a/numeric.c b/numeric.c
index 568d6c0ea1..d1c016e708 100644
--- a/numeric.c
+++ b/numeric.c
@@ -376,7 +376,6 @@ num_eql(x, y)
return rb_equal(x, y);
}
-
static VALUE
num_equal(x, y)
VALUE x, y;
diff --git a/parse.y b/parse.y
index 103d01bbf7..b6ad7b596b 100644
--- a/parse.y
+++ b/parse.y
@@ -1840,7 +1840,8 @@ nextc()
ruby_sourceline++;
lex_pbeg = lex_p = RSTRING(v)->ptr;
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;
lex_lastline = 0;
return -1;
@@ -1853,6 +1854,10 @@ nextc()
}
}
c = (unsigned char)*lex_p++;
+ if (c == '\r' && lex_p <= lex_pend && *lex_p == '\n') {
+ lex_p++;
+ c = '\n';
+ }
return c;
}
@@ -2916,7 +2921,7 @@ yylex()
case ':':
c = nextc();
if (c == ':') {
- if (lex_state == EXPR_BEG) {
+ if (lex_state == EXPR_BEG || lex_state == EXPR_MID) {
lex_state = EXPR_BEG;
return tCOLON3;
}
@@ -3019,10 +3024,6 @@ yylex()
case '\\':
c = nextc();
- if (c == '\r') {
- c = nextc();
- if (c != '\n') pushback(c);
- }
if (c == '\n') {
space_seen = 1;
goto retry; /* skip \\n */
@@ -3230,7 +3231,8 @@ yylex()
}
else if (toklast() == '!' || toklast() == '?') {
result = tFID;
- } else {
+ }
+ else {
result = tIDENTIFIER;
if (lex_state == EXPR_FNAME || lex_state == EXPR_DOT) {
if ((c = nextc()) == '=' && !peek('=')) {
@@ -3243,7 +3245,7 @@ yylex()
}
if (lex_state == EXPR_BEG ||
lex_state == EXPR_DOT ||
- lex_state == EXPR_ARG){
+ lex_state == EXPR_ARG) {
lex_state = EXPR_ARG;
}
else {
diff --git a/prec.c b/prec.c
index 693b81ba4c..e4e116c347 100644
--- a/prec.c
+++ b/prec.c
@@ -1,6 +1,6 @@
/************************************************
- ruby.h -
+ prec.c -
$Author$
$Date$
diff --git a/random.c b/random.c
index e78225cabb..e977094eaa 100644
--- a/random.c
+++ b/random.c
@@ -92,10 +92,11 @@ rb_f_srand(argc, argv, obj)
static int saved_seed;
if (rb_scan_args(argc, argv, "01", &seed) == 0) {
+ static int n = 0;
struct timeval tv;
gettimeofday(&tv, 0);
- seed = tv.tv_sec ^ tv.tv_usec ^ getpid();
+ seed = tv.tv_sec ^ tv.tv_usec ^ getpid() ^ n++;
}
else {
seed = NUM2UINT(seed);
diff --git a/range.c b/range.c
index d37dfaa21f..b1925e9929 100644
--- a/range.c
+++ b/range.c
@@ -134,14 +134,28 @@ range_each(range)
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;
- ID le = EXCL(range)?'<':rb_intern("<=");
ID succ = rb_intern("succ");
- while (rb_funcall(v, le, 1, e)) {
- rb_yield(v);
- v = rb_funcall(v, succ, 0, 0);
+ if (EXCL(range)) {
+ while (RTEST(rb_funcall(v, '<', 1, e))) {
+ 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);
+ }
}
}
diff --git a/re.c b/re.c
index 4ecc46eee5..ac73732d39 100644
--- a/re.c
+++ b/re.c
@@ -964,7 +964,7 @@ rb_reg_s_quote(argc, argv)
if (*s == '[' || *s == ']'
|| *s == '{' || *s == '}'
|| *s == '(' || *s == ')'
- || *s == '|'
+ || *s == '|' || *s == '-'
|| *s == '*' || *s == '.' || *s == '\\'
|| *s == '?' || *s == '+'
|| *s == '^' || *s == '$') {
diff --git a/sample/README b/sample/README
index 1bdc85f32b..82db05eec9 100644
--- a/sample/README
+++ b/sample/README
@@ -22,8 +22,8 @@ from.rb scan mail spool
fullpath.rb convert ls -lR to fullpath format
getopts.test test fot getopt.rb
goodfriday.rb print various christian calendar event.
-inf-ruby.el program to run ruby under emacs
io.rb io test
+irb.rb interactive ruby
less.rb front end for less
list.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
philos.rb famous dining philosophers
pi.rb calculate PI
-rbc.rb interactive ruby, to be removed by irb
rcs.awk random character stereogram (AWK)
rcs.rb random character stereogram (Ruby)
rcs.dat data for random character stereogram
rd2html.rb rd (Ruby Document) to HTML translator
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
svr.rb socket server
test.rb test suite used by `make test'
diff --git a/sample/cal.rb b/sample/cal.rb
index cf82c6421c..8eea4abfdb 100644
--- a/sample/cal.rb
+++ b/sample/cal.rb
@@ -1,7 +1,7 @@
#! /usr/local/bin/ruby
# 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'
@@ -39,7 +39,7 @@ def cal(m, y, sg)
for d in 1..31
break if jd = Date.exist?(y, m, d, sg)
end
- fst = cur = Date.new(jd, sg)
+ fst = cur = Date.new1(jd, sg)
ti = Date::MONTHNAMES[m]
ti << ' ' << y.to_s unless $yr
mo = ti.center((($w + 1) * 7) - 1) << "\n"
diff --git a/string.c b/string.c
index 94acc767fb..7bb9d09966 100644
--- a/string.c
+++ b/string.c
@@ -520,7 +520,7 @@ rb_str_match(x, y)
reg = rb_reg_regcomp(y);
start = rb_reg_search(reg, x, 0, 0);
if (start == -1) {
- return Qfalse;
+ return Qnil;
}
return INT2NUM(start);
@@ -760,7 +760,7 @@ rb_str_upto(beg, end, excl)
if (TYPE(end) != T_STRING) end = rb_str_to_str(end);
current = beg;
- for (;;) {
+ while (rb_str_cmp(current, end) <= 0) {
rb_yield(current);
if (!excl && rb_str_equal(current, end)) break;
current = rb_str_succ(current);
diff --git a/time.c b/time.c
index f8296e6e20..8a6d562a87 100644
--- a/time.c
+++ b/time.c
@@ -208,8 +208,8 @@ time_arg(argc, argv, tm)
}
tm->tm_year = obj2long(v[0]);
- if (tm->tm_year < 69) tm->tm_year += 100;
- if (tm->tm_year >= 1000) tm->tm_year -= 1900;
+ if (0 < tm->tm_year && tm->tm_year < 69) tm->tm_year += 100;
+ if (tm->tm_year >= 1900) tm->tm_year -= 1900;
if (NIL_P(v[1])) {
tm->tm_mon = 0;
}
@@ -263,9 +263,9 @@ make_time_t(tptr, fn)
struct tm *(*fn)();
{
struct timeval tv;
- time_t guess, t;
+ time_t oguess, guess;
struct tm *tm;
- long diff;
+ long t, diff;
if (gettimeofday(&tv, 0) < 0) {
rb_sys_fail("gettimeofday");
@@ -276,9 +276,10 @@ make_time_t(tptr, fn)
if (!tm) goto error;
t = tptr->tm_year;
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;
- if (diff > 0 && guess < 0) goto out_of_range;
+ if (diff > 0 && guess <= oguess) goto out_of_range;
tm = (*fn)(&guess);
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_hour - tm->tm_hour) * 3600;
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;
return guess;
@@ -302,7 +303,7 @@ make_time_t(tptr, fn)
error:
rb_raise(rb_eArgError, "gmtime/localtime error");
- return Qnil; /* not reached */
+ return 0; /* not reached */
}
static VALUE
diff --git a/version.h b/version.h
index d2c5ba958d..72ef4efd83 100644
--- a/version.h
+++ b/version.h
@@ -1,4 +1,4 @@
-#define RUBY_VERSION "1.4.0"
-#define RUBY_RELEASE_DATE "1999-08-13"
-#define RUBY_VERSION_CODE 140
-#define RUBY_RELEASE_CODE 19990813
+#define RUBY_VERSION "1.4.1"
+#define RUBY_RELEASE_DATE "1999-09-16"
+#define RUBY_VERSION_CODE 141
+#define RUBY_RELEASE_CODE 19990916