summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--array.c2
-rw-r--r--eval.c10
-rw-r--r--numeric.c16
-rw-r--r--range.c11
4 files changed, 31 insertions, 8 deletions
diff --git a/array.c b/array.c
index 934fb36..1313093 100644
--- a/array.c
+++ b/array.c
@@ -44,7 +44,7 @@ memfill(mem, size, val)
#define ARY_TMPLOCK FL_USER1
-static void
+static inline void
rb_ary_modify_check(ary)
VALUE ary;
{
diff --git a/eval.c b/eval.c
index 2a25dac..fbe53d8 100644
--- a/eval.c
+++ b/eval.c
@@ -917,14 +917,19 @@ static VALUE trace_func = 0;
static int tracing = 0;
static void call_trace_func _((char*,NODE*,VALUE,ID,VALUE));
+#if 0
#define SET_CURRENT_SOURCE() (ruby_sourcefile = ruby_current_node->nd_file, \
ruby_sourceline = nd_line(ruby_current_node))
+#else
+#define SET_CURRENT_SOURCE() 0
+#endif
void
ruby_set_current_source()
{
if (ruby_current_node) {
- SET_CURRENT_SOURCE();
+ ruby_sourcefile = ruby_current_node->nd_file;
+ ruby_sourceline = nd_line(ruby_current_node);
}
}
@@ -3390,7 +3395,6 @@ rb_eval(self, n)
break;
case NODE_NEWLINE:
- ruby_sourcefile = node->nd_file;
ruby_sourceline = node->nd_nth;
if (trace_func) {
call_trace_func("line", node, self,
@@ -4443,7 +4447,7 @@ rb_undefined(obj, id, argc, argv, call_status)
return rb_funcall2(obj, missing, argc+1, nargv);
}
-static VALUE
+static inline VALUE
call_cfunc(func, recv, len, argc, argv)
VALUE (*func)();
VALUE recv;
diff --git a/numeric.c b/numeric.c
index 28061ca..04c59f4 100644
--- a/numeric.c
+++ b/numeric.c
@@ -850,11 +850,21 @@ num_step(argc, argv, from)
{
VALUE to, step;
- if (rb_scan_args(argc, argv, "11", &to, &step) == 1) {
+ if (argc == 1) {
+ to = argv[0];
step = INT2FIX(1);
}
- else if (rb_equal(step, INT2FIX(0))) {
- rb_raise(rb_eArgError, "step cannot be 0");
+ else {
+ if (argc == 2) {
+ to = argv[0];
+ step = argv[1];
+ }
+ else {
+ rb_raise(rb_eArgError, "wrong number of arguments");
+ }
+ if (rb_equal(step, INT2FIX(0))) {
+ rb_raise(rb_eArgError, "step cannot be 0");
+ }
}
if (FIXNUM_P(from) && FIXNUM_P(to) && FIXNUM_P(step)) {
diff --git a/range.c b/range.c
index 3b56ee7..2faf2f3 100644
--- a/range.c
+++ b/range.c
@@ -306,7 +306,16 @@ range_each(range)
rb_raise(rb_eTypeError, "cannot iterate from %s",
rb_class2name(CLASS_OF(beg)));
}
- if (TYPE(beg) == T_STRING) {
+ if (FIXNUM_P(beg) && FIXNUM_P(end)) { /* fixnums are special */
+ long lim = FIX2LONG(end);
+ long i;
+
+ if (!EXCL(range)) lim += 1;
+ for (i=FIX2LONG(beg); i<lim; i++) {
+ rb_yield(LONG2NUM(i));
+ }
+ }
+ else if (TYPE(beg) == T_STRING) {
VALUE args[5];
long iter[2];