summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-01-23 07:30:43 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-01-23 07:30:43 +0000
commiteb9708f38671aa6446a89acc755f3341f5cb59b6 (patch)
tree1a033ace8ffbc862b97c6f4eab80e3326462f06d
parentb6cc058c53fde7442253c44e688ff8541050572d (diff)
* 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
-rw-r--r--ChangeLog20
-rw-r--r--ToDo1
-rw-r--r--array.c9
-rw-r--r--configure.in2
-rw-r--r--doc/NEWS4
-rw-r--r--eval.c2
-rw-r--r--file.c4
-rw-r--r--gc.c2
-rw-r--r--io.c23
-rw-r--r--marshal.c2
-rw-r--r--misc/ruby-mode.el12
-rw-r--r--object.c30
-rw-r--r--regex.c33
13 files changed, 102 insertions, 42 deletions
diff --git a/ChangeLog b/ChangeLog
index d823dfaf11..c7394fed9c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
diff --git a/ToDo b/ToDo
index 41f0edf02e..20d5236265 100644
--- a/ToDo
+++ b/ToDo
@@ -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
diff --git a/array.c b/array.c
index e1e1f9245b..55ee37ff8a 100644
--- a/array.c
+++ b/array.c
@@ -1169,14 +1169,6 @@ rb_ary_collect_bang(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;
VALUE *argv;
@@ -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);
diff --git a/configure.in b/configure.in
index 35647e4597..4a0af908e6 100644
--- a/configure.in
+++ b/configure.in
@@ -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\
diff --git a/doc/NEWS b/doc/NEWS
index 1b2baf93f7..95f3981c37 100644
--- a/doc/NEWS
+++ b/doc/NEWS
@@ -1,3 +1,7 @@
+: IO#fsync
+
+ Added.
+
: Array expansion
Fixed with the following behavior:
diff --git a/eval.c b/eval.c
index be5858c2d1..13f656cdc6 100644
--- a/eval.c
+++ b/eval.c
@@ -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;
diff --git a/file.c b/file.c
index 424e753a3f..e3bc81cdd8 100644
--- a/file.c
+++ b/file.c
@@ -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
diff --git a/gc.c b/gc.c
index f5602989e5..89085de921 100644
--- a/gc.c
+++ b/gc.c
@@ -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");
}
}
diff --git a/io.c b/io.c
index c5fb2359f6..946d332195 100644
--- a/io.c
+++ b/io.c
@@ -439,6 +439,28 @@ rb_io_set_sync(io, 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);
diff --git a/marshal.c b/marshal.c
index 93005e9425..72ac20ae6f 100644
--- a/marshal.c
+++ b/marshal.c
@@ -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;
diff --git a/misc/ruby-mode.el b/misc/ruby-mode.el
index 56cb1ed2aa..a33e6d43e4 100644
--- a/misc/ruby-mode.el
+++ b/misc/ruby-mode.el
@@ -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))
diff --git a/object.c b/object.c
index 68a0b824ea..2c4440c89a 100644
--- a/object.c
+++ b/object.c
@@ -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()) {
@@ -604,6 +610,15 @@ rb_mod_initialize(argc, argv, module)
}
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);
diff --git a/regex.c b/regex.c
index 99847afba3..64d32151ed 100644
--- a/regex.c
+++ b/regex.c
@@ -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;