mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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:
parent
d54accfe3f
commit
662e3cf1f9
11 changed files with 111 additions and 46 deletions
36
ChangeLog
36
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,
|
||||
|
|
10
bignum.c
10
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;
|
||||
}
|
||||
|
|
12
eval.c
12
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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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'
|
||||
|
|
8
object.c
8
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++;
|
||||
|
|
2
pack.c
2
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)) {
|
||||
|
|
15
util.c
15
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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue