summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-07-10 04:49:24 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-07-10 04:49:24 +0000
commitc67a74570dd056569763f5015e0aafa7d454fca7 (patch)
treef1dda39296b6911752cd4b6446a21f2e54ff68e1 /lib
parent3043170b14875ce53f3a951d665279b12c2c63a8 (diff)
matz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@820 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/date.rb8
-rw-r--r--lib/date2.rb14
-rw-r--r--lib/jcode.rb2
-rw-r--r--lib/matrix.rb58
-rw-r--r--lib/net/ftp.rb4
-rw-r--r--lib/tracer.rb8
-rw-r--r--lib/weakref.rb28
7 files changed, 62 insertions, 60 deletions
diff --git a/lib/date.rb b/lib/date.rb
index 3a7d3c7b1b..dbb47f0af2 100644
--- a/lib/date.rb
+++ b/lib/date.rb
@@ -1,8 +1,8 @@
#
# Date.rb -
# $Release Version: $
-# $Revision: 1.1.1.2 $
-# $Date: 1999/01/20 04:59:35 $
+# $Revision: 1.2 $
+# $Date: 2000/07/06 07:21:23 $
# by Yasuo OHBA(SHL Japan Inc. Technology Dept.)
#
# --
@@ -168,12 +168,10 @@ class Date
m = Date.daylist(@year)
if @month < 1 || @month > 12
raise ArgumentError, "argument(month) out of range."
- return nil
end
if @year == 1752 && @month == 9
if @day >= 3 && @day <= 13
raise ArgumentError, "argument(1752/09/3-13) out of range."
- return nil
end
d = 30
else
@@ -181,7 +179,6 @@ class Date
end
if @day < 1 || @day > d
raise ArgumentError, "argument(day) out of range."
- return nil
end
return self
end
@@ -299,4 +296,3 @@ def Date.jan1!(y)
end
return (d % 7)
end
-
diff --git a/lib/date2.rb b/lib/date2.rb
index e1badcd3f7..ad631456f2 100644
--- a/lib/date2.rb
+++ b/lib/date2.rb
@@ -147,7 +147,7 @@ class Date
def new3(y=-4712, m=1, d=1, sg=ITALY)
unless jd = exist3?(y, m, d, sg)
- fail ArgumentError, 'invalid date'
+ raise ArgumentError, 'invalid date'
end
new(jd, sg)
end
@@ -169,7 +169,7 @@ class Date
def new2(y=-4712, d=1, sg=ITALY)
unless jd = exist2?(y, d, sg)
- fail ArgumentError, 'invalid date'
+ raise ArgumentError, 'invalid date'
end
new(jd, sg)
end
@@ -189,7 +189,7 @@ class Date
def neww(y=1582, w=41, d=5, sg=ITALY)
unless jd = existw?(y, w, d, sg)
- fail ArgumentError, 'invalid date'
+ raise ArgumentError, 'invalid date'
end
new(jd, sg)
end
@@ -280,7 +280,7 @@ class Date
case n
when Numeric; return type.new(@rjd + n, @sg)
end
- fail TypeError, 'expected numeric'
+ raise TypeError, 'expected numeric'
end
def - (x)
@@ -288,7 +288,7 @@ class Date
when Numeric; return type.new(@rjd - x, @sg)
when Date; return @rjd - x.rjd
end
- fail TypeError, 'expected numeric or date'
+ raise TypeError, 'expected numeric or date'
end
def <=> (other)
@@ -296,7 +296,7 @@ class Date
when Numeric; return @rjd <=> other
when Date; return @rjd <=> other.rjd
end
- fail TypeError, 'expected numeric or date'
+ raise TypeError, 'expected numeric or date'
end
def === (other)
@@ -304,7 +304,7 @@ class Date
when Numeric; return jd == other
when Date; return jd == other.jd
end
- fail TypeError, 'expected numeric or date'
+ raise TypeError, 'expected numeric or date'
end
def >> (n)
diff --git a/lib/jcode.rb b/lib/jcode.rb
index 193f3042ff..923153a637 100644
--- a/lib/jcode.rb
+++ b/lib/jcode.rb
@@ -1,6 +1,6 @@
# jcode.rb - ruby code to handle japanese (EUC/SJIS) string
-$vsave, $VERBOSE = $VERBOSE, FALSE
+$vsave, $VERBOSE = $VERBOSE, false
class String
printf STDERR, "feel free for some warnings:\n" if $VERBOSE
diff --git a/lib/matrix.rb b/lib/matrix.rb
index 9de7dcb3a2..223bf70869 100644
--- a/lib/matrix.rb
+++ b/lib/matrix.rb
@@ -37,7 +37,7 @@
# creates a matrix where `rows' indicates rows.
# `rows' is an array of arrays,
# e.g, Matrix[[11, 12], [21, 22]]
-# Matrix.rows(rows, copy = TRUE)
+# Matrix.rows(rows, copy = true)
# creates a matrix where `rows' indicates rows.
# if optional argument `copy' is false, use the array as
# internal structure of the metrix without copying.
@@ -143,7 +143,7 @@
#
# INSTANCE CREATION:
# Vector.[](*array)
-# Vector.elements(array, copy = TRUE)
+# Vector.elements(array, copy = true)
# ACCSESSING:
# [](i)
# size
@@ -193,10 +193,10 @@ class Matrix
private_class_method :new
def Matrix.[](*rows)
- new(:init_rows, rows, FALSE)
+ new(:init_rows, rows, false)
end
- def Matrix.rows(rows, copy = TRUE)
+ def Matrix.rows(rows, copy = true)
new(:init_rows, rows, copy)
end
@@ -208,7 +208,7 @@ class Matrix
columns[j][i]
}
}
- Matrix.rows(rows, FALSE)
+ Matrix.rows(rows, false)
end
def Matrix.diagonal(*values)
@@ -220,7 +220,7 @@ class Matrix
row
}
self
- rows(rows, FALSE)
+ rows(rows, false)
end
def Matrix.scalar(n, value)
@@ -242,11 +242,11 @@ class Matrix
def Matrix.row_vector(row)
case row
when Vector
- Matrix.rows([row.to_a], FALSE)
+ Matrix.rows([row.to_a], false)
when Array
- Matrix.rows([row.dup], FALSE)
+ Matrix.rows([row.dup], false)
else
- Matrix.row([[row]], FALSE)
+ Matrix.row([[row]], false)
end
end
@@ -311,13 +311,13 @@ class Matrix
|i|
@rows[i][j]
}
- Vector.elements(col, FALSE)
+ Vector.elements(col, false)
end
end
def collect
rows = @rows.collect{|row| row.collect{|e| yield e}}
- Matrix.rows(rows, FALSE)
+ Matrix.rows(rows, false)
end
alias map collect
@@ -345,7 +345,7 @@ class Matrix
|row|
row[from_col, size_col]
}
- Matrix.rows(rows, FALSE)
+ Matrix.rows(rows, false)
end
# TESTING
@@ -363,20 +363,20 @@ class Matrix
# COMPARING
def ==(other)
- return FALSE unless Matrix === other
+ return false unless Matrix === other
other.compare_by_row_vectors(@rows)
end
alias eql? ==
def compare_by_row_vectors(rows)
- return FALSE unless @rows.size == rows.size
+ return false unless @rows.size == rows.size
0.upto(@rows.size - 1) do
|i|
- return FALSE unless @rows[i] == rows[i]
+ return false unless @rows[i] == rows[i]
end
- TRUE
+ true
end
def clone
@@ -405,7 +405,7 @@ class Matrix
e * m
}
}
- return Matrix.rows(rows, FALSE)
+ return Matrix.rows(rows, false)
when Vector
m = Matrix.column_vector(m)
r = self * m
@@ -425,7 +425,7 @@ class Matrix
vij
}
}
- return Matrix.rows(rows, FALSE)
+ return Matrix.rows(rows, false)
else
x, y = m.coerce(self)
return x * y
@@ -453,7 +453,7 @@ class Matrix
self[i, j] + m[i, j]
}
}
- Matrix.rows(rows, FALSE)
+ Matrix.rows(rows, false)
end
def -(m)
@@ -477,7 +477,7 @@ class Matrix
self[i, j] - m[i, j]
}
}
- Matrix.rows(rows, FALSE)
+ Matrix.rows(rows, false)
end
def /(other)
@@ -490,7 +490,7 @@ class Matrix
e / other
}
}
- return Matrix.rows(rows, FALSE)
+ return Matrix.rows(rows, false)
when Matrix
return self * other.inverse
else
@@ -825,10 +825,10 @@ class Vector
private_class_method :new
def Vector.[](*array)
- new(:init_elements, array, copy = FALSE)
+ new(:init_elements, array, copy = false)
end
- def Vector.elements(array, copy = TRUE)
+ def Vector.elements(array, copy = true)
new(:init_elements, array, copy)
end
@@ -873,7 +873,7 @@ class Vector
# COMPARING
def ==(other)
- return FALSE unless Vector === other
+ return false unless Vector === other
other.compare_by(@elements)
end
@@ -897,7 +897,7 @@ class Vector
case x
when Numeric
els = @elements.collect{|e| e * x}
- Vector.elements(els, FALSE)
+ Vector.elements(els, false)
when Matrix
self.covector * x
else
@@ -914,7 +914,7 @@ class Vector
|v1, v2|
v1 + v2
}
- Vector.elements(els, FALSE)
+ Vector.elements(els, false)
when Matrix
Matrix.column_vector(self) + v
else
@@ -931,7 +931,7 @@ class Vector
|v1, v2|
v1 - v2
}
- Vector.elements(els, FALSE)
+ Vector.elements(els, false)
when Matrix
Matrix.column_vector(self) - v
else
@@ -958,7 +958,7 @@ class Vector
|v|
yield v
}
- Vector.elements(els, FALSE)
+ Vector.elements(els, false)
end
alias map collect
@@ -967,7 +967,7 @@ class Vector
|v1, v2|
yield v1, v2
}
- Vector.elements(els, FALSE)
+ Vector.elements(els, false)
end
def r
diff --git a/lib/net/ftp.rb b/lib/net/ftp.rb
index 3c2d97c3b3..a40b3532b1 100644
--- a/lib/net/ftp.rb
+++ b/lib/net/ftp.rb
@@ -377,7 +377,7 @@ module Net
end
end
- def putbinaryfile(localfile, remotefile, blocksize, callback = nil)
+ def putbinaryfile(localfile, remotefile, blocksize = 4096, callback = nil)
if iterator?
callback = Proc.new
end
@@ -635,7 +635,7 @@ module Net
host = (@sock.peeraddr())[3]
return host, port
end
- private :parse228
+ private :parse229
def parse257(resp)
if resp[0, 3] != "257"
diff --git a/lib/tracer.rb b/lib/tracer.rb
index 8ee14ce378..78bada9a65 100644
--- a/lib/tracer.rb
+++ b/lib/tracer.rb
@@ -17,10 +17,10 @@ class Tracer
@RCS_ID='-$Id: tracer.rb,v 1.8 1998/05/19 03:42:49 keiju Exp keiju $-'
class << self
- attr :verbose, TRUE
+ attr :verbose, true
alias verbose? verbose
end
- verbose = TRUE
+ verbose = true
MY_FILE_NAME = caller(0)[0].scan(/^(.*):[0-9]+$/)[0][0]
@@ -114,14 +114,14 @@ class Tracer
return unless p.call event, file, line, id, binding
end
- Thread.critical = TRUE
+ Thread.critical = true
printf("#%d:%s:%d:%s: %s",
get_thread_no,
file,
line,
EVENT_SYMBOL[event],
get_line(file, line))
- Thread.critical = FALSE
+ Thread.critical = false
end
Single = new
diff --git a/lib/weakref.rb b/lib/weakref.rb
index 18b530f2ae..a6519e64c0 100644
--- a/lib/weakref.rb
+++ b/lib/weakref.rb
@@ -19,18 +19,24 @@ class WeakRef<Delegator
ID_MAP = {} # obj -> [ref,...]
ID_REV_MAP = {} # ref -> obj
ObjectSpace.add_finalizer(lambda{|id|
- rids = ID_MAP[id]
- if rids
- for rid in rids
- ID_REV_MAP[rid] = nil
+ __old_status = Thread.critical
+ Thread.critical = true
+ begin
+ rids = ID_MAP[id]
+ if rids
+ for rid in rids
+ ID_REV_MAP[rid] = nil
+ end
+ ID_MAP[id] = nil
end
- ID_MAP[id] = nil
- end
- rid = ID_REV_MAP[id]
- if rid
- ID_REV_MAP[id] = nil
- ID_MAP[rid].delete(id)
- ID_MAP[rid] = nil if ID_MAP[rid].empty?
+ rid = ID_REV_MAP[id]
+ if rid
+ ID_REV_MAP[id] = nil
+ ID_MAP[rid].delete(id)
+ ID_MAP[rid] = nil if ID_MAP[rid].empty?
+ end
+ ensure
+ Thread.critical = __old_status
end
})