1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* array.c (Init_Array): remove Array#filter.

* object.c (rb_mod_initialize): should accept zero argument.

* object.c (rb_mod_cmp): should raise ArgumentError if
  inheritance/inclusion relation between two classes/modules is
  not defined. [new]

* io.c (rb_io_fsync): new method. [new]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2014 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2002-01-23 07:30:43 +00:00
parent b6cc058c53
commit eb9708f386
13 changed files with 102 additions and 42 deletions

View file

@ -1,11 +1,27 @@
Wed Jan 23 16:07:31 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
* array.c (Init_Array): remove Array#filter.
Wed Jan 23 13:27:44 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
* eval.c (rb_yield_0): restore source file/line after yield.
Wed Jan 23 02:00:14 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
* object.c (rb_mod_initialize): should accept zero argument.
* object.c (rb_mod_cmp): should raise ArgumentError if
inheritance/inclusion relation between two classes/modules is
not defined. [new]
Tue Jan 22 17:45:23 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
* io.c (rb_io_fsync): new method. [new]
Mon Jan 21 22:57:18 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
* signal.c (ruby_signal): must define sighandler_t unless
POSIX_SIGNAL.
* signal.c (ruby_signal): must define sighandler_t for every
occasion.
Mon Jan 21 08:25:30 2002 Yukihiro Matsumoto <matz@ruby-lang.org>

1
ToDo
View file

@ -58,6 +58,7 @@ Hacking Interpreter
* trap every method invocation, which can be enabled by e.g. trap_call :method.
* unify Errno exceptions of same errno, or new exception comparison scheme.
* 2.times{|i| if i==0 then a = 15 else puts eval("a") end} should print nil.
* Thread#max_stack_size attribute (possible??)
Standard Libraries

View file

@ -1168,14 +1168,6 @@ rb_ary_collect_bang(ary)
return ary;
}
static VALUE
rb_ary_filter(ary)
VALUE ary;
{
rb_warn("Array#filter is deprecated; use Array#collect!");
return rb_ary_collect_bang(ary);
}
static VALUE
rb_ary_select(argc, argv, ary)
int argc;
@ -1872,7 +1864,6 @@ Init_Array()
rb_define_method(rb_cArray, "select", rb_ary_select, -1);
rb_define_method(rb_cArray, "map", rb_ary_collect, 0);
rb_define_method(rb_cArray, "map!", rb_ary_collect_bang, 0);
rb_define_method(rb_cArray, "filter", rb_ary_filter, 0);
rb_define_method(rb_cArray, "delete", rb_ary_delete, 1);
rb_define_method(rb_cArray, "delete_at", rb_ary_delete_at_m, 1);
rb_define_method(rb_cArray, "delete_if", rb_ary_delete_if, 0);

View file

@ -294,7 +294,7 @@ AC_FUNC_MEMCMP
AC_REPLACE_FUNCS(dup2 memmove mkdir strcasecmp strncasecmp strerror strftime\
strchr strstr strtoul crypt flock vsnprintf\
isinf isnan finite hypot)
AC_CHECK_FUNCS(fmod killpg drand48 random wait4 waitpid syscall chroot\
AC_CHECK_FUNCS(fmod killpg drand48 random wait4 waitpid syscall chroot fsync\
truncate chsize times utimes fcntl lockf lstat symlink readlink\
setitimer setruid seteuid setreuid setresuid setproctitle\
setrgid setegid setregid setresgid pause lchown lchmod\

View file

@ -1,3 +1,7 @@
: IO#fsync
Added.
: Array expansion
Fixed with the following behavior:

2
eval.c
View file

@ -2937,7 +2937,7 @@ rb_eval(self, n)
default:
return rb_funcall(klass, node->nd_mid, 0, 0);
}
result = rb_const_get(klass, node->nd_mid);
result = rb_const_get_at(klass, node->nd_mid);
}
break;

