summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-07-09 22:28:42 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-07-09 22:28:42 +0000
commit662e3cf1f94bb50f6a27568c7526f867956e5b55 (patch)
treec2aa80d7fdd9598fcd612e59d6373f97b893dc21
parentd54accfe3ff3fd8a139cc7b899fc1e20104dcc97 (diff)
downloadruby-662e3cf1f94bb50f6a27568c7526f867956e5b55.tar.gz
* eval.c (rb_load): put rb_load_file() in a thread critical
section. [ruby-dev:20490] * eval.c (compile): put rb_compile_string() in a thread critical section. * variable.c (rb_const_get_0): should not warn if constant is not defined. (ruby-bugs-ja PR#509) * bignum.c (rb_big2dbl): give a warning on overflow. (ruby-bugs-ja PR#510) * util.c (ruby_strtod): change MDMAXEXPT from 511 to 308. * pack.c (utf8_to_uv): long is sufficient. LONG_LONG is not required. * bignum.c (rb_big2str): support 32 bit (without `long long' type) machines. (ruby-bugs-ja PR#512) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4050 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog36
-rw-r--r--bignum.c10
-rw-r--r--eval.c12
-rw-r--r--lib/rexml/encoding.rb10
-rw-r--r--lib/rexml/encodings/EUC-JP.rb17
-rw-r--r--lib/rexml/encodings/Shift-JIS.rb21
-rw-r--r--lib/rexml/encodings/Shift_JIS.rb18
-rw-r--r--object.c8
-rw-r--r--pack.c2
-rw-r--r--util.c15
-rw-r--r--variable.c8
11 files changed, 111 insertions, 46 deletions
diff --git a/ChangeLog b/ChangeLog
index 965a5e1d86..f00f4d796c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -9,19 +9,41 @@ Wed Jul 9 15:38:28 2003 WATANABE Hirofumi <eban@ruby-lang.org>
* mkconfig.rb: support text-mount on Cygwin.
-Wed Jul 09 11:09:57 2003 NAKAMURA Usaku <usa@ruby-lang.org>
+Wed Jul 9 11:09:57 2003 NAKAMURA Usaku <usa@ruby-lang.org>
* re.c (match_entry): add prototype to avoid VC++ warnings.
+Wed Jul 9 03:48:27 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_load): put rb_load_file() in a thread critical
+ section. [ruby-dev:20490]
+
+ * eval.c (compile): put rb_compile_string() in a thread critical
+ section.
+
+Tue Jul 8 02:35:41 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * variable.c (rb_const_get_0): should not warn if constant is not
+ defined. (ruby-bugs-ja PR#509)
+
+ * bignum.c (rb_big2dbl): give a warning on overflow.
+ (ruby-bugs-ja PR#510)
+
+ * util.c (ruby_strtod): change MDMAXEXPT from 511 to 308.
+
+ * pack.c (utf8_to_uv): long is sufficient. LONG_LONG is not
+ required.
+
+Tue Jul 8 01:43:16 2003 Koji Arai <jca02266@nifty.ne.jp>
+
+ * bignum.c (rb_big2str): support 32 bit (without `long long' type)
+ machines. (ruby-bugs-ja PR#512)
+
Mon Jul 7 10:22:46 2003 WATANABE Hirofumi <eban@ruby-lang.org>
* ext/dbm/extconf.rb (gdbm_compat, qdbm): add check for gdbm_compat
and qdbm.
-Sat Jul 5 00:22:59 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * node.h (NEW_NODE): cast arguments to rb_node_newnode().
-
Mon Jul 7 01:34:49 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_call_super): k->super maybe NULL if klass is Kernel.
@@ -34,6 +56,10 @@ Sat Jul 5 23:32:06 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_mod_remove_method): allow "remove_method" to accept
multiple arguments.
+Sat Jul 5 00:22:59 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * node.h (NEW_NODE): cast arguments to rb_node_newnode().
+
Fri Jul 4 21:48:44 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* ext/syck/rubyext.c, ext/syck/syck.c, ext/syck/syck.h,
diff --git a/bignum.c b/bignum.c
index 5992662d42..9839f552fb 100644
--- a/bignum.c
+++ b/bignum.c
@@ -647,8 +647,11 @@ rb_big2str(x, base)
break;
}
j += 2;
+
hbase = base * base;
+#if SIZEOF_BDIGITS > 2
hbase *= hbase;
+#endif
t = rb_big_clone(x);
ds = BDIGITS(t);
@@ -666,7 +669,7 @@ rb_big2str(x, base)
num %= hbase;
}
if (ds[i-1] == 0) i--;
- k = 4;
+ k = SIZEOF_BDIGITS;
while (k--) {
c = (char)(num % base);
s[--j] = ruby_digitmap[(int)c];
@@ -839,7 +842,10 @@ rb_big2dbl(x)
while (i--) {
d = ds[i] + BIGRAD*d;
}
- if (isinf(d)) d = HUGE_VAL;
+ if (isinf(d)) {
+ rb_warn("Bignum out of Float range");
+ d = HUGE_VAL;
+ }
if (!RBIGNUM(x)->sign) d = -d;
return d;
}
diff --git a/eval.c b/eval.c
index 605d4f8ea4..47853d686a 100644
--- a/eval.c
+++ b/eval.c
@@ -5339,10 +5339,15 @@ compile(src, file, line)
int line;
{
NODE *node;
+ int critical;
ruby_nerrs = 0;
StringValue(src);
+ critical = rb_thread_critical;
+ rb_thread_critical = Qtrue;
node = rb_compile_string(file, src, line);
+ rb_thread_critical = critical;
+
if (ruby_nerrs == 0) return node;
return 0;
@@ -5747,17 +5752,22 @@ rb_load(fname, wrap)
last_func = ruby_frame->last_func;
if (state == 0) {
NODE *node;
+ volatile int critical;
DEFER_INTS;
ruby_in_eval++;
+ critical = rb_thread_critical;
+ rb_thread_critical = Qtrue;
rb_load_file(RSTRING(fname)->ptr);
ruby_in_eval--;
node = ruby_eval_tree;
ALLOW_INTS;
+ rb_thread_critical = critical;
if (ruby_nerrs == 0) {
eval_node(self, node);
}
}
+ ALLOW_INTS;
ruby_frame->last_func = last_func;
if (ruby_scope->flags == SCOPE_ALLOCA && ruby_class == rb_cObject) {
if (ruby_scope->local_tbl) /* toplevel was empty */
@@ -8440,6 +8450,7 @@ rb_thread_schedule()
rb_thread_t curr;
int found = 0;
+ if (ruby_in_compile) abort();
fd_set readfds;
fd_set writefds;
fd_set exceptfds;
@@ -8680,6 +8691,7 @@ rb_thread_wait_fd(fd)
int fd;
{
if (rb_thread_critical) return;
+ if (ruby_in_compile) return;
if (curr_thread == curr_thread->next) return;
if (curr_thread->status == THREAD_TO_KILL) return;
diff --git a/lib/rexml/encoding.rb b/lib/rexml/encoding.rb
index 3d7dcd6260..2d62e49fac 100644
--- a/lib/rexml/encoding.rb
+++ b/lib/rexml/encoding.rb
@@ -8,7 +8,7 @@ module REXML
if match
ENCODING_CLAIMS[ match ] = encoding_str
else
- ENCODING_CLAIMS[ /^\s*<?xml\s*version=(['"]).*?\1\s*encoding=(["'])#{encoding_str}\2/ ] = encoding_str
+ ENCODING_CLAIMS[ /^\s*<?xml\s*version=(['"]).*?\1\s*encoding=(["'])#{encoding_str}\2/i ] = encoding_str
end
end
@@ -20,9 +20,11 @@ module REXML
# ID ---> Encoding name
attr_reader :encoding
def encoding=( enc )
- enc = UTF_8 unless enc
- @encoding = enc.upcase
- require "rexml/encodings/#@encoding" unless @encoding == UTF_8
+ enc = UTF_8 unless enc
+ rv = ENCODING_CLAIMS.find{|k,v| /#{v}/i =~ enc }
+ enc = rv[1] if rv
+ @encoding = enc
+ require "rexml/encodings/#@encoding" unless @encoding == UTF_8
end
def check_encoding str
diff --git a/lib/rexml/encodings/EUC-JP.rb b/lib/rexml/encodings/EUC-JP.rb
index cedd6751e7..23a1c3c657 100644
--- a/lib/rexml/encodings/EUC-JP.rb
+++ b/lib/rexml/encodings/EUC-JP.rb
@@ -13,5 +13,20 @@ begin
end
end
rescue LoadError
- raise "uconv is required for Japanese encoding support."
+ begin
+ require 'iconv'
+ module REXML
+ module Encoding
+ def from_euc_jp(str)
+ return Iconv::iconv("utf-8", "euc-jp", str)[0]
+ end
+
+ def to_euc_jp content
+ return Iconv::iconv("euc-jp", "utf-8", content)[0]
+ end
+ end
+ end
+ rescue LoadError
+ raise "uconv or iconv is required for Japanese encoding support."
+ end
end
diff --git a/lib/rexml/encodings/Shift-JIS.rb b/lib/rexml/encodings/Shift-JIS.rb
index 8650174538..e805456ea7 100644
--- a/lib/rexml/encodings/Shift-JIS.rb
+++ b/lib/rexml/encodings/Shift-JIS.rb
@@ -3,15 +3,30 @@ begin
module REXML
module Encoding
- def to_shift_jis content
+ def from_shift_jis(str)
Uconv::u8tosjis(content)
end
- def from_shift_jis(str)
+ def to_shift_jis content
Uconv::sjistou8(str)
end
end
end
rescue LoadError
- raise "uconv is required for Japanese encoding support."
+ begin
+ require 'iconv'
+ module REXML
+ module Encoding
+ def from_shift_jis(str)
+ return Iconv::iconv("utf-8", "shift-jis", str)[0]
+ end
+
+ def to_shift_jis content
+ return Iconv::iconv("euc-jp", "shift-jis", content)[0]
+ end
+ end
+ end
+ rescue LoadError
+ raise "uconv or iconv is required for Japanese encoding support."
+ end
end
diff --git a/lib/rexml/encodings/Shift_JIS.rb b/lib/rexml/encodings/Shift_JIS.rb
index 8650174538..6e8f759373 100644
--- a/lib/rexml/encodings/Shift_JIS.rb
+++ b/lib/rexml/encodings/Shift_JIS.rb
@@ -1,17 +1 @@
-begin
- require 'uconv'
-
- module REXML
- module Encoding
- def to_shift_jis content
- Uconv::u8tosjis(content)
- end
-
- def from_shift_jis(str)
- Uconv::sjistou8(str)
- end
- end
- end
-rescue LoadError
- raise "uconv is required for Japanese encoding support."
-end
+require 'rexml/encodings/Shift-JIS'
diff --git a/object.c b/object.c
index 0e1c1a72ab..7e8b5e68e1 100644
--- a/object.c
+++ b/object.c
@@ -1140,6 +1140,10 @@ rb_cstr_to_dbl(p, badcheck)
while (ISSPACE(*p) || *p == '_') p++;
}
d = strtod(p, &end);
+ if (errno == ERANGE) {
+ rb_warn("Float %*s out of range", end-p, p);
+ errno = 0;
+ }
if (p == end) {
if (badcheck) {
bad:
@@ -1170,6 +1174,10 @@ rb_cstr_to_dbl(p, badcheck)
*n = '\0';
p = buf;
d = strtod(p, &end);
+ if (errno == ERANGE) {
+ rb_warn("Float %*s out of range", end-p, p);
+ errno = 0;
+ }
if (badcheck) {
if (p == end) goto bad;
while (*end && ISSPACE(*end)) end++;
diff --git a/pack.c b/pack.c
index 86726518ce..6df527605a 100644
--- a/pack.c
+++ b/pack.c
@@ -1876,7 +1876,7 @@ utf8_to_uv(p, lenp)
long *lenp;
{
int c = *p++ & 0xff;
- unsigned LONG_LONG uv = c;
+ unsigned long uv = c;
long n;
if (!(uv & 0x80)) {
diff --git a/util.c b/util.c
index 9a3ce69c2c..ae2bc8de92 100644
--- a/util.c
+++ b/util.c
@@ -665,11 +665,8 @@ ruby_getcwd()
#define TRUE 1
#define FALSE 0
-static int maxExponent = 511; /* Largest possible base 10 exponent. Any
- * exponent larger than this will already
- * produce underflow or overflow, so there's
- * no need to worry about additional digits.
- */
+static int MDMINEXPT = -323;
+static int MDMAXEXPT = 309;
static double powersOf10[] = { /* Table giving binary powers of 10. Entry */
10.0, /* is 10^2^i. Used to convert decimal */
100.0, /* exponents into floating-point numbers. */
@@ -862,12 +859,12 @@ ruby_strtod(string, endPtr)
* fraction.
*/
- if (exp > maxExponent) {
- exp = maxExponent;
+ if (exp > MDMAXEXPT - 18) {
+ exp = MDMAXEXPT;
errno = ERANGE;
}
- else if (exp < -maxExponent) {
- exp = -maxExponent;
+ else if (exp < MDMINEXPT + 18) {
+ exp = MDMINEXPT;
errno = ERANGE;
}
fracExp = exp;
diff --git a/variable.c b/variable.c
index 8b62aad92a..6aa98035f1 100644
--- a/variable.c
+++ b/variable.c
@@ -1284,15 +1284,15 @@ rb_const_get_0(klass, id, exclude)
tmp = klass;
retry:
while (tmp) {
- if (exclude && tmp == rb_cObject && klass != rb_cObject) {
- rb_warn("toplevel constant %s referenced by %s::%s",
- rb_id2name(id), rb_class2name(klass), rb_id2name(id));
- }
while (RCLASS(tmp)->iv_tbl && st_lookup(RCLASS(tmp)->iv_tbl,id,&value)) {
if (value == Qundef) {
rb_autoload_load(tmp, id);
continue;
}
+ if (exclude && tmp == rb_cObject && klass != rb_cObject) {
+ rb_warn("toplevel constant %s referenced by %s::%s",
+ rb_id2name(id), rb_class2name(klass), rb_id2name(id));
+ }
return value;
}
tmp = RCLASS(tmp)->super;