* 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
This commit is contained in:
matz 2003-07-09 22:28:42 +00:00
Родитель d54accfe3f
Коммит 662e3cf1f9
11 изменённых файлов: 111 добавлений и 46 удалений

Просмотреть файл

@ -9,19 +9,41 @@ Wed Jul 9 15:38:28 2003 WATANABE Hirofumi <eban@ruby-lang.org>
* mkconfig.rb: support text-mount on Cygwin. * 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. * 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> 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 * ext/dbm/extconf.rb (gdbm_compat, qdbm): add check for gdbm_compat
and qdbm. 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> 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. * 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 * eval.c (rb_mod_remove_method): allow "remove_method" to accept
multiple arguments. 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> 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, * ext/syck/rubyext.c, ext/syck/syck.c, ext/syck/syck.h,

Просмотреть файл

@ -647,8 +647,11 @@ rb_big2str(x, base)
break; break;
} }
j += 2; j += 2;
hbase = base * base; hbase = base * base;
#if SIZEOF_BDIGITS > 2
hbase *= hbase; hbase *= hbase;
#endif
t = rb_big_clone(x); t = rb_big_clone(x);
ds = BDIGITS(t); ds = BDIGITS(t);
@ -666,7 +669,7 @@ rb_big2str(x, base)
num %= hbase; num %= hbase;
} }
if (ds[i-1] == 0) i--; if (ds[i-1] == 0) i--;
k = 4; k = SIZEOF_BDIGITS;
while (k--) { while (k--) {
c = (char)(num % base); c = (char)(num % base);
s[--j] = ruby_digitmap[(int)c]; s[--j] = ruby_digitmap[(int)c];
@ -839,7 +842,10 @@ rb_big2dbl(x)
while (i--) { while (i--) {
d = ds[i] + BIGRAD*d; 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; if (!RBIGNUM(x)->sign) d = -d;
return d; return d;
} }

12
eval.c
Просмотреть файл

@ -5339,10 +5339,15 @@ compile(src, file, line)
int line; int line;
{ {
NODE *node; NODE *node;
int critical;
ruby_nerrs = 0; ruby_nerrs = 0;
StringValue(src); StringValue(src);
critical = rb_thread_critical;
rb_thread_critical = Qtrue;
node = rb_compile_string(file, src, line); node = rb_compile_string(file, src, line);
rb_thread_critical = critical;
if (ruby_nerrs == 0) return node; if (ruby_nerrs == 0) return node;
return 0; return 0;
@ -5747,17 +5752,22 @@ rb_load(fname, wrap)
last_func = ruby_frame->last_func; last_func = ruby_frame->last_func;
if (state == 0) { if (state == 0) {
NODE *node; NODE *node;
volatile int critical;
DEFER_INTS; DEFER_INTS;
ruby_in_eval++; ruby_in_eval++;
critical = rb_thread_critical;
rb_thread_critical = Qtrue;
rb_load_file(RSTRING(fname)->ptr); rb_load_file(RSTRING(fname)->ptr);
ruby_in_eval--; ruby_in_eval--;
node = ruby_eval_tree; node = ruby_eval_tree;
ALLOW_INTS; ALLOW_INTS;
rb_thread_critical = critical;
if (ruby_nerrs == 0) { if (ruby_nerrs == 0) {
eval_node(self, node); eval_node(self, node);
} }
} }
ALLOW_INTS;
ruby_frame->last_func = last_func; ruby_frame->last_func = last_func;
if (ruby_scope->flags == SCOPE_ALLOCA && ruby_class == rb_cObject) { if (ruby_scope->flags == SCOPE_ALLOCA && ruby_class == rb_cObject) {
if (ruby_scope->local_tbl) /* toplevel was empty */ if (ruby_scope->local_tbl) /* toplevel was empty */
@ -8440,6 +8450,7 @@ rb_thread_schedule()
rb_thread_t curr; rb_thread_t curr;
int found = 0; int found = 0;
if (ruby_in_compile) abort();
fd_set readfds; fd_set readfds;
fd_set writefds; fd_set writefds;
fd_set exceptfds; fd_set exceptfds;
@ -8680,6 +8691,7 @@ rb_thread_wait_fd(fd)
int fd; int fd;
{ {
if (rb_thread_critical) return; if (rb_thread_critical) return;
if (ruby_in_compile) return;
if (curr_thread == curr_thread->next) return; if (curr_thread == curr_thread->next) return;
if (curr_thread->status == THREAD_TO_KILL) return; if (curr_thread->status == THREAD_TO_KILL) return;

Просмотреть файл

@ -8,7 +8,7 @@ module REXML
if match if match
ENCODING_CLAIMS[ match ] = encoding_str ENCODING_CLAIMS[ match ] = encoding_str
else 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
end end
@ -21,7 +21,9 @@ module REXML
attr_reader :encoding attr_reader :encoding
def encoding=( enc ) def encoding=( enc )
enc = UTF_8 unless enc enc = UTF_8 unless enc
@encoding = enc.upcase rv = ENCODING_CLAIMS.find{|k,v| /#{v}/i =~ enc }
enc = rv[1] if rv
@encoding = enc
require "rexml/encodings/#@encoding" unless @encoding == UTF_8 require "rexml/encodings/#@encoding" unless @encoding == UTF_8
end end

Просмотреть файл

@ -13,5 +13,20 @@ begin
end end
end end
rescue LoadError 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 end

Просмотреть файл

@ -3,15 +3,30 @@ begin
module REXML module REXML
module Encoding module Encoding
def to_shift_jis content def from_shift_jis(str)
Uconv::u8tosjis(content) Uconv::u8tosjis(content)
end end
def from_shift_jis(str) def to_shift_jis content
Uconv::sjistou8(str) Uconv::sjistou8(str)
end end
end end
end end
rescue LoadError 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 end

Просмотреть файл

@ -1,17 +1 @@
begin require 'rexml/encodings/Shift-JIS'
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

Просмотреть файл

@ -1140,6 +1140,10 @@ rb_cstr_to_dbl(p, badcheck)
while (ISSPACE(*p) || *p == '_') p++; while (ISSPACE(*p) || *p == '_') p++;
} }
d = strtod(p, &end); d = strtod(p, &end);
if (errno == ERANGE) {
rb_warn("Float %*s out of range", end-p, p);
errno = 0;
}
if (p == end) { if (p == end) {
if (badcheck) { if (badcheck) {
bad: bad:
@ -1170,6 +1174,10 @@ rb_cstr_to_dbl(p, badcheck)
*n = '\0'; *n = '\0';
p = buf; p = buf;
d = strtod(p, &end); d = strtod(p, &end);
if (errno == ERANGE) {
rb_warn("Float %*s out of range", end-p, p);
errno = 0;
}
if (badcheck) { if (badcheck) {
if (p == end) goto bad; if (p == end) goto bad;
while (*end && ISSPACE(*end)) end++; while (*end && ISSPACE(*end)) end++;

2
pack.c
Просмотреть файл

@ -1876,7 +1876,7 @@ utf8_to_uv(p, lenp)
long *lenp; long *lenp;
{ {
int c = *p++ & 0xff; int c = *p++ & 0xff;
unsigned LONG_LONG uv = c; unsigned long uv = c;
long n; long n;
if (!(uv & 0x80)) { if (!(uv & 0x80)) {

15
util.c
Просмотреть файл

@ -665,11 +665,8 @@ ruby_getcwd()
#define TRUE 1 #define TRUE 1
#define FALSE 0 #define FALSE 0
static int maxExponent = 511; /* Largest possible base 10 exponent. Any static int MDMINEXPT = -323;
* exponent larger than this will already static int MDMAXEXPT = 309;
* produce underflow or overflow, so there's
* no need to worry about additional digits.
*/
static double powersOf10[] = { /* Table giving binary powers of 10. Entry */ static double powersOf10[] = { /* Table giving binary powers of 10. Entry */
10.0, /* is 10^2^i. Used to convert decimal */ 10.0, /* is 10^2^i. Used to convert decimal */
100.0, /* exponents into floating-point numbers. */ 100.0, /* exponents into floating-point numbers. */
@ -862,12 +859,12 @@ ruby_strtod(string, endPtr)
* fraction. * fraction.
*/ */
if (exp > maxExponent) { if (exp > MDMAXEXPT - 18) {
exp = maxExponent; exp = MDMAXEXPT;
errno = ERANGE; errno = ERANGE;
} }
else if (exp < -maxExponent) { else if (exp < MDMINEXPT + 18) {
exp = -maxExponent; exp = MDMINEXPT;
errno = ERANGE; errno = ERANGE;
} }
fracExp = exp; fracExp = exp;

Просмотреть файл

@ -1284,15 +1284,15 @@ rb_const_get_0(klass, id, exclude)
tmp = klass; tmp = klass;
retry: retry:
while (tmp) { 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)) { while (RCLASS(tmp)->iv_tbl && st_lookup(RCLASS(tmp)->iv_tbl,id,&value)) {
if (value == Qundef) { if (value == Qundef) {
rb_autoload_load(tmp, id); rb_autoload_load(tmp, id);
continue; 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; return value;
} }
tmp = RCLASS(tmp)->super; tmp = RCLASS(tmp)->super;