4
file.c
View file

@ -1549,7 +1549,7 @@ rb_file_s_basename(argc, argv)
basename = rb_str_new(name, f);
}
else {
p++; /* skip last `/' */
p++; /* skip last / */
if (NIL_P(fext) || !(f = rmext(p, ext))) {
basename = rb_str_new2(p);
}
@ -2216,6 +2216,8 @@ rb_file_const(name, value)
VALUE value;
{
rb_define_const(rb_mFConst, name, value);
rb_define_const(rb_cIO, name, value);
rb_define_const(rb_cFile, name, value);
}
static int

2
gc.c
View file

@ -823,7 +823,7 @@ rb_gc_mark_children(ptr)
default:
rb_bug("rb_gc_mark(): unknown data type 0x%x(0x%x) %s",
obj->as.basic.flags & T_MASK, obj,
is_pointer_to_heap(obj)?"corrupted object":"non object");
is_pointer_to_heap(obj) ? "corrupted object" : "non object");
}
}

23
io.c
View file

@ -438,6 +438,28 @@ rb_io_set_sync(io, mode)
return mode;
}
static VALUE
rb_io_fsync(io)
VALUE io;
{
#ifdef HAVE_FSYNC
OpenFile *fptr;
FILE *f;
GetOpenFile(io, fptr);
rb_io_check_writable(fptr);
f = GetWriteFile(fptr);
io_fflush(f, fptr->path);
if (fsync(fileno(f)) < 0)
rb_sys_fail(fptr->path);
return INT2FIX(0);
#else
rb_notimplement();
return Qnil; /* not reached */
#endif
}
static VALUE
rb_io_fileno(io)
VALUE io;
@ -3557,6 +3579,7 @@ Init_IO()
rb_define_alias(rb_cIO, "to_i", "fileno");
rb_define_method(rb_cIO, "to_io", rb_io_to_io, 0);
rb_define_method(rb_cIO, "fsync", rb_io_fsync, 0);
rb_define_method(rb_cIO, "sync", rb_io_sync, 0);
rb_define_method(rb_cIO, "sync=", rb_io_set_sync, 1);

View file

