summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-03-13 05:45:13 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-03-13 05:45:13 +0000
commite502549be1bea41406ccef0e819b0e9cb8cdb069 (patch)
tree78a2fe9e8986665213222c60304e5682e0431303
parent8fc5876485fb84bf9c93b569ff0cb57cf2b21f7d (diff)
* io.c (argf_seek_m): wrong calling sequence of rb_io_seek().
* parse.y (cond0): no special treatment of string literal in condition. * math.c: add acos, asin, atan, conh, sinh, tanh and hypot to Math. * configure.in: check hypot availablility. * missing/hypot.c: public domain rewrite of hypot. * parse.y (warn_unless_e_option): warning condition was wrong. * parse.y (warning_unless_e_option): ditto. * enum.c (enum_all): new method 'all?', which returns true if block returns true for all elements. * enum.c (enum_any): new method 'any?', which returns true if block retruns true for any of elements. * marshal.c (marshal_load): do not give warning unless explicitly set to verbose. * eval.c (rb_exit): give string value "exit" to SystemExit. * ruby.c (proc_options): -v should not print version if proc_options called via moreswitches(). * parse.y (stmt): while/until modifier must work for empty body. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1241 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog52
-rw-r--r--MANIFEST1
-rw-r--r--array.c4
-rw-r--r--configure.in2
-rw-r--r--dln.c6
-rw-r--r--enum.c58
-rw-r--r--eval.c6
-rw-r--r--intern.h1
-rw-r--r--io.c41
-rw-r--r--lib/delegate.rb2
-rw-r--r--lib/mkmf.rb2
-rw-r--r--lib/profile.rb9
-rw-r--r--marshal.c2
-rw-r--r--math.c74
-rw-r--r--missing/hypot.c17
-rw-r--r--numeric.c2
-rw-r--r--object.c4
-rw-r--r--parse.y47
-rw-r--r--ruby.c3
-rw-r--r--version.h4
20 files changed, 266 insertions, 71 deletions
diff --git a/ChangeLog b/ChangeLog
index 3dd36ff..cc974a8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,15 +1,59 @@
+<<<<<<< ChangeLog
+Tue Mar 13 14:41:16 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (argf_seek_m): wrong calling sequence of rb_io_seek().
+
+Tue Mar 13 09:14:19 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (cond0): no special treatment of string literal in
+ condition.
+
Mon Mar 12 18:59:38 2001 WATANABE Hirofumi <eban@ruby-lang.org>
* lib/mkmf.rb (create_makefile): save/restore $libs and $LIBPATH.
+Sun Mar 11 18:13:34 2001 Masahiro Tanaka <masa@stars.gsfc.nasa.gov>
+
+ * math.c: add acos, asin, atan, conh, sinh, tanh and hypot to Math.
+
+ * configure.in: check hypot availablility.
+
+ * missing/hypot.c: public domain rewrite of hypot.
+
+Sun Mar 11 13:21:04 2001 Koji Arai <JCA02266@nifty.ne.jp>
+
+ * parse.y (warn_unless_e_option): warning condition was wrong.
+
+ * parse.y (warning_unless_e_option): ditto.
+
Sun Mar 11 00:55:31 2001 WATANABE Hirofumi <eban@ruby-lang.org>
* lib/mkmf.rb (install_rb): fix handling of destination path.
+Sat Mar 10 22:56:44 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * enum.c (enum_all): new method 'all?', which returns true if
+ block returns true for all elements.
+
+ * enum.c (enum_any): new method 'any?', which returns true if
+ block retruns true for any of elements.
+
Sat Mar 10 02:34:18 2001 WATANABE Hirofumi <eban@ruby-lang.org>
* math.c (math_log, math_log10): use nan() instead of 0.0/0.0 on Cygwin.
+Fri Mar 9 09:56:19 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * marshal.c (marshal_load): do not give warning unless explicitly
+ set to verbose.
+
+Fri Mar 9 02:07:53 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_exit): give string value "exit" to SystemExit.
+
+ * ruby.c (proc_options): -v should not print version if
+ proc_options called via moreswitches().
+
Thu Mar 8 17:45:19 2001 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
* lib/net/protocol.rb: one write(2) per one line.
@@ -19,6 +63,14 @@ Wed Mar 7 14:26:11 2001 WATANABE Hirofumi <eban@ruby-lang.org>
* math.c (math_log, math_log10): should return NaN if x < 0.0
on Cygwin.
+Thu Mar 7 10:31:26 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
+
+ * parse.y (stmt): while/until modifier must work for empty body.
+
+Tue Mar 6 22:53:58 2001 Kazuhiro Yoshida <moriq.kazuhiro@nifty.ne.jp>
+
+ * ruby.c (ruby_set_argv): clear ARGV contents before adding args.
+
Tue Mar 6 10:50:29 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* parse.y (primary): rescue and ensure clauses should be allowed
diff --git a/MANIFEST b/MANIFEST
index c701e81..d80ba8a 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -167,6 +167,7 @@ missing/dup2.c
missing/file.h
missing/finite.c
missing/flock.c
+missing/hypot.c
missing/isinf.c
missing/isnan.c
missing/memcmp.c
diff --git a/array.c b/array.c
index 5695851..4d3cd04 100644
--- a/array.c
+++ b/array.c
@@ -1100,7 +1100,7 @@ rb_ary_delete_at(ary, pos)
return del;
}
-VALUE
+static VALUE
rb_ary_delete_at_m(ary, pos)
VALUE ary, pos;
{
@@ -1186,7 +1186,7 @@ rb_ary_replace_m(ary, ary2)
return ary;
}
-static VALUE
+VALUE
rb_ary_clear(ary)
VALUE ary;
{
diff --git a/configure.in b/configure.in
index c24b7b7..6a60e2c 100644
--- a/configure.in
+++ b/configure.in
@@ -255,7 +255,7 @@ AC_FUNC_VFORK
AC_FUNC_MEMCMP
AC_REPLACE_FUNCS(dup2 memmove mkdir strcasecmp strncasecmp strerror strftime\
strchr strstr strtoul crypt flock vsnprintf\
- isinf isnan finite)
+ isinf isnan finite hypot)
AC_CHECK_FUNCS(fmod killpg drand48 random wait4 waitpid syscall getcwd chroot\
truncate chsize times utimes fcntl lockf lstat symlink readlink\
setitimer setruid seteuid setreuid setresuid \
diff --git a/dln.c b/dln.c
index 98b97af..1114227 100644
--- a/dln.c
+++ b/dln.c
@@ -84,9 +84,9 @@ int eaccess();
#ifndef FUNCNAME_PATTERN
# if defined(__hp9000s300) || (defined(__NetBSD__) && !defined(__ELF__)) || defined(__BORLANDC__) || (defined(__FreeBSD__) && __FreeBSD__ < 3) || defined(__OpenBSD__) || defined(NeXT) || defined(__WATCOMC__) || defined(__APPLE__)
-# define FUNCNAME_PATTERN "_Init_%.200s"
+# define FUNCNAME_PATTERN "_Init_%s"
# else
-# define FUNCNAME_PATTERN "Init_%.200s"
+# define FUNCNAME_PATTERN "Init_%s"
# endif
#endif
@@ -1194,7 +1194,7 @@ aix_loaderror(const char *pathname)
#define LOAD_ERRTAB_LEN (sizeof(load_errtab)/sizeof(load_errtab[0]))
#define ERRBUF_APPEND(s) strncat(errbuf, s, sizeof(errbuf)-strlen(errbuf)-1)
- snprintf(errbuf, 1024, "load failed - %.200s ", pathname);
+ snprintf(errbuf, 1024, "load failed - %s ", pathname);
if (!loadquery(1, &message[0], sizeof(message)))
ERRBUF_APPEND(strerror(errno));
diff --git a/enum.c b/enum.c
index 19cfe91..56d6950 100644
--- a/enum.c
+++ b/enum.c
@@ -87,10 +87,10 @@ enum_find(argc, argv, obj)
rb_gc_force_recycle((VALUE)memo);
return memo->u1.value;
}
+ rb_gc_force_recycle((VALUE)memo);
if (!NIL_P(if_none)) {
rb_eval_cmd(if_none, rb_ary_new2(0));
}
- rb_gc_force_recycle((VALUE)memo);
return Qnil;
}
@@ -147,7 +147,7 @@ collect_i(i, tmp)
}
static VALUE
-enum_all(i, ary)
+collect_all(i, ary)
VALUE i, ary;
{
rb_ary_push(ary, i);
@@ -161,7 +161,7 @@ enum_to_a(obj)
VALUE ary;
ary = rb_ary_new();
- rb_iterate(rb_each, obj, enum_all, ary);
+ rb_iterate(rb_each, obj, collect_all, ary);
return ary;
}
@@ -173,7 +173,7 @@ enum_collect(obj)
VALUE tmp;
tmp = rb_ary_new();
- rb_iterate(rb_each, obj, rb_block_given_p() ? collect_i : enum_all, tmp);
+ rb_iterate(rb_each, obj, rb_block_given_p() ? collect_i : collect_all, tmp);
return tmp;
}
@@ -204,6 +204,54 @@ enum_sort(obj)
}
static VALUE
+all_i(i, memo)
+ VALUE i;
+ NODE *memo;
+{
+ if (!RTEST(rb_yield(i))) {
+ memo->u1.value = Qfalse;
+ rb_iter_break();
+ }
+ return Qnil;
+}
+
+static VALUE
+enum_all(obj)
+ VALUE obj;
+{
+ NODE *memo = rb_node_newnode(NODE_MEMO, Qnil, 0, 0);
+
+ memo->u1.value = Qtrue;
+ rb_iterate(rb_each, obj, all_i, (VALUE)memo);
+ rb_gc_force_recycle((VALUE)memo);
+ return memo->u1.value;
+}
+
+static VALUE
+any_i(i, memo)
+ VALUE i;
+ NODE *memo;
+{
+ if (RTEST(rb_yield(i))) {
+ memo->u1.value = Qtrue;
+ rb_iter_break();
+ }
+ return Qnil;
+}
+
+static VALUE
+enum_any(obj)
+ VALUE obj;
+{
+ NODE *memo = rb_node_newnode(NODE_MEMO, Qnil, 0, 0);
+
+ memo->u1.value = Qfalse;
+ rb_iterate(rb_each, obj, any_i, (VALUE)memo);
+ rb_gc_force_recycle((VALUE)memo);
+ return memo->u1.value;
+}
+
+static VALUE
min_i(i, memo)
VALUE i;
NODE *memo;
@@ -358,6 +406,8 @@ Init_Enumerable()
rb_define_method(rb_mEnumerable,"collect", enum_collect, 0);
rb_define_method(rb_mEnumerable,"map", enum_collect, 0);
rb_define_method(rb_mEnumerable,"inject", enum_inject, 1);
+ rb_define_method(rb_mEnumerable,"all?", enum_all, 0);
+ rb_define_method(rb_mEnumerable,"any?", enum_any, 0);
rb_define_method(rb_mEnumerable,"min", enum_min, 0);
rb_define_method(rb_mEnumerable,"max", enum_max, 0);
rb_define_method(rb_mEnumerable,"member?", enum_member, 1);
diff --git a/eval.c b/eval.c
index ce09465..cb892cd 100644
--- a/eval.c
+++ b/eval.c
@@ -3315,7 +3315,7 @@ rb_exit(status)
VALUE exit;
exit_status = status;
- exit = rb_exc_new(rb_eSystemExit, 0, 0);
+ exit = rb_exc_new2(rb_eSystemExit, "exit");
rb_iv_set(exit, "status", INT2NUM(status));
rb_exc_raise(exit);
}
@@ -4152,7 +4152,7 @@ stack_length(p)
#endif
if (p) *p = STACK_END;
-#ifdef sparc
+#ifdef __sparc__
return rb_gc_stack_start - STACK_END + 0x80;
#else
return (STACK_END < rb_gc_stack_start) ? rb_gc_stack_start - STACK_END
@@ -6445,7 +6445,7 @@ block_pass(self, node)
break;
case TAG_BREAK:
if (orphan) {
- rb_raise(rb_eLocalJumpError, "retry from proc-closure");
+ rb_raise(rb_eLocalJumpError, "break from proc-closure");
}
break;
case TAG_RETRY:
diff --git a/intern.h b/intern.h
index f1a0b70..b83c077 100644
--- a/intern.h
+++ b/intern.h
@@ -41,6 +41,7 @@ VALUE rb_ary_sort _((VALUE));
VALUE rb_ary_sort_bang _((VALUE));
VALUE rb_ary_delete _((VALUE, VALUE));
VALUE rb_ary_delete_at _((VALUE, long));
+VALUE rb_ary_clear _((VALUE));
VALUE rb_ary_plus _((VALUE, VALUE));
VALUE rb_ary_concat _((VALUE, VALUE));
VALUE rb_ary_assoc _((VALUE, VALUE));
diff --git a/io.c b/io.c
index 075c520..9beb17f 100644
--- a/io.c
+++ b/io.c
@@ -317,7 +317,23 @@ rb_io_tell(io)
#endif
static VALUE
-rb_io_seek(argc, argv, io)
+rb_io_seek(io, offset, whence)
+ VALUE io, offset;
+ int whence;
+{
+ OpenFile *fptr;
+ long pos;
+
+ GetOpenFile(io, fptr);
+ pos = fseek(fptr->f, NUM2INT(offset), whence);
+ if (pos != 0) rb_sys_fail(fptr->path);
+ clearerr(fptr->f);
+
+ return INT2FIX(0);
+}
+
+static VALUE
+rb_io_seek_m(argc, argv, io)
int argc;
VALUE *argv;
VALUE io;
@@ -331,12 +347,7 @@ rb_io_seek(argc, argv, io)
if (argc == 1) whence = SEEK_SET;
else whence = NUM2INT(ptrname);
- GetOpenFile(io, fptr);
- pos = fseek(fptr->f, NUM2INT(offset), whence);
- if (pos != 0) rb_sys_fail(fptr->path);
- clearerr(fptr->f);
-
- return INT2FIX(0);
+ return rb_io_seek(io, offset, whence);
}
static VALUE
@@ -3148,7 +3159,7 @@ rb_io_s_read(argc, argv, io)
arg.io = rb_io_open(RSTRING(fname)->ptr, "r");
if (NIL_P(arg.io)) return Qnil;
if (!NIL_P(offset)) {
- rb_io_seek(1, &offset, arg.io);
+ rb_io_seek(arg.io, offset, SEEK_SET);
}
return rb_ensure(io_s_read, (VALUE)&arg, rb_io_close, arg.io);
}
@@ -3167,9 +3178,13 @@ argf_tell()
}
static VALUE
-argf_seek(self, offset, ptrname)
- VALUE self, offset, ptrname;
+argf_seek_m(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
+ VALUE args[2];
+
if (!next_argv()) {
rb_raise(rb_eArgError, "no stream to seek");
}
@@ -3177,7 +3192,7 @@ argf_seek(self, offset, ptrname)
if (TYPE(current_file) != T_FILE) {
return argf_forward();
}
- return rb_io_seek(current_file, offset, ptrname);
+ return rb_io_seek_m(argc, argv, current_file);
}
static VALUE
@@ -3490,7 +3505,7 @@ Init_IO()
rb_define_method(rb_cIO, "<<", rb_io_addstr, 1);
rb_define_method(rb_cIO, "flush", rb_io_flush, 0);
rb_define_method(rb_cIO, "tell", rb_io_tell, 0);
- rb_define_method(rb_cIO, "seek", rb_io_seek, -1);
+ rb_define_method(rb_cIO, "seek", rb_io_seek_m, -1);
rb_define_const(rb_cIO, "SEEK_SET", INT2FIX(SEEK_SET));
rb_define_const(rb_cIO, "SEEK_CUR", INT2FIX(SEEK_CUR));
rb_define_const(rb_cIO, "SEEK_END", INT2FIX(SEEK_END));
@@ -3548,7 +3563,7 @@ Init_IO()
rb_define_singleton_method(argf, "getc", argf_getc, 0);
rb_define_singleton_method(argf, "readchar", argf_readchar, 0);
rb_define_singleton_method(argf, "tell", argf_tell, 0);
- rb_define_singleton_method(argf, "seek", argf_seek, 2);
+ rb_define_singleton_method(argf, "seek", argf_seek_m, -1);
rb_define_singleton_method(argf, "rewind", argf_rewind, 0);
rb_define_singleton_method(argf, "pos", argf_tell, 0);
rb_define_singleton_method(argf, "pos=", argf_set_pos, 1);
diff --git a/lib/delegate.rb b/lib/delegate.rb
index 480e1ef..a72ea94 100644
--- a/lib/delegate.rb
+++ b/lib/delegate.rb
@@ -8,7 +8,7 @@
# Usage:
# foo = Object.new
# foo2 = SimpleDelegator.new(foo)
-# foo.hash == foo2.hash # => true
+# foo.hash == foo2.hash # => false
#
# Foo = DelegateClass(Array)
#
diff --git a/lib/mkmf.rb b/lib/mkmf.rb
index 4692ea7..eb3cb74 100644
--- a/lib/mkmf.rb
+++ b/lib/mkmf.rb
@@ -375,7 +375,7 @@ def create_makefile(target, srcdir = File.dirname($0))
$DLDFLAGS = CONFIG["DLDFLAGS"]
$libs = CONFIG["LIBRUBYARG"] + " " + $libs
- $configure_args['--enable-shared'] or $LIBPATH |= ["$(topdir)"]
+ $configure_args['--enable-shared'] or $LIBPATH |= [$topdir]
$LIBPATH |= [CONFIG["libdir"]]
defflag = ''
diff --git a/lib/profile.rb b/lib/profile.rb
index b00caac..6f772ee 100644
--- a/lib/profile.rb
+++ b/lib/profile.rb
@@ -1,6 +1,7 @@
module Profiler__
- Start = Float(Time.times[0])
+ Times = if defined? Process.times then Process else Time end
+ Start = Float(Times::times[0])
top = "toplevel".intern
Stack = [[0, 0, top]]
MAP = {"#toplevel" => [1, 0, 0, "#toplevel"]}
@@ -8,10 +9,10 @@ module Profiler__
p = proc{|event, file, line, id, binding, klass|
case event
when "call", "c-call"
- now = Float(Time.times[0])
+ now = Float(Times::times[0])
Stack.push [now, 0.0, id]
when "return", "c-return"
- now = Float(Time.times[0])
+ now = Float(Times::times[0])
tick = Stack.pop
name = klass.to_s
if name.nil? then name = '' end
@@ -35,7 +36,7 @@ module Profiler__
}
END {
set_trace_func nil
- total = Float(Time.times[0]) - Start
+ total = Float(Times::times[0]) - Start
if total == 0 then total = 0.01 end
MAP["#toplevel"][1] = total
# f = open("./rmon.out", "w")
diff --git a/marshal.c b/marshal.c
index a7b13ef..35ceee9 100644
--- a/marshal.c
+++ b/marshal.c
@@ -1056,7 +1056,7 @@ marshal_load(argc, argv)
\tformat version %d.%d required; %d.%d given",
MARSHAL_MAJOR, MARSHAL_MINOR, major, minor);
}
- if (minor != MARSHAL_MINOR) {
+ if (ruby_verbose && minor != MARSHAL_MINOR) {
rb_warn("incompatible marshal file format (can be read)\n\
\tformat version %d.%d required; %d.%d given",
MARSHAL_MAJOR, MARSHAL_MINOR, major, minor);
diff --git a/math.c b/math.c
index b2d61f6..4af3cef 100644
--- a/math.c
+++ b/math.c
@@ -57,6 +57,62 @@ math_tan(obj, x)
}
static VALUE
+math_acos(obj, x)
+ VALUE obj, x;
+{
+ Need_Float(x);
+ /*
+ if (RFLOAT(x)->value < -1.0 || RFLOAT(x)->value > 1.0)
+ rb_raise(rb_eArgError, "Out of range (-1..1)");
+ */
+ return rb_float_new(acos(RFLOAT(x)->value));
+}
+
+static VALUE
+math_asin(obj, x)
+ VALUE obj, x;
+{
+ Need_Float(x);
+ /*
+ if (RFLOAT(x)->value < -1.0 || RFLOAT(x)->value > 1.0)
+ rb_raise(rb_eArgError, "Out of range (-1..1)");
+ */
+ return rb_float_new(asin(RFLOAT(x)->value));
+}
+
+static VALUE
+math_atan(obj, x)
+ VALUE obj, x;
+{
+ Need_Float(x);
+ return rb_float_new(atan(RFLOAT(x)->value));
+}
+
+static VALUE
+math_cosh(obj, x)
+ VALUE obj, x;
+{
+ Need_Float(x);
+ return rb_float_new(cosh(RFLOAT(x)->value));
+}
+
+static VALUE
+math_sinh(obj, x)
+ VALUE obj, x;
+{
+ Need_Float(x);
+ return rb_float_new(sinh(RFLOAT(x)->value));
+}
+
+static VALUE
+math_tanh(obj, x)
+ VALUE obj, x;
+{
+ Need_Float(x);
+ return rb_float_new(tanh(RFLOAT(x)->value));
+}
+
+static VALUE
math_exp(obj, x)
VALUE obj, x;
{
@@ -118,6 +174,14 @@ math_ldexp(obj, x, n)
return rb_float_new(d = ldexp(RFLOAT(x)->value, NUM2INT(n)));
}
+static VALUE
+math_hypot(obj, x, y)
+ VALUE obj, x, y;
+{
+ Need_Float2(x, y);
+ return rb_float_new(hypot(RFLOAT(x)->value, RFLOAT(y)->value));
+}
+
void
Init_Math()
{
@@ -140,6 +204,14 @@ Init_Math()
rb_define_module_function(rb_mMath, "sin", math_sin, 1);
rb_define_module_function(rb_mMath, "tan", math_tan, 1);
+ rb_define_module_function(rb_mMath, "acos", math_acos, 1);
+ rb_define_module_function(rb_mMath, "asin", math_asin, 1);
+ rb_define_module_function(rb_mMath, "atan", math_atan, 1);
+
+ rb_define_module_function(rb_mMath, "cosh", math_cosh, 1);
+ rb_define_module_function(rb_mMath, "sinh", math_sinh, 1);
+ rb_define_module_function(rb_mMath, "tanh", math_tanh, 1);
+
rb_define_module_function(rb_mMath, "exp", math_exp, 1);
rb_define_module_function(rb_mMath, "log", math_log, 1);
rb_define_module_function(rb_mMath, "log10", math_log10, 1);
@@ -147,4 +219,6 @@ Init_Math()
rb_define_module_function(rb_mMath, "frexp", math_frexp, 1);
rb_define_module_function(rb_mMath, "ldexp", math_ldexp, 2);
+
+ rb_define_module_function(rb_mMath, "hypot", math_hypot, 2);
}
diff --git a/missing/hypot.c b/missing/hypot.c
new file mode 100644
index 0000000..aad5259
--- /dev/null
+++ b/missing/hypot.c
@@ -0,0 +1,17 @@
+/* public domain rewrite of hypot */
+
+#include <math.h>
+
+double hypot(x,y)
+ double x, y;
+{
+ if (x < 0) x = -x;
+ if (y < 0) y = -y;
+ if (x < y) {
+ double tmp = x;
+ x = y; y = tmp;
+ }
+ if (y == 0.0) return x;
+ y /= x;
+ return x * sqrt(1.0+y*y);
+}
diff --git a/numeric.c b/numeric.c
index 8e37269..dc8a788 100644
--- a/numeric.c
+++ b/numeric.c
@@ -947,7 +947,7 @@ rb_fix2str(x, base)
else if (base == 8) fmt[2] = 'o';
else rb_fatal("fixnum cannot treat base %d", base);
- snprintf(buf, 22, fmt, FIX2LONG(x));
+ sprintf(buf, fmt, FIX2LONG(x));
return rb_str_new2(buf);
}
diff --git a/object.c b/object.c
index 34a17dd..071dfb1 100644
--- a/object.c
+++ b/object.c
@@ -513,8 +513,8 @@ sym_inspect(sym)
name = rb_id2name(SYM2ID(sym));
str = rb_str_new(0, strlen(name)+2);
- sprintf(RSTRING(str)->ptr, ":%s", name);
- RSTRING(str)->len = strlen(RSTRING(str)->ptr);
+ RSTRING(str)->ptr[0] = ':';
+ strcpy(RSTRING(str)->ptr+1, name);
return str;
}
diff --git a/parse.y b/parse.y
index 93a4bf6..ec4c9b3 100644
--- a/parse.y
+++ b/parse.y
@@ -233,6 +233,7 @@ static void top_local_setup();
%token <id> tOP_ASGN /* +=, -= etc. */
%token tASSOC /* => */
%token tLPAREN /* ( */
+%token tRPAREN /* ) */
%token tLBRACK /* [ */
%token tLBRACE /* { */
%token tSTAR /* * */
@@ -360,31 +361,21 @@ stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem
| stmt kWHILE_MOD expr
{
value_expr($3);
- if ($1) {
- if (nd_type($1) == NODE_BEGIN) {
- $$ = NEW_WHILE(cond($3), $1->nd_body, 0);
- }
- else {
- $$ = NEW_WHILE(cond($3), $1, 1);
- }
+ if ($1 && nd_type($1) == NODE_BEGIN) {
+ $$ = NEW_WHILE(cond($3), $1->nd_body, 0);
}
else {
- $$ = 0;
+ $$ = NEW_WHILE(cond($3), $1, 1);
}
}
| stmt kUNTIL_MOD expr
{
value_expr($3);
- if ($1) {
- if (nd_type($1) == NODE_BEGIN) {
- $$ = NEW_UNTIL(cond($3), $1->nd_body, 0);
- }
- else {
- $$ = NEW_UNTIL(cond($3), $1, 1);
- }
+ if ($1 && nd_type($1) == NODE_BEGIN) {
+ $$ = NEW_UNTIL(cond($3), $1->nd_body, 0);
}
else {
- $$ = 0;
+ $$ = NEW_UNTIL(cond($3), $1, 1);
}
}
| stmt kRESCUE_MOD stmt
@@ -4470,20 +4461,20 @@ static void
warn_unless_e_option(str)
const char *str;
{
- if (e_option_supplied()) rb_warn(str);
+ if (!e_option_supplied()) rb_warn(str);
}
static void
warning_unless_e_option(str)
const char *str;
{
- if (e_option_supplied()) rb_warning(str);
+ if (!e_option_supplied()) rb_warning(str);
}
static NODE *cond0();
static NODE*
-cond2(node, logop)
+range_op(node, logop)
NODE *node;
int logop;
{
@@ -4512,39 +4503,31 @@ cond0(node, logop)
assign_in_cond(node);
switch (type) {
case NODE_DSTR:
+ case NODE_STR:
if (logop) break;
- nd_set_type(node, NODE_DREGX);
- warn_unless_e_option("string literal in condition");
- goto dregex;
+ warn("string literal in condition");
+ break;
case NODE_DREGX:
case NODE_DREGX_ONCE:
warning_unless_e_option("regex literal in condition");
- dregex:
local_cnt('_');
local_cnt('~');
return NEW_MATCH2(node, NEW_GVAR(rb_intern("$_")));
case NODE_DOT2:
case NODE_DOT3:
- node->nd_beg = cond2(node->nd_beg, logop);
- node->nd_end = cond2(node->nd_end, logop);
+ node->nd_beg = range_op(node->nd_beg, logop);
+ node->nd_end = range_op(node->nd_end, logop);
if (type == NODE_DOT2) nd_set_type(node,NODE_FLIP2);
else if (type == NODE_DOT3) nd_set_type(node, NODE_FLIP3);
node->nd_cnt = local_append(0);
warn_unless_e_option("range literal in condition");
break;
- case NODE_STR:
- if (logop) break;
- node->nd_lit = rb_reg_new(RSTRING(node->nd_lit)->ptr,RSTRING(node->nd_lit)->len,0);
- warn_unless_e_option("string literal in condition");
- goto regexp;
-
case NODE_LIT:
if (TYPE(node->nd_lit) == T_REGEXP) {
warning_unless_e_option("regex literal in condition");
- regexp:
nd_set_type(node, NODE_MATCH);
local_cnt('_');
local_cnt('~');
diff --git a/ruby.c b/ruby.c
index 7d11ab1..55bef5d 100644
--- a/ruby.c
+++ b/ruby.c
@@ -430,7 +430,7 @@ proc_options(argc, argv)
goto reswitch;
case 'v':
- if (verbose) {
+ if (argv0 == 0 || verbose) {
s++;
goto reswitch;
}
@@ -990,6 +990,7 @@ ruby_set_argv(argc, argv)
if (origargv) dln_argv0 = origargv[0];
else dln_argv0 = argv[0];
#endif
+ rb_ary_clear(rb_argv);
for (i=0; i < argc; i++) {
rb_ary_push(rb_argv, rb_tainted_str_new2(argv[i]));
}
diff --git a/version.h b/version.h
index 237e936..6ae7e2e 100644
--- a/version.h
+++ b/version.h
@@ -1,4 +1,4 @@
#define RUBY_VERSION "1.7.0"
-#define RUBY_RELEASE_DATE "2001-03-12"
+#define RUBY_RELEASE_DATE "2001-03-13"
#define RUBY_VERSION_CODE 170
-#define RUBY_RELEASE_CODE 20010312
+#define RUBY_RELEASE_CODE 20010313