diff options
-rw-r--r-- | ChangeLog | 27 | ||||
-rw-r--r-- | array.c | 12 | ||||
-rw-r--r-- | class.c | 8 | ||||
-rw-r--r-- | dir.c | 4 | ||||
-rw-r--r-- | doc/NEWS | 8 | ||||
-rw-r--r-- | eval.c | 15 | ||||
-rw-r--r-- | ext/extmk.rb.in | 5 | ||||
-rw-r--r-- | hash.c | 22 | ||||
-rw-r--r-- | misc/ruby-mode.el | 3 | ||||
-rw-r--r-- | range.c | 2 | ||||
-rw-r--r-- | string.c | 3 |
11 files changed, 87 insertions, 22 deletions
@@ -1,3 +1,30 @@ +Fri Jan 25 17:16:23 2002 Yukihiro Matsumoto <matz@ruby-lang.org> + + * class.c (rb_include_module): detect cyclic module inclusion. + +Fri Jan 25 02:17:56 2002 Yukihiro Matsumoto <matz@ruby-lang.org> + + * eval.c (rb_thread_cleanup): need not to free thread stacks at + process termination. + + * array.c (rb_ary_fetch): use the block to get the default value + if the block is given. + + * eval.c (rb_thread_schedule): should check time only if BOTH + WAIT_SELECT and WAIT_TIME. + +Thu Jan 24 11:49:05 2002 Yukihiro Matsumoto <matz@ruby-lang.org> + + * eval.c (umethod_bind): should update rklass field. + + * hash.c (rb_hash_update): if a block is given, yields [key, + value1, value2] to the block to resolve conflict. + +Thu Jan 24 05:42:01 2002 Koji Arai <jca02266@nifty.ne.jp> + + * string.c (rb_str_split_m): no need to consider KANJI + characters, if the length of separator is 1 (byte). + Wed Jan 23 16:07:31 2002 Yukihiro Matsumoto <matz@ruby-lang.org> * array.c (Init_Array): remove Array#filter. @@ -550,8 +550,16 @@ rb_ary_fetch(argc, argv, ary) idx += RARRAY(ary)->len; } if (idx < 0 || RARRAY(ary)->len <= idx) { - if (argc == 2) return ifnone; - rb_raise(rb_eIndexError, "index %d out of array", idx); + if (rb_block_given_p()) { + if (argc > 1) { + rb_raise(rb_eArgError, "wrong number of arguments"); + } + return rb_yield(pos); + } + if (argc == 1) { + rb_raise(rb_eIndexError, "index %d out of array", idx); + } + return ifnone; } return RARRAY(ary)->ptr[idx]; } @@ -349,11 +349,13 @@ rb_include_module(klass, module) OBJ_INFECT(klass, module); c = klass; while (module) { + if (RCLASS(klass)->m_tbl == RCLASS(module)->m_tbl) + rb_raise(rb_eArgError, "cyclic include detected"); /* ignore if the module included already in superclasses */ for (p = RCLASS(klass)->super; p; p = RCLASS(p)->super) { - if (BUILTIN_TYPE(p) == T_ICLASS && - RCLASS(p)->m_tbl == RCLASS(module)->m_tbl) { - goto skip; + if (BUILTIN_TYPE(p) == T_ICLASS) { + if (RCLASS(p)->m_tbl == RCLASS(module)->m_tbl) + goto skip; } } RCLASS(c)->super = include_class_new(module, RCLASS(c)->super); @@ -734,7 +734,7 @@ glob_helper(path, sub, flags, func, arg) if (strcmp(".", dp->d_name) == 0 || strcmp("..", dp->d_name) == 0) continue; buf = ALLOC_N(char, strlen(base)+NAMLEN(dp)+strlen(m)+6); - sprintf(buf, "%s%s%s", base, (BASE)?"/":"", dp->d_name); + sprintf(buf, "%s%s%s", base, (BASE) ? "/" : "", dp->d_name); if (lstat(buf, &st) < 0) { if (errno != ENOENT) rb_sys_warning(buf); continue; @@ -750,7 +750,7 @@ glob_helper(path, sub, flags, func, arg) } if (fnmatch(magic, dp->d_name, flags) == 0) { buf = ALLOC_N(char, strlen(base)+NAMLEN(dp)+2); - sprintf(buf, "%s%s%s", base, (BASE)?"/":"", dp->d_name); + sprintf(buf, "%s%s%s", base, (BASE) ? "/" : "", dp->d_name); if (!m) { (*func)(buf, arg); free(buf); @@ -1,3 +1,11 @@ +: Array#fetch + + takes block to get the default value. + +: Hash#update + + takes block to resolve key conflict. + : IO#fsync Added. @@ -166,7 +166,7 @@ print_undef(klass, id) { rb_name_error(id, "undefined method `%s' for %s `%s'", rb_id2name(id), - (TYPE(klass) == T_MODULE)?"module":"class", + (TYPE(klass) == T_MODULE) ? "module" : "class", rb_class2name(klass)); } @@ -4262,8 +4262,8 @@ rb_f_missing(argc, argv, obj) char buf[BUFSIZ]; snprintf(buf, BUFSIZ, format, rb_id2name(id), - desc, desc[0]=='#'?"":":", - desc[0]=='#'?"":rb_class2name(CLASS_OF(obj))); + desc, desc[0]=='#' ? "" : ":", + desc[0]=='#' ? "" : rb_class2name(CLASS_OF(obj))); exc = rb_exc_new2(exc, buf); rb_iv_set(exc, "name", argv[0]); rb_iv_set(exc, "args", rb_ary_new4(argc-1, argv+1)); @@ -6866,6 +6866,7 @@ umethod_bind(method, recv) method = Data_Make_Struct(rb_cMethod,struct METHOD,bm_mark,free,bound); *bound = *data; bound->recv = recv; + bound->rklass = CLASS_OF(recv); return method; } @@ -7319,7 +7320,7 @@ static rb_thread_t rb_thread_check(data) VALUE data; { - if (TYPE(data) != T_DATA || RDATA(data)->dfree != (RUBY_DATA_FUNC)thread_free) { + if (TYPE(data) != T_DATA || RDATA(data)->dmark != (RUBY_DATA_FUNC)thread_mark) { rb_raise(rb_eTypeError, "wrong argument type %s (expected Thread)", rb_class2name(CLASS_OF(data))); } @@ -7744,7 +7745,8 @@ rb_thread_schedule() if (select_timeout && n == 0) { if (now < 0.0) now = timeofday(); FOREACH_THREAD_FROM(curr, th) { - if ((th->wait_for & (WAIT_SELECT|WAIT_TIME)) && th->delay <= now) { + if (((th->wait_for&(WAIT_SELECT|WAIT_TIME)) == (WAIT_SELECT|WAIT_TIME)) && + th->delay <= now) { th->status = THREAD_RUNNABLE; th->wait_for = 0; th->select_value = 0; @@ -7810,7 +7812,7 @@ rb_thread_schedule() FOREACH_THREAD_FROM(curr, th) { fprintf(stderr, "deadlock 0x%lx: %d:%d %s - %s:%d\n", th->thread, th->status, - th->wait_for, th==main_thread?"(main)":"", + th->wait_for, th==main_thread ? "(main)" : "", th->file, th->line); } END_FOREACH_FROM(curr, th); @@ -8664,6 +8666,7 @@ rb_thread_cleanup() th->gid = 0; th->priority = 0; th->status = THREAD_TO_KILL; + RDATA(th->thread)->dfree = NULL; } } END_FOREACH(th); diff --git a/ext/extmk.rb.in b/ext/extmk.rb.in index 86dd67e558..b073a1586d 100644 --- a/ext/extmk.rb.in +++ b/ext/extmk.rb.in @@ -26,6 +26,7 @@ SRC_EXT = ["c", "cc", "m", "cxx", "cpp", "C"] $extlist = [] $includedir = "@includedir@".gsub(/\$\{prefix\}|\$\(prefix\)/,'@prefix@') +$libdir = "@libdir@".gsub(/\$\{exec_prefix\}|\$\(exec_prefix\)/,'@exec_prefix@') $top_srcdir = "@top_srcdir@" if $top_srcdir !~ "^/" @@ -73,7 +74,7 @@ if /mswin32/ =~ RUBY_PLATFORM else OUTFLAG = '-o ' end -LINK = "@CC@ #{OUTFLAG}conftest -I#$topdir -I#$top_srcdir #{CFLAGS} -I#$includedir @LDFLAGS@ %s %s %s conftest.c %s %s @LIBS@" +LINK = "@CC@ #{OUTFLAG}conftest -I#$topdir -I#$top_srcdir #{CFLAGS} -I#$includedir -L#$libdir @LDFLAGS@ %s %s %s conftest.c %s %s @LIBS@" CPP = "@CPP@ @CPPFLAGS@ -I#$topdir -I#$top_srcdir #{CFLAGS} -I#$includedir %s %s %s conftest.c" $log = open('extmk.log', 'w') @@ -450,7 +451,7 @@ target_prefix = #{target_prefix} " mfile.printf "LOCAL_LIBS = %s %s\n", $LOCAL_LIBS, $local_flags - mfile.printf "LIBS = %s\n", $libs + mfile.printf "LIBS = -L%s %s\n", $libdir, $libs mfile.printf "OBJS = " if !$objs then $objs = [] @@ -889,12 +889,30 @@ rb_hash_update_i(key, value, hash) return ST_CONTINUE; } +static int +rb_hash_update_block_i(key, value, hash) + VALUE key, value; + VALUE hash; +{ + if (key == Qundef) return ST_CONTINUE; + if (rb_hash_has_key(hash, key)) { + value = rb_yield(rb_ary_new3(3, key, rb_hash_aref(hash, key), value)); + } + rb_hash_aset(hash, key, value); + return ST_CONTINUE; +} + static VALUE rb_hash_update(hash1, hash2) VALUE hash1, hash2; { hash2 = to_hash(hash2); - st_foreach(RHASH(hash2)->tbl, rb_hash_update_i, hash1); + if (rb_block_given_p()) { + st_foreach(RHASH(hash2)->tbl, rb_hash_update_block_i, hash1); + } + else { + st_foreach(RHASH(hash2)->tbl, rb_hash_update_i, hash1); + } return hash1; } @@ -985,7 +1003,7 @@ env_fetch(argc, argv) if (!env) { if (rb_block_given_p()) { if (argc > 1) { - rb_raise(rb_eArgError, "wrong number of arguments", argc); + rb_raise(rb_eArgError, "wrong number of arguments"); } return rb_yield(key); } diff --git a/misc/ruby-mode.el b/misc/ruby-mode.el index a33e6d43e4..bbbb2706e5 100644 --- a/misc/ruby-mode.el +++ b/misc/ruby-mode.el @@ -256,8 +256,7 @@ The variable ruby-indent-level controls the amount of indentation. (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 - (looking-at "[a-zA-Z][a-zA-z0-9_]* +"))))))))) + (t nil)))))))) (defun ruby-forward-string (term &optional end no-error expand) (let ((n 1) (c (string-to-char term)) @@ -438,7 +438,7 @@ rb_range_beg_len(range, begp, lenp, len, err) out_of_range: if (err) { rb_raise(rb_eRangeError, "%d..%s%d out of range", - b, EXCL(range)?".":"", e); + b, EXCL(range)? "." : "", e); } return Qnil; } @@ -1634,7 +1634,7 @@ uscore_get() line = rb_lastline_get(); if (TYPE(line) != T_STRING) { rb_raise(rb_eTypeError, "$_ value need to be String (%s given)", - NIL_P(line)?"nil":rb_class2name(CLASS_OF(line))); + NIL_P(line) ? "nil" : rb_class2name(CLASS_OF(line))); } return line; } @@ -2509,7 +2509,6 @@ rb_str_split_m(argc, argv, str) if (!NIL_P(limit) && lim <= ++i) break; } end++; - if (ismbchar(*ptr)) {ptr++; end++;} } } } |