summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-02-13 09:11:11 (GMT)
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-02-13 09:11:11 (GMT)
commit937092b8203c373c919a6f307f91e17d4bec5bb1 (patch)
tree07a130b71a37018a9ffaf3f970f42d4348db3a78
parent050f2d84603bd9b3761f1e498f81ce74719caeea (diff)
* range.c (range_step): step might be float 0 < x < 1.
* eval.c (rb_thread_schedule): pause if no runnable thread when there's only one thread. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--compar.c1
-rw-r--r--eval.c5
-rw-r--r--file.c1
-rw-r--r--parse.y2
-rw-r--r--range.c10
-rw-r--r--sample/test.rb14
7 files changed, 36 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index bf18550..4e4c73b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,6 +12,13 @@ Thu Feb 13 01:30:10 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* eval.c (rb_thread_schedule): current thread may be dead when
deadlock. (ruby-bugs:PR#588)
+Thu Feb 13 00:28:52 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * range.c (range_step): step might be float 0 < x < 1.
+
+ * eval.c (rb_thread_schedule): pause if no runnable thread when
+ there's only one thread.
+
Thu Feb 13 00:09:47 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* file.c (strrdirsep): ignore trailing directory separators.
diff --git a/compar.c b/compar.c
index e8c9286..3b6622c 100644
--- a/compar.c
+++ b/compar.c
@@ -72,6 +72,7 @@ cmp_lt(x, y)
{
VALUE c = rb_funcall(x, cmp, 1, y);
+ if (NIL_P(c)) return Qfalse;
if (rb_cmpint(c) < 0) return Qtrue;
return Qfalse;
}
diff --git a/eval.c b/eval.c
index bfd0267..56e9db8 100644
--- a/eval.c
+++ b/eval.c
@@ -8211,6 +8211,11 @@ rb_thread_schedule()
if (!next) {
/* raise fatal error to main thread */
curr_thread->node = ruby_current_node;
+ if (curr->next == curr) {
+ TRAP_BEG;
+ pause();
+ TRAP_END;
+ }
FOREACH_THREAD_FROM(curr, th) {
fprintf(stderr, "deadlock 0x%lx: %s:",
th->thread, thread_status_name(th->status));
diff --git a/file.c b/file.c
index 9996423..c3828b7 100644
--- a/file.c
+++ b/file.c
@@ -1755,6 +1755,7 @@ rb_file_s_basename(argc, argv)
if (NIL_P(fext) || !(f = rmext(p, ext))) {
f = chompdirsep(p) - p;
}
+ basename = rb_str_new(p, f);
}
basename = rb_str_new(p, f);
OBJ_INFECT(basename, fname);
diff --git a/parse.y b/parse.y
index c7423f5..0c04a40 100644
--- a/parse.y
+++ b/parse.y
@@ -3664,7 +3664,7 @@ yylex()
}
pushback(c);
if (ISDIGIT(c)) {
- rb_warning("no .<digit> floating literal anymore; put 0 before dot");
+ rb_warn("no .<digit> floating literal anymore; put 0 before dot");
}
lex_state = EXPR_DOT;
return '.';
diff --git a/range.c b/range.c
index 585940a..97b7d68 100644
--- a/range.c
+++ b/range.c
@@ -242,13 +242,14 @@ range_step(argc, argv, range)
}
unit = NUM2LONG(step);
- if (unit <= 0) {
- rb_raise(rb_eArgError, "step can't be <= 0");
- }
+ if (unit < 0) {
+ rb_raise(rb_eArgError, "step can't be negative");
+ }
if (FIXNUM_P(b) && FIXNUM_P(e)) { /* fixnums are special */
long end = FIX2LONG(e);
long i;
+ if (unit == 0) rb_raise(rb_eArgError, "step can't be 0");
if (!EXCL(range)) end += 1;
for (i=FIX2LONG(b); i<end; i+=unit) {
rb_yield(LONG2NUM(i));
@@ -257,6 +258,7 @@ range_step(argc, argv, range)
else if (rb_obj_is_kind_of(b, rb_cNumeric)) {
ID c = rb_intern(EXCL(range) ? "<" : "<=");
+ if (rb_equal(step, INT2FIX(0))) rb_raise(rb_eArgError, "step can't be 0");
while (RTEST(rb_funcall(b, c, 1, e))) {
rb_yield(b);
b = rb_funcall(b, '+', 1, step);
@@ -266,6 +268,7 @@ range_step(argc, argv, range)
VALUE args[5];
long iter[2];
+ if (unit == 0) rb_raise(rb_eArgError, "step can't be 0");
args[0] = b; args[1] = e; args[2] = range;
iter[0] = 1; iter[1] = unit;
rb_iterate((VALUE(*)_((VALUE)))str_step, (VALUE)args, step_i, (VALUE)iter);
@@ -273,6 +276,7 @@ range_step(argc, argv, range)
else {
long args[2];
+ if (unit == 0) rb_raise(rb_eArgError, "step can't be 0");
if (!rb_respond_to(b, id_succ)) {
rb_raise(rb_eTypeError, "cannot iterate from %s",
rb_obj_classname(b));
diff --git a/sample/test.rb b/sample/test.rb
index 4b00990..4b62fb3 100644
--- a/sample/test.rb
+++ b/sample/test.rb
@@ -1651,6 +1651,20 @@ test_ok(!x.foo)
test_ok(x.bar)
test_ok(!x.quux)
+test_check "path"
+test_ok(File.basename("a") == "a")
+test_ok(File.basename("a/b") == "b")
+test_ok(File.basename("a/b/") == "b")
+test_ok(File.basename("a/b////") == "b")
+test_ok(File.basename("a.rb", ".rb") == "a")
+test_ok(File.dirname("a") == ".")
+test_ok(File.dirname("/a") == "/")
+test_ok(File.dirname("a/b") == "a")
+test_ok(File.dirname("a/b/c") == "a/b")
+test_ok(File.dirname("/a/b/c") == "/a/b")
+test_ok(File.dirname("/a/b/") == "/a")
+test_ok(File.dirname("/a/b///") == "/a")
+
test_check "gc"
begin
1.upto(10000) {