@ -392,7 +392,7 @@ w_object(obj, arg, limit)
case T_BIGNUM:
w_byte(TYPE_BIGNUM, arg);
{
char sign = RBIGNUM(obj)->sign?'+':'-';
char sign = RBIGNUM(obj)->sign ? '+' : '-';
long len = RBIGNUM(obj)->len;
BDIGIT *d = RBIGNUM(obj)->digits;

View file

@ -252,9 +252,12 @@ The variable ruby-indent-level controls the amount of indentation.
(looking-at ruby-block-mid-re))
(goto-char (match-end 0))
(looking-at "\\>"))
((eq option 'expr-qstr)
(looking-at "[a-zA-Z][a-zA-z0-9_]* +%[^ \t]"))
((eq option 'expr-re)
(looking-at "[a-zA-Z][a-zA-z0-9_]* +/[^ \t]"))
(t
(and (not (eq option 'expr-arg))
(looking-at "[a-zA-Z][a-zA-z0-9_]* +/[^ \t]"))))))))))
(looking-at "[a-zA-Z][a-zA-z0-9_]* +")))))))))
(defun ruby-forward-string (term &optional end no-error expand)
(let ((n 1) (c (string-to-char term))
@ -310,7 +313,7 @@ The variable ruby-indent-level controls the amount of indentation.
(goto-char indent-point))))
((looking-at "/")
(cond
((and (not (eobp)) (ruby-expr-beg))
((and (not (eobp)) (ruby-expr-beg 'expr-re))
(if (ruby-forward-string "/" indent-point t t)
nil
(setq in-string (point))
@ -319,7 +322,8 @@ The variable ruby-indent-level controls the amount of indentation.
(goto-char pnt))))
((looking-at "%")
(cond
((and (not (eobp)) (ruby-expr-beg 'expr-arg)
((and (not (eobp))
(ruby-expr-beg 'expr-qstr)
(not (looking-at "%="))
(looking-at "%[Qqrxw]?\\(.\\)"))
(goto-char (match-beginning 1))

View file

@ -521,6 +521,7 @@ static VALUE
rb_mod_le(mod, arg)
VALUE mod, arg;
{
if (mod == arg) return Qtrue;
switch (TYPE(arg)) {
case T_MODULE:
case T_CLASS:
@ -534,7 +535,6 @@ rb_mod_le(mod, arg)
return Qtrue;
mod = RCLASS(mod)->super;
}
return Qfalse;
}
@ -573,8 +573,9 @@ static VALUE
rb_mod_cmp(mod, arg)
VALUE mod, arg;
{
if (mod == arg) return INT2FIX(0);
VALUE start = mod;
if (mod == arg) return INT2FIX(0);
switch (TYPE(arg)) {
case T_MODULE:
case T_CLASS:
@ -588,13 +589,18 @@ rb_mod_cmp(mod, arg)
if (rb_mod_le(mod, arg)) {
return INT2FIX(-1);
}
return INT2FIX(1);
while (arg) {
if (RCLASS(arg)->m_tbl == RCLASS(start)->m_tbl)
return INT2FIX(1);
arg = RCLASS(arg)->super;
}
rb_raise(rb_eArgError, "non related class/module");
return Qnil; /* not reached */
}
static VALUE
rb_mod_initialize(argc, argv, module)
int argc;
VALUE *argv;
rb_mod_initialize(module)
VALUE module;
{
if (rb_block_given_p()) {
@ -603,6 +609,15 @@ rb_mod_initialize(argc, argv, module)
return Qnil;
}
static VALUE
rb_class_initialize(argc, argv, klass)
int argc;
VALUE *argv;
VALUE klass;
{
return rb_mod_initialize(klass);
}
static VALUE
rb_module_s_alloc(klass)
VALUE klass;
@ -1262,7 +1277,7 @@ Init_Object()
rb_define_private_method(rb_cModule, "attr_accessor", rb_mod_attr_accessor, -1);
rb_define_singleton_method(rb_cModule, "allocate", rb_module_s_alloc, 0);
rb_define_method(rb_cModule, "initialize", rb_mod_initialize, -1);
rb_define_method(rb_cModule, "initialize", rb_mod_initialize, 0);
rb_define_method(rb_cModule, "instance_methods", rb_class_instance_methods, -1);
rb_define_method(rb_cModule, "public_instance_methods", rb_class_instance_methods, -1);
rb_define_method(rb_cModule, "protected_instance_methods", rb_class_protected_instance_methods, -1);
@ -1278,6 +1293,7 @@ Init_Object()
rb_define_method(rb_cClass, "allocate", rb_class_allocate_instance, 0);
rb_define_method(rb_cClass, "new", rb_class_new_instance, -1);
rb_define_method(rb_cClass, "initialize", rb_class_initialize, -1);
rb_define_method(rb_cClass, "superclass", rb_class_superclass, 0);
rb_undef_method(CLASS_OF(rb_cClass), "allocate");
rb_define_singleton_method(rb_cClass, "new", rb_class_s_new, -1);

33
regex.c
View file

@ -370,13 +370,12 @@ enum regexpcode
duplicate, /* Match a duplicate of something remembered.
Followed by one byte containing the index of the memory
register. */
fail, /* always fails. */
wordchar, /* Matches any word-constituent character. */
notwordchar, /* Matches any char that is not a word-constituent. */
wordbeg, /* Succeeds if at word beginning. */
wordend, /* Succeeds if at word end. */
wordbound, /* Succeeds if at a word boundary. */
notwordbound,/* Succeeds if not at a word boundary. */
notwordbound /* Succeeds if not at a word boundary. */
};
@ -461,7 +460,7 @@ re_set_syntax(syntax)
int n = mbclen(c) - 1; \
c &= (1<<(BYTEWIDTH-2-n)) - 1; \
while (n--) { \
c = c << 6 | *p++ & ((1<<6)-1); \
c = c << 6 | (*p++ & ((1<<6)-1)); \
} \
} \
else { \
@ -502,23 +501,28 @@ print_mbc(c)
{
if (current_mbctype == MBCTYPE_UTF8) {
if (c < 0x80)
printf("%c", c);
printf("%c", (int)c);
else if (c <= 0x7ff)
printf("%c%c", utf8_firstbyte(c), c&0x3f);
printf("%c%c", (int)utf8_firstbyte(c), (int)(c & 0x3f));
else if (c <= 0xffff)
printf("%c%c%c", utf8_firstbyte(c), (c>>6)&0x3f, c&0x3f);
printf("%c%c%c", (int)utf8_firstbyte(c), (int)((c >> 6) & 0x3f),
(int)(c & 0x3f));
else if (c <= 0x1fffff)
printf("%c%c%c%c", utf8_firstbyte(c), (c>>12)&0x3f, (c>>6)&0x3f, c&0x3f);
printf("%c%c%c%c", (int)utf8_firstbyte(c), (int)((c >> 12) & 0x3f),
(int)((c >> 6) & 0x3f), (int)(c & 0x3f));
else if (c <= 0x3ffffff)
printf("%c%c%c%c%c", utf8_firstbyte(c), (c>>18)&0x3f, (c>>12)&0x3f, (c>>6)&0x3f, c&0x3f);
printf("%c%c%c%c%c", (int)utf8_firstbyte(c), (int)((c >> 18) & 0x3f),
(int)((c >> 12) & 0x3f), (int)((c >> 6) & 0x3f), (int)(c & 0x3f));
else if (c <= 0x7fffffff)
printf("%c%c%c%c%c%c", utf8_firstbyte(c), (c>>24)&0x3f, (c>>18)&0x3f, (c>>12)&0x3f, (c>>6)&0x3f, c&0x3f);
printf("%c%c%c%c%c%c", (int)utf8_firstbyte(c), (int)((c >> 24) & 0x3f),
(int)((c >> 18) & 0x3f), (int)((c >> 12) & 0x3f),
(int)((c >> 6) & 0x3f), (int)(c & 0x3f));
}
else if (c < 0xff) {
printf("\\%o", c);
printf("\\%o", (int)c);
}
else {
printf("%c%c", c>>BYTEWIDTH, c&0xff);
printf("%c%c", (int)(c >> BYTEWIDTH), (int)(c &0xff));
}
}
@ -1184,7 +1188,7 @@ re_compile_pattern(pattern, size, bufp)
register const char *p = pattern;
const char *nextp;
const char *pend = pattern + size;
register unsigned int c, c1;
register unsigned int c, c1 = 0;
const char *p0;
int numlen;
#define ERROR_MSG_MAX_SIZE 200
@ -1246,7 +1250,6 @@ re_compile_pattern(pattern, size, bufp)
int *stackb = stacka;
int *stackp = stackb;
int *stacke = stackb + 40;
int *stackt;
/* Counts ('s as they are encountered. Remembered for the matching ),
where it becomes the register number to put in the stop_memory
@ -1479,8 +1482,8 @@ re_compile_pattern(pattern, size, bufp)
case 'W':
for (c = 0; c < (1 << BYTEWIDTH); c++) {
if (SYNTAX(c) != Sword &&
(current_mbctype && !re_mbctab[c] ||
!current_mbctype && SYNTAX(c) != Sword2))
((current_mbctype && !re_mbctab[c]) ||
(!current_mbctype && SYNTAX(c) != Sword2)))
SET_LIST_BIT(c);
}
had_char_class = 1;