зеркало из https://github.com/github/ruby.git
* eval.c (rb_provide_feature): should not tweak extension used for
loading. * io.c (io_fread): use fread(3) if PENDING_COUND is available. * class.c (rb_mod_include_p): Module#include? added. [new] * re.c (ignorecase_setter): give warning on modifying $=. * string.c (rb_str_casecmp): new method. [new] * string.c (rb_str_eql): separated from rb_str_equal(), make it always be case sensitive. [new] * string.c (rb_str_hash): made it always be case sensitive. * eval.c (rb_f_require): should not include path in $" value * file.c (rb_find_file): should return 0 explicitly on failure. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1642 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
9e214f30c4
Коммит
15ffbb1f82
30
ChangeLog
30
ChangeLog
|
@ -1,15 +1,45 @@
|
|||
Mon Jul 23 00:26:04 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* eval.c (rb_provide_feature): should not tweak extension used for
|
||||
loading.
|
||||
|
||||
Sun Jul 22 21:16:43 2001 Akinori MUSHA <knu@iDaemons.org>
|
||||
|
||||
* ext/extmk.rb.in, lib/mkmf.rb: introduce a couple of new make
|
||||
variables: CLEANFILES and DISTCLEANFILES. They'd typically be
|
||||
defined in a file "depend".
|
||||
|
||||
Sat Jul 21 09:40:10 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
|
||||
|
||||
* io.c (io_fread): use fread(3) if PENDING_COUND is available.
|
||||
|
||||
Fri Jul 20 22:55:01 2001 Akinori MUSHA <knu@iDaemons.org>
|
||||
|
||||
* gc.c (ruby_xrealloc): fix a dangling bug which led memory
|
||||
reallocation to fail even though the second try after a GC
|
||||
succeeds.
|
||||
|
||||
Fri Jul 20 03:00:46 2001 Akinori MUSHA <knu@iDaemons.org>
|
||||
|
||||
* class.c (rb_mod_include_p): Module#include? added. [new]
|
||||
|
||||
Fri Jul 20 01:05:50 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* re.c (ignorecase_setter): give warning on modifying $=.
|
||||
|
||||
* string.c (rb_str_casecmp): new method. [new]
|
||||
|
||||
* string.c (rb_str_eql): separated from rb_str_equal(), make it
|
||||
always be case sensitive. [new]
|
||||
|
||||
* string.c (rb_str_hash): made it always be case sensitive.
|
||||
|
||||
Thu Jul 19 13:03:15 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
|
||||
|
||||
* eval.c (rb_f_require): should not include path in $" value
|
||||
|
||||
* file.c (rb_find_file): should return 0 explicitly on failure.
|
||||
|
||||
Tue Jul 17 11:44:40 2001 Usaku Nakamura <usa@osb.att.ne.jp>
|
||||
|
||||
* ruby.h: enable volatile directive with VC++.
|
||||
|
|
1
ToDo
1
ToDo
|
@ -26,6 +26,7 @@ Language Spec.
|
|||
* to_i returns nil if str contains no digit.
|
||||
* raise exception by `` error
|
||||
* jar like combined library package.
|
||||
* resumable Exception via Exception#resume.
|
||||
|
||||
Hacking Interpreter
|
||||
|
||||
|
|
16
class.c
16
class.c
|
@ -343,6 +343,22 @@ rb_mod_included_modules(mod)
|
|||
return ary;
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_mod_include_p(mod, mod2)
|
||||
VALUE mod;
|
||||
VALUE mod2;
|
||||
{
|
||||
VALUE p;
|
||||
|
||||
Check_Type(mod2, T_MODULE);
|
||||
for (p = RCLASS(mod)->super; p; p = RCLASS(p)->super) {
|
||||
if (BUILTIN_TYPE(p) == T_ICLASS) {
|
||||
if (RBASIC(p)->klass == mod2) return Qtrue;
|
||||
}
|
||||
}
|
||||
return Qfalse;
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_mod_ancestors(mod)
|
||||
VALUE mod;
|
||||
|
|
35
eval.c
35
eval.c
|
@ -5392,19 +5392,6 @@ static void
|
|||
rb_provide_feature(feature)
|
||||
VALUE feature;
|
||||
{
|
||||
char *ext;
|
||||
char *f = RSTRING(feature)->ptr;
|
||||
|
||||
ext = strrchr(f, '.');
|
||||
if (ext && (strcmp(DLEXT, ext) == 0
|
||||
#ifdef DLEXT2
|
||||
|| strcmp(DLEXT2, ext) == 0
|
||||
#endif
|
||||
)) {
|
||||
feature = rb_str_new(RSTRING(feature)->ptr, ext-RSTRING(feature)->ptr);
|
||||
rb_str_cat2(feature, ".so");
|
||||
}
|
||||
if (rb_feature_p(RSTRING(feature)->ptr, Qtrue)) return;
|
||||
rb_ary_push(rb_features, feature);
|
||||
}
|
||||
|
||||
|
@ -5440,19 +5427,19 @@ rb_f_require(obj, fname)
|
|||
}
|
||||
else if (strcmp(".so", ext) == 0 || strcmp(".o", ext) == 0) {
|
||||
fname = rb_str_new(RSTRING(fname)->ptr, ext-RSTRING(fname)->ptr);
|
||||
tmp = rb_str_dup(fname);
|
||||
feature = tmp = rb_str_dup(fname);
|
||||
rb_str_cat2(tmp, DLEXT);
|
||||
tmp = rb_find_file(tmp);
|
||||
if (tmp) {
|
||||
feature = fname = tmp;
|
||||
fname = tmp;
|
||||
goto load_dyna;
|
||||
}
|
||||
#ifdef DLEXT2
|
||||
tmp = rb_str_dup(fname);
|
||||
feature = tmp = rb_str_dup(fname);
|
||||
rb_str_cat2(tmp, DLEXT);
|
||||
tmp = rb_find_file(tmp);
|
||||
if (tmp) {
|
||||
feature = fname = tmp;
|
||||
fname = tmp;
|
||||
goto load_dyna;
|
||||
}
|
||||
#endif
|
||||
|
@ -5460,7 +5447,8 @@ rb_f_require(obj, fname)
|
|||
else if (strcmp(DLEXT, ext) == 0) {
|
||||
tmp = rb_find_file(fname);
|
||||
if (tmp) {
|
||||
feature = fname = tmp;
|
||||
feature = fname;
|
||||
fname = tmp;
|
||||
goto load_dyna;
|
||||
}
|
||||
}
|
||||
|
@ -5468,7 +5456,8 @@ rb_f_require(obj, fname)
|
|||
else if (strcmp(DLEXT2, ext) == 0) {
|
||||
tmp = rb_find_file(fname);
|
||||
if (tmp) {
|
||||
feature = fname = tmp;
|
||||
feature = fname;
|
||||
fname = tmp;
|
||||
goto load_dyna;
|
||||
}
|
||||
}
|
||||
|
@ -5480,17 +5469,15 @@ rb_f_require(obj, fname)
|
|||
break;
|
||||
|
||||
case 1:
|
||||
feature = fname;
|
||||
fname = tmp;
|
||||
feature = fname = tmp;
|
||||
goto load_rb;
|
||||
|
||||
default:
|
||||
feature = fname;
|
||||
feature = tmp;
|
||||
fname = rb_find_file(tmp);
|
||||
goto load_dyna;
|
||||
}
|
||||
rb_raise(rb_eLoadError, "No such file to load -- %s",
|
||||
RSTRING(fname)->ptr);
|
||||
rb_raise(rb_eLoadError, "No such file to load -- %s", RSTRING(fname)->ptr);
|
||||
|
||||
load_dyna:
|
||||
rb_provide_feature(feature);
|
||||
|
|
1
file.c
1
file.c
|
@ -2348,6 +2348,7 @@ rb_find_file(path)
|
|||
if (file_load_ok(f)) {
|
||||
return rb_str_new2(f);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
2
hash.c
2
hash.c
|
@ -388,7 +388,7 @@ rb_hash_indexes(argc, argv, hash)
|
|||
return indexes;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
VALUE
|
||||
rb_hash_delete(hash, key)
|
||||
VALUE hash, key;
|
||||
{
|
||||
|
|
3
intern.h
3
intern.h
|
@ -90,6 +90,7 @@ VALUE rb_define_class_id _((ID, VALUE));
|
|||
VALUE rb_module_new _((void));
|
||||
VALUE rb_define_module_id _((ID));
|
||||
VALUE rb_mod_included_modules _((VALUE));
|
||||
VALUE rb_mod_include_p _((VALUE, VALUE));
|
||||
VALUE rb_mod_ancestors _((VALUE));
|
||||
VALUE rb_class_instance_methods _((int, VALUE*, VALUE));
|
||||
VALUE rb_class_protected_instance_methods _((int, VALUE*, VALUE));
|
||||
|
@ -201,6 +202,7 @@ VALUE rb_hash_freeze _((VALUE));
|
|||
VALUE rb_hash_aref _((VALUE, VALUE));
|
||||
VALUE rb_hash_aset _((VALUE, VALUE, VALUE));
|
||||
VALUE rb_hash_delete_if _((VALUE));
|
||||
VALUE rb_hash_delete _((VALUE,VALUE));
|
||||
int rb_path_check _((char *));
|
||||
int rb_env_path_tainted _((void));
|
||||
/* io.c */
|
||||
|
@ -281,6 +283,7 @@ VALUE rb_range_beg_len _((VALUE, long*, long*, long, int));
|
|||
VALUE rb_length_by_each _((VALUE));
|
||||
/* re.c */
|
||||
int rb_memcmp _((char*,char*,long));
|
||||
int rb_memcicmp _((char*,char*,long));
|
||||
VALUE rb_reg_nth_defined _((int, VALUE));
|
||||
VALUE rb_reg_nth_match _((int, VALUE));
|
||||
VALUE rb_reg_last_match _((VALUE));
|
||||
|
|
28
io.c
28
io.c
|
@ -108,11 +108,14 @@ static VALUE lineno;
|
|||
#ifdef _STDIO_USES_IOSTREAM /* GNU libc */
|
||||
# ifdef _IO_fpos_t
|
||||
# define READ_DATA_PENDING(fp) ((fp)->_IO_read_ptr != (fp)->_IO_read_end)
|
||||
# define READ_DATA_PENDING_COUNT(fp) ((fp)->_IO_read_end - (fp)->_IO_read_ptr)
|
||||
# else
|
||||
# define READ_DATA_PENDING(fp) ((fp)->_gptr < (fp)->_egptr)
|
||||
# define READ_DATA_PENDING_COUNT(fp) ((fp)->_egptr - (fp)->_gptr)
|
||||
# endif
|
||||
#elif defined(FILE_COUNT)
|
||||
# define READ_DATA_PENDING(fp) ((fp)->FILE_COUNT > 0)
|
||||
# define READ_DATA_PENDING_COUNT(fp) ((fp)->FILE_COUNT)
|
||||
#elif defined(__BEOS__)
|
||||
# define READ_DATA_PENDING(fp) (fp->_state._eof == 0)
|
||||
#else
|
||||
|
@ -476,14 +479,34 @@ io_fread(ptr, len, f)
|
|||
long n = len;
|
||||
int c;
|
||||
|
||||
while (n--) {
|
||||
while (n > 0) {
|
||||
#ifdef READ_DATA_PENDING_COUNT
|
||||
int i = READ_DATA_PENDING_COUNT(f);
|
||||
if (i <= 0) {
|
||||
rb_thread_wait_fd(fileno(f));
|
||||
i = READ_DATA_PENDING_COUNT(f);
|
||||
}
|
||||
if (i > 0) {
|
||||
if (i > n) i = n;
|
||||
TRAP_BEG;
|
||||
c = fread(ptr, 1, i, f);
|
||||
TRAP_END;
|
||||
if (c < 0) goto eof;
|
||||
ptr += c;
|
||||
n -= c;
|
||||
if (c < i) goto eof;
|
||||
continue;
|
||||
}
|
||||
#else
|
||||
if (!READ_DATA_PENDING(f)) {
|
||||
rb_thread_wait_fd(fileno(f));
|
||||
}
|
||||
#endif
|
||||
TRAP_BEG;
|
||||
c = getc(f);
|
||||
TRAP_END;
|
||||
if (c == EOF) {
|
||||
eof:
|
||||
if (ferror(f)) {
|
||||
if (errno == EINTR) continue;
|
||||
rb_sys_fail(0);
|
||||
|
@ -492,9 +515,10 @@ io_fread(ptr, len, f)
|
|||
break;
|
||||
}
|
||||
*ptr++ = c;
|
||||
n--;
|
||||
}
|
||||
|
||||
return len - n - 1;
|
||||
return len - n;
|
||||
}
|
||||
|
||||
#ifndef S_ISREG
|
||||
|
|
|
@ -70,6 +70,7 @@ do_coerce(x, y)
|
|||
VALUE a[2];
|
||||
|
||||
a[0] = *x; a[1] = *y;
|
||||
|
||||
ary = rb_rescue(coerce_body, (VALUE)a, coerce_rescue, (VALUE)a);
|
||||
if (TYPE(ary) != T_ARRAY || RARRAY(ary)->len != 2) {
|
||||
rb_raise(rb_eTypeError, "coerce must return [x, y]");
|
||||
|
|
3
object.c
3
object.c
|
@ -956,7 +956,7 @@ rb_Float(val)
|
|||
d = strtod(p, &end);
|
||||
if (p == end) {
|
||||
bad:
|
||||
rb_raise(rb_eArgError, "invalid value for Float: \"%s\"", q);
|
||||
rb_raise(rb_eArgError, "invalid value for Float(): \"%s\"", q);
|
||||
}
|
||||
if (*end) {
|
||||
if (*end == '_') {
|
||||
|
@ -1232,6 +1232,7 @@ Init_Object()
|
|||
rb_define_method(rb_cModule, "dup", rb_mod_dup, 0);
|
||||
rb_define_method(rb_cModule, "to_s", rb_mod_to_s, 0);
|
||||
rb_define_method(rb_cModule, "included_modules", rb_mod_included_modules, 0);
|
||||
rb_define_method(rb_cModule, "include?", rb_mod_include_p, 1);
|
||||
rb_define_method(rb_cModule, "name", rb_mod_name, 0);
|
||||
rb_define_method(rb_cModule, "ancestors", rb_mod_ancestors, 0);
|
||||
|
||||
|
|
25
re.c
25
re.c
|
@ -71,6 +71,20 @@ static const char casetable[] = {
|
|||
|
||||
#define MIN(a,b) (((a)>(b))?(b):(a))
|
||||
|
||||
int
|
||||
rb_memcicmp(p1, p2, len)
|
||||
char *p1, *p2;
|
||||
long len;
|
||||
{
|
||||
int tmp;
|
||||
|
||||
while (len--) {
|
||||
if (tmp = casetable[(unsigned)*p1++] - casetable[(unsigned)*p2++])
|
||||
return tmp;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
rb_memcmp(p1, p2, len)
|
||||
char *p1, *p2;
|
||||
|
@ -81,12 +95,7 @@ rb_memcmp(p1, p2, len)
|
|||
if (!ruby_ignorecase) {
|
||||
return memcmp(p1, p2, len);
|
||||
}
|
||||
|
||||
while (len--) {
|
||||
if (tmp = casetable[(unsigned)*p1++] - casetable[(unsigned)*p2++])
|
||||
return tmp;
|
||||
}
|
||||
return 0;
|
||||
return rb_memcicmp(p1, p2, len);
|
||||
}
|
||||
|
||||
#define REG_CASESTATE FL_USER0
|
||||
|
@ -1304,9 +1313,11 @@ ignorecase_getter()
|
|||
}
|
||||
|
||||
static void
|
||||
ignorecase_setter(val)
|
||||
ignorecase_setter(val, id)
|
||||
VALUE val;
|
||||
ID id;
|
||||
{
|
||||
rb_warn("modifying %s is deperecated", rb_id2name(id));
|
||||
may_need_recompile = 1;
|
||||
ruby_ignorecase = RTEST(val);
|
||||
}
|
||||
|
|
63
string.c
63
string.c
|
@ -639,30 +639,14 @@ rb_str_hash(str)
|
|||
key &= ~g;
|
||||
}
|
||||
#elif HASH_PERL
|
||||
if (ruby_ignorecase) {
|
||||
while (len--) {
|
||||
key = key*33 + toupper(*p);
|
||||
p++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
while (len--) {
|
||||
key = key*33 + *p++;
|
||||
}
|
||||
while (len--) {
|
||||
key = key*33 + *p++;
|
||||
}
|
||||
key = key + (key>>5);
|
||||
#else
|
||||
if (ruby_ignorecase) {
|
||||
while (len--) {
|
||||
key = key*65599 + toupper(*p);
|
||||
p++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
while (len--) {
|
||||
key = key*65599 + *p;
|
||||
p++;
|
||||
}
|
||||
while (len--) {
|
||||
key = key*65599 + *p;
|
||||
p++;
|
||||
}
|
||||
key = key + (key>>5);
|
||||
#endif
|
||||
|
@ -712,6 +696,20 @@ rb_str_equal(str1, str2)
|
|||
return Qfalse;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rb_str_eql(str1, str2)
|
||||
VALUE str1, str2;
|
||||
{
|
||||
if (TYPE(str2) != T_STRING || RSTRING(str1)->len != RSTRING(str2)->len)
|
||||
return Qfalse;
|
||||
|
||||
if (memcmp(RSTRING(str1)->ptr, RSTRING(str2)->ptr,
|
||||
lesser(RSTRING(str1)->len, RSTRING(str2)->len)) == 0)
|
||||
return Qtrue;
|
||||
|
||||
return Qfalse;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rb_str_cmp_m(str1, str2)
|
||||
VALUE str1, str2;
|
||||
|
@ -723,6 +721,26 @@ rb_str_cmp_m(str1, str2)
|
|||
return INT2FIX(result);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rb_str_casecmp(str1, str2)
|
||||
VALUE str1, str2;
|
||||
{
|
||||
long len;
|
||||
int retval;
|
||||
|
||||
StringValue(str2);
|
||||
len = lesser(RSTRING(str1)->len, RSTRING(str2)->len);
|
||||
retval = rb_memcicmp(RSTRING(str1)->ptr, RSTRING(str2)->ptr, len);
|
||||
if (retval == 0) {
|
||||
if (RSTRING(str1)->len == RSTRING(str2)->len) return INT2FIX(0);
|
||||
if (RSTRING(str1)->len > RSTRING(str2)->len) return INT2FIX(1);
|
||||
return INT2FIX(-1);
|
||||
}
|
||||
if (retval == 0) return INT2FIX(0);
|
||||
if (retval > 0) return INT2FIX(1);
|
||||
return INT2FIX(-1);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rb_str_match(x, y)
|
||||
VALUE x, y;
|
||||
|
@ -2934,8 +2952,9 @@ Init_String()
|
|||
rb_define_method(rb_cString, "<=>", rb_str_cmp_m, 1);
|
||||
rb_define_method(rb_cString, "==", rb_str_equal, 1);
|
||||
rb_define_method(rb_cString, "===", rb_str_equal, 1);
|
||||
rb_define_method(rb_cString, "eql?", rb_str_equal, 1);
|
||||
rb_define_method(rb_cString, "eql?", rb_str_eql, 1);
|
||||
rb_define_method(rb_cString, "hash", rb_str_hash_m, 0);
|
||||
rb_define_method(rb_cString, "casecmp", rb_str_casecmp, 1);
|
||||
rb_define_method(rb_cString, "+", rb_str_plus, 1);
|
||||
rb_define_method(rb_cString, "*", rb_str_times, 1);
|
||||
rb_define_method(rb_cString, "%", rb_str_format, 1);
|
||||
|
|
Загрузка…
Ссылка в новой задаче