mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
8fc5876485
commit
e502549be1
20 changed files with 266 additions and 71 deletions
52
ChangeLog
52
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>
|
Mon Mar 12 18:59:38 2001 WATANABE Hirofumi <eban@ruby-lang.org>
|
||||||
|
|
||||||
* lib/mkmf.rb (create_makefile): save/restore $libs and $LIBPATH.
|
* 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>
|
Sun Mar 11 00:55:31 2001 WATANABE Hirofumi <eban@ruby-lang.org>
|
||||||
|
|
||||||
* lib/mkmf.rb (install_rb): fix handling of destination path.
|
* 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>
|
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.
|
* 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>
|
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.
|
* 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
|
* math.c (math_log, math_log10): should return NaN if x < 0.0
|
||||||
on Cygwin.
|
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>
|
Tue Mar 6 10:50:29 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* parse.y (primary): rescue and ensure clauses should be allowed
|
* parse.y (primary): rescue and ensure clauses should be allowed
|
||||||
|
|
1
MANIFEST
1
MANIFEST
|
@ -167,6 +167,7 @@ missing/dup2.c
|
||||||
missing/file.h
|
missing/file.h
|
||||||
missing/finite.c
|
missing/finite.c
|
||||||
missing/flock.c
|
missing/flock.c
|
||||||
|
missing/hypot.c
|
||||||
missing/isinf.c
|
missing/isinf.c
|
||||||
missing/isnan.c
|
missing/isnan.c
|
||||||
missing/memcmp.c
|
missing/memcmp.c
|
||||||
|
|
4
array.c
4
array.c
|
@ -1100,7 +1100,7 @@ rb_ary_delete_at(ary, pos)
|
||||||
return del;
|
return del;
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE
|
static VALUE
|
||||||
rb_ary_delete_at_m(ary, pos)
|
rb_ary_delete_at_m(ary, pos)
|
||||||
VALUE ary, pos;
|
VALUE ary, pos;
|
||||||
{
|
{
|
||||||
|
@ -1186,7 +1186,7 @@ rb_ary_replace_m(ary, ary2)
|
||||||
return ary;
|
return ary;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
VALUE
|
||||||
rb_ary_clear(ary)
|
rb_ary_clear(ary)
|
||||||
VALUE ary;
|
VALUE ary;
|
||||||
{
|
{
|
||||||
|
|
|
@ -255,7 +255,7 @@ AC_FUNC_VFORK
|
||||||
AC_FUNC_MEMCMP
|
AC_FUNC_MEMCMP
|
||||||
AC_REPLACE_FUNCS(dup2 memmove mkdir strcasecmp strncasecmp strerror strftime\
|
AC_REPLACE_FUNCS(dup2 memmove mkdir strcasecmp strncasecmp strerror strftime\
|
||||||
strchr strstr strtoul crypt flock vsnprintf\
|
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\
|
AC_CHECK_FUNCS(fmod killpg drand48 random wait4 waitpid syscall getcwd chroot\
|
||||||
truncate chsize times utimes fcntl lockf lstat symlink readlink\
|
truncate chsize times utimes fcntl lockf lstat symlink readlink\
|
||||||
setitimer setruid seteuid setreuid setresuid \
|
setitimer setruid seteuid setreuid setresuid \
|
||||||
|
|
6
dln.c
6
dln.c
|
@ -84,9 +84,9 @@ int eaccess();
|
||||||
|
|
||||||
#ifndef FUNCNAME_PATTERN
|
#ifndef FUNCNAME_PATTERN
|
||||||
# if defined(__hp9000s300) || (defined(__NetBSD__) && !defined(__ELF__)) || defined(__BORLANDC__) || (defined(__FreeBSD__) && __FreeBSD__ < 3) || defined(__OpenBSD__) || defined(NeXT) || defined(__WATCOMC__) || defined(__APPLE__)
|
# 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
|
# else
|
||||||
# define FUNCNAME_PATTERN "Init_%.200s"
|
# define FUNCNAME_PATTERN "Init_%s"
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1194,7 +1194,7 @@ aix_loaderror(const char *pathname)
|
||||||
#define LOAD_ERRTAB_LEN (sizeof(load_errtab)/sizeof(load_errtab[0]))
|
#define LOAD_ERRTAB_LEN (sizeof(load_errtab)/sizeof(load_errtab[0]))
|
||||||
#define ERRBUF_APPEND(s) strncat(errbuf, s, sizeof(errbuf)-strlen(errbuf)-1)
|
#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)))
|
if (!loadquery(1, &message[0], sizeof(message)))
|
||||||
ERRBUF_APPEND(strerror(errno));
|
ERRBUF_APPEND(strerror(errno));
|
||||||
|
|
58
enum.c
58
enum.c
|
@ -87,10 +87,10 @@ enum_find(argc, argv, obj)
|
||||||
rb_gc_force_recycle((VALUE)memo);
|
rb_gc_force_recycle((VALUE)memo);
|
||||||
return memo->u1.value;
|
return memo->u1.value;
|
||||||
}
|
}
|
||||||
|
rb_gc_force_recycle((VALUE)memo);
|
||||||
if (!NIL_P(if_none)) {
|
if (!NIL_P(if_none)) {
|
||||||
rb_eval_cmd(if_none, rb_ary_new2(0));
|
rb_eval_cmd(if_none, rb_ary_new2(0));
|
||||||
}
|
}
|
||||||
rb_gc_force_recycle((VALUE)memo);
|
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ collect_i(i, tmp)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
enum_all(i, ary)
|
collect_all(i, ary)
|
||||||
VALUE i, ary;
|
VALUE i, ary;
|
||||||
{
|
{
|
||||||
rb_ary_push(ary, i);
|
rb_ary_push(ary, i);
|
||||||
|
@ -161,7 +161,7 @@ enum_to_a(obj)
|
||||||
VALUE ary;
|
VALUE ary;
|
||||||
|
|
||||||
ary = rb_ary_new();
|
ary = rb_ary_new();
|
||||||
rb_iterate(rb_each, obj, enum_all, ary);
|
rb_iterate(rb_each, obj, collect_all, ary);
|
||||||
|
|
||||||
return ary;
|
return ary;
|
||||||
}
|
}
|
||||||
|
@ -173,7 +173,7 @@ enum_collect(obj)
|
||||||
VALUE tmp;
|
VALUE tmp;
|
||||||
|
|
||||||
tmp = rb_ary_new();
|
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;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
@ -203,6 +203,54 @@ enum_sort(obj)
|
||||||
return rb_ary_sort(enum_to_a(obj));
|
return rb_ary_sort(enum_to_a(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
|
static VALUE
|
||||||
min_i(i, memo)
|
min_i(i, memo)
|
||||||
VALUE i;
|
VALUE i;
|
||||||
|
@ -358,6 +406,8 @@ Init_Enumerable()
|
||||||
rb_define_method(rb_mEnumerable,"collect", enum_collect, 0);
|
rb_define_method(rb_mEnumerable,"collect", enum_collect, 0);
|
||||||
rb_define_method(rb_mEnumerable,"map", 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,"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,"min", enum_min, 0);
|
||||||
rb_define_method(rb_mEnumerable,"max", enum_max, 0);
|
rb_define_method(rb_mEnumerable,"max", enum_max, 0);
|
||||||
rb_define_method(rb_mEnumerable,"member?", enum_member, 1);
|
rb_define_method(rb_mEnumerable,"member?", enum_member, 1);
|
||||||
|
|
6
eval.c
6
eval.c
|
@ -3315,7 +3315,7 @@ rb_exit(status)
|
||||||
VALUE exit;
|
VALUE exit;
|
||||||
|
|
||||||
exit_status = status;
|
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_iv_set(exit, "status", INT2NUM(status));
|
||||||
rb_exc_raise(exit);
|
rb_exc_raise(exit);
|
||||||
}
|
}
|
||||||
|
@ -4152,7 +4152,7 @@ stack_length(p)
|
||||||
#endif
|
#endif
|
||||||
if (p) *p = STACK_END;
|
if (p) *p = STACK_END;
|
||||||
|
|
||||||
#ifdef sparc
|
#ifdef __sparc__
|
||||||
return rb_gc_stack_start - STACK_END + 0x80;
|
return rb_gc_stack_start - STACK_END + 0x80;
|
||||||
#else
|
#else
|
||||||
return (STACK_END < rb_gc_stack_start) ? rb_gc_stack_start - STACK_END
|
return (STACK_END < rb_gc_stack_start) ? rb_gc_stack_start - STACK_END
|
||||||
|
@ -6445,7 +6445,7 @@ block_pass(self, node)
|
||||||
break;
|
break;
|
||||||
case TAG_BREAK:
|
case TAG_BREAK:
|
||||||
if (orphan) {
|
if (orphan) {
|
||||||
rb_raise(rb_eLocalJumpError, "retry from proc-closure");
|
rb_raise(rb_eLocalJumpError, "break from proc-closure");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TAG_RETRY:
|
case TAG_RETRY:
|
||||||
|
|
1
intern.h
1
intern.h
|
@ -41,6 +41,7 @@ VALUE rb_ary_sort _((VALUE));
|
||||||
VALUE rb_ary_sort_bang _((VALUE));
|
VALUE rb_ary_sort_bang _((VALUE));
|
||||||
VALUE rb_ary_delete _((VALUE, VALUE));
|
VALUE rb_ary_delete _((VALUE, VALUE));
|
||||||
VALUE rb_ary_delete_at _((VALUE, long));
|
VALUE rb_ary_delete_at _((VALUE, long));
|
||||||
|
VALUE rb_ary_clear _((VALUE));
|
||||||
VALUE rb_ary_plus _((VALUE, VALUE));
|
VALUE rb_ary_plus _((VALUE, VALUE));
|
||||||
VALUE rb_ary_concat _((VALUE, VALUE));
|
VALUE rb_ary_concat _((VALUE, VALUE));
|
||||||
VALUE rb_ary_assoc _((VALUE, VALUE));
|
VALUE rb_ary_assoc _((VALUE, VALUE));
|
||||||
|
|
41
io.c
41
io.c
|
@ -317,7 +317,23 @@ rb_io_tell(io)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static VALUE
|
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;
|
int argc;
|
||||||
VALUE *argv;
|
VALUE *argv;
|
||||||
VALUE io;
|
VALUE io;
|
||||||
|
@ -331,12 +347,7 @@ rb_io_seek(argc, argv, io)
|
||||||
if (argc == 1) whence = SEEK_SET;
|
if (argc == 1) whence = SEEK_SET;
|
||||||
else whence = NUM2INT(ptrname);
|
else whence = NUM2INT(ptrname);
|
||||||
|
|
||||||
GetOpenFile(io, fptr);
|
return rb_io_seek(io, offset, whence);
|
||||||
pos = fseek(fptr->f, NUM2INT(offset), whence);
|
|
||||||
if (pos != 0) rb_sys_fail(fptr->path);
|
|
||||||
clearerr(fptr->f);
|
|
||||||
|
|
||||||
return INT2FIX(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
@ -3148,7 +3159,7 @@ rb_io_s_read(argc, argv, io)
|
||||||
arg.io = rb_io_open(RSTRING(fname)->ptr, "r");
|
arg.io = rb_io_open(RSTRING(fname)->ptr, "r");
|
||||||
if (NIL_P(arg.io)) return Qnil;
|
if (NIL_P(arg.io)) return Qnil;
|
||||||
if (!NIL_P(offset)) {
|
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);
|
return rb_ensure(io_s_read, (VALUE)&arg, rb_io_close, arg.io);
|
||||||
}
|
}
|
||||||
|
@ -3167,9 +3178,13 @@ argf_tell()
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
argf_seek(self, offset, ptrname)
|
argf_seek_m(argc, argv, self)
|
||||||
VALUE self, offset, ptrname;
|
int argc;
|
||||||
|
VALUE *argv;
|
||||||
|
VALUE self;
|
||||||
{
|
{
|
||||||
|
VALUE args[2];
|
||||||
|
|
||||||
if (!next_argv()) {
|
if (!next_argv()) {
|
||||||
rb_raise(rb_eArgError, "no stream to seek");
|
rb_raise(rb_eArgError, "no stream to seek");
|
||||||
}
|
}
|
||||||
|
@ -3177,7 +3192,7 @@ argf_seek(self, offset, ptrname)
|
||||||
if (TYPE(current_file) != T_FILE) {
|
if (TYPE(current_file) != T_FILE) {
|
||||||
return argf_forward();
|
return argf_forward();
|
||||||
}
|
}
|
||||||
return rb_io_seek(current_file, offset, ptrname);
|
return rb_io_seek_m(argc, argv, current_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
@ -3490,7 +3505,7 @@ Init_IO()
|
||||||
rb_define_method(rb_cIO, "<<", rb_io_addstr, 1);
|
rb_define_method(rb_cIO, "<<", rb_io_addstr, 1);
|
||||||
rb_define_method(rb_cIO, "flush", rb_io_flush, 0);
|
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, "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_SET", INT2FIX(SEEK_SET));
|
||||||
rb_define_const(rb_cIO, "SEEK_CUR", INT2FIX(SEEK_CUR));
|
rb_define_const(rb_cIO, "SEEK_CUR", INT2FIX(SEEK_CUR));
|
||||||
rb_define_const(rb_cIO, "SEEK_END", INT2FIX(SEEK_END));
|
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, "getc", argf_getc, 0);
|
||||||
rb_define_singleton_method(argf, "readchar", argf_readchar, 0);
|
rb_define_singleton_method(argf, "readchar", argf_readchar, 0);
|
||||||
rb_define_singleton_method(argf, "tell", argf_tell, 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, "rewind", argf_rewind, 0);
|
||||||
rb_define_singleton_method(argf, "pos", argf_tell, 0);
|
rb_define_singleton_method(argf, "pos", argf_tell, 0);
|
||||||
rb_define_singleton_method(argf, "pos=", argf_set_pos, 1);
|
rb_define_singleton_method(argf, "pos=", argf_set_pos, 1);
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
# Usage:
|
# Usage:
|
||||||
# foo = Object.new
|
# foo = Object.new
|
||||||
# foo2 = SimpleDelegator.new(foo)
|
# foo2 = SimpleDelegator.new(foo)
|
||||||
# foo.hash == foo2.hash # => true
|
# foo.hash == foo2.hash # => false
|
||||||
#
|
#
|
||||||
# Foo = DelegateClass(Array)
|
# Foo = DelegateClass(Array)
|
||||||
#
|
#
|
||||||
|
|
|
@ -375,7 +375,7 @@ def create_makefile(target, srcdir = File.dirname($0))
|
||||||
$DLDFLAGS = CONFIG["DLDFLAGS"]
|
$DLDFLAGS = CONFIG["DLDFLAGS"]
|
||||||
|
|
||||||
$libs = CONFIG["LIBRUBYARG"] + " " + $libs
|
$libs = CONFIG["LIBRUBYARG"] + " " + $libs
|
||||||
$configure_args['--enable-shared'] or $LIBPATH |= ["$(topdir)"]
|
$configure_args['--enable-shared'] or $LIBPATH |= [$topdir]
|
||||||
$LIBPATH |= [CONFIG["libdir"]]
|
$LIBPATH |= [CONFIG["libdir"]]
|
||||||
|
|
||||||
defflag = ''
|
defflag = ''
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
|
|
||||||
module Profiler__
|
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
|
top = "toplevel".intern
|
||||||
Stack = [[0, 0, top]]
|
Stack = [[0, 0, top]]
|
||||||
MAP = {"#toplevel" => [1, 0, 0, "#toplevel"]}
|
MAP = {"#toplevel" => [1, 0, 0, "#toplevel"]}
|
||||||
|
@ -8,10 +9,10 @@ module Profiler__
|
||||||
p = proc{|event, file, line, id, binding, klass|
|
p = proc{|event, file, line, id, binding, klass|
|
||||||
case event
|
case event
|
||||||
when "call", "c-call"
|
when "call", "c-call"
|
||||||
now = Float(Time.times[0])
|
now = Float(Times::times[0])
|
||||||
Stack.push [now, 0.0, id]
|
Stack.push [now, 0.0, id]
|
||||||
when "return", "c-return"
|
when "return", "c-return"
|
||||||
now = Float(Time.times[0])
|
now = Float(Times::times[0])
|
||||||
tick = Stack.pop
|
tick = Stack.pop
|
||||||
name = klass.to_s
|
name = klass.to_s
|
||||||
if name.nil? then name = '' end
|
if name.nil? then name = '' end
|
||||||
|
@ -35,7 +36,7 @@ module Profiler__
|
||||||
}
|
}
|
||||||
END {
|
END {
|
||||||
set_trace_func nil
|
set_trace_func nil
|
||||||
total = Float(Time.times[0]) - Start
|
total = Float(Times::times[0]) - Start
|
||||||
if total == 0 then total = 0.01 end
|
if total == 0 then total = 0.01 end
|
||||||
MAP["#toplevel"][1] = total
|
MAP["#toplevel"][1] = total
|
||||||
# f = open("./rmon.out", "w")
|
# f = open("./rmon.out", "w")
|
||||||
|
|
|
@ -1056,7 +1056,7 @@ marshal_load(argc, argv)
|
||||||
\tformat version %d.%d required; %d.%d given",
|
\tformat version %d.%d required; %d.%d given",
|
||||||
MARSHAL_MAJOR, MARSHAL_MINOR, major, minor);
|
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\
|
rb_warn("incompatible marshal file format (can be read)\n\
|
||||||
\tformat version %d.%d required; %d.%d given",
|
\tformat version %d.%d required; %d.%d given",
|
||||||
MARSHAL_MAJOR, MARSHAL_MINOR, major, minor);
|
MARSHAL_MAJOR, MARSHAL_MINOR, major, minor);
|
||||||
|
|
74
math.c
74
math.c
|
@ -56,6 +56,62 @@ math_tan(obj, x)
|
||||||
return rb_float_new(tan(RFLOAT(x)->value));
|
return rb_float_new(tan(RFLOAT(x)->value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
static VALUE
|
||||||
math_exp(obj, x)
|
math_exp(obj, x)
|
||||||
VALUE 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)));
|
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
|
void
|
||||||
Init_Math()
|
Init_Math()
|
||||||
{
|
{
|
||||||
|
@ -140,6 +204,14 @@ Init_Math()
|
||||||
rb_define_module_function(rb_mMath, "sin", math_sin, 1);
|
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, "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, "exp", math_exp, 1);
|
||||||
rb_define_module_function(rb_mMath, "log", math_log, 1);
|
rb_define_module_function(rb_mMath, "log", math_log, 1);
|
||||||
rb_define_module_function(rb_mMath, "log10", math_log10, 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, "frexp", math_frexp, 1);
|
||||||
rb_define_module_function(rb_mMath, "ldexp", math_ldexp, 2);
|
rb_define_module_function(rb_mMath, "ldexp", math_ldexp, 2);
|
||||||
|
|
||||||
|
rb_define_module_function(rb_mMath, "hypot", math_hypot, 2);
|
||||||
}
|
}
|
||||||
|
|
17
missing/hypot.c
Normal file
17
missing/hypot.c
Normal file
|
@ -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);
|
||||||
|
}
|
|
@ -947,7 +947,7 @@ rb_fix2str(x, base)
|
||||||
else if (base == 8) fmt[2] = 'o';
|
else if (base == 8) fmt[2] = 'o';
|
||||||
else rb_fatal("fixnum cannot treat base %d", base);
|
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);
|
return rb_str_new2(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
4
object.c
4
object.c
|
@ -513,8 +513,8 @@ sym_inspect(sym)
|
||||||
|
|
||||||
name = rb_id2name(SYM2ID(sym));
|
name = rb_id2name(SYM2ID(sym));
|
||||||
str = rb_str_new(0, strlen(name)+2);
|
str = rb_str_new(0, strlen(name)+2);
|
||||||
sprintf(RSTRING(str)->ptr, ":%s", name);
|
RSTRING(str)->ptr[0] = ':';
|
||||||
RSTRING(str)->len = strlen(RSTRING(str)->ptr);
|
strcpy(RSTRING(str)->ptr+1, name);
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
39
parse.y
39
parse.y
|
@ -233,6 +233,7 @@ static void top_local_setup();
|
||||||
%token <id> tOP_ASGN /* +=, -= etc. */
|
%token <id> tOP_ASGN /* +=, -= etc. */
|
||||||
%token tASSOC /* => */
|
%token tASSOC /* => */
|
||||||
%token tLPAREN /* ( */
|
%token tLPAREN /* ( */
|
||||||
|
%token tRPAREN /* ) */
|
||||||
%token tLBRACK /* [ */
|
%token tLBRACK /* [ */
|
||||||
%token tLBRACE /* { */
|
%token tLBRACE /* { */
|
||||||
%token tSTAR /* * */
|
%token tSTAR /* * */
|
||||||
|
@ -360,33 +361,23 @@ stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem
|
||||||
| stmt kWHILE_MOD expr
|
| stmt kWHILE_MOD expr
|
||||||
{
|
{
|
||||||
value_expr($3);
|
value_expr($3);
|
||||||
if ($1) {
|
if ($1 && nd_type($1) == NODE_BEGIN) {
|
||||||
if (nd_type($1) == NODE_BEGIN) {
|
|
||||||
$$ = NEW_WHILE(cond($3), $1->nd_body, 0);
|
$$ = NEW_WHILE(cond($3), $1->nd_body, 0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$$ = NEW_WHILE(cond($3), $1, 1);
|
$$ = NEW_WHILE(cond($3), $1, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
$$ = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
| stmt kUNTIL_MOD expr
|
| stmt kUNTIL_MOD expr
|
||||||
{
|
{
|
||||||
value_expr($3);
|
value_expr($3);
|
||||||
if ($1) {
|
if ($1 && nd_type($1) == NODE_BEGIN) {
|
||||||
if (nd_type($1) == NODE_BEGIN) {
|
|
||||||
$$ = NEW_UNTIL(cond($3), $1->nd_body, 0);
|
$$ = NEW_UNTIL(cond($3), $1->nd_body, 0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$$ = NEW_UNTIL(cond($3), $1, 1);
|
$$ = NEW_UNTIL(cond($3), $1, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
$$ = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
| stmt kRESCUE_MOD stmt
|
| stmt kRESCUE_MOD stmt
|
||||||
{
|
{
|
||||||
$$ = NEW_RESCUE($1, NEW_RESBODY(0,$3,0), 0);
|
$$ = NEW_RESCUE($1, NEW_RESBODY(0,$3,0), 0);
|
||||||
|
@ -4470,20 +4461,20 @@ static void
|
||||||
warn_unless_e_option(str)
|
warn_unless_e_option(str)
|
||||||
const char *str;
|
const char *str;
|
||||||
{
|
{
|
||||||
if (e_option_supplied()) rb_warn(str);
|
if (!e_option_supplied()) rb_warn(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
warning_unless_e_option(str)
|
warning_unless_e_option(str)
|
||||||
const char *str;
|
const char *str;
|
||||||
{
|
{
|
||||||
if (e_option_supplied()) rb_warning(str);
|
if (!e_option_supplied()) rb_warning(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
static NODE *cond0();
|
static NODE *cond0();
|
||||||
|
|
||||||
static NODE*
|
static NODE*
|
||||||
cond2(node, logop)
|
range_op(node, logop)
|
||||||
NODE *node;
|
NODE *node;
|
||||||
int logop;
|
int logop;
|
||||||
{
|
{
|
||||||
|
@ -4512,39 +4503,31 @@ cond0(node, logop)
|
||||||
assign_in_cond(node);
|
assign_in_cond(node);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case NODE_DSTR:
|
case NODE_DSTR:
|
||||||
|
case NODE_STR:
|
||||||
if (logop) break;
|
if (logop) break;
|
||||||
nd_set_type(node, NODE_DREGX);
|
warn("string literal in condition");
|
||||||
warn_unless_e_option("string literal in condition");
|
break;
|
||||||
goto dregex;
|
|
||||||
|
|
||||||
case NODE_DREGX:
|
case NODE_DREGX:
|
||||||
case NODE_DREGX_ONCE:
|
case NODE_DREGX_ONCE:
|
||||||
warning_unless_e_option("regex literal in condition");
|
warning_unless_e_option("regex literal in condition");
|
||||||
dregex:
|
|
||||||
local_cnt('_');
|
local_cnt('_');
|
||||||
local_cnt('~');
|
local_cnt('~');
|
||||||
return NEW_MATCH2(node, NEW_GVAR(rb_intern("$_")));
|
return NEW_MATCH2(node, NEW_GVAR(rb_intern("$_")));
|
||||||
|
|
||||||
case NODE_DOT2:
|
case NODE_DOT2:
|
||||||
case NODE_DOT3:
|
case NODE_DOT3:
|
||||||
node->nd_beg = cond2(node->nd_beg, logop);
|
node->nd_beg = range_op(node->nd_beg, logop);
|
||||||
node->nd_end = cond2(node->nd_end, logop);
|
node->nd_end = range_op(node->nd_end, logop);
|
||||||
if (type == NODE_DOT2) nd_set_type(node,NODE_FLIP2);
|
if (type == NODE_DOT2) nd_set_type(node,NODE_FLIP2);
|
||||||
else if (type == NODE_DOT3) nd_set_type(node, NODE_FLIP3);
|
else if (type == NODE_DOT3) nd_set_type(node, NODE_FLIP3);
|
||||||
node->nd_cnt = local_append(0);
|
node->nd_cnt = local_append(0);
|
||||||
warn_unless_e_option("range literal in condition");
|
warn_unless_e_option("range literal in condition");
|
||||||
break;
|
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:
|
case NODE_LIT:
|
||||||
if (TYPE(node->nd_lit) == T_REGEXP) {
|
if (TYPE(node->nd_lit) == T_REGEXP) {
|
||||||
warning_unless_e_option("regex literal in condition");
|
warning_unless_e_option("regex literal in condition");
|
||||||
regexp:
|
|
||||||
nd_set_type(node, NODE_MATCH);
|
nd_set_type(node, NODE_MATCH);
|
||||||
local_cnt('_');
|
local_cnt('_');
|
||||||
local_cnt('~');
|
local_cnt('~');
|
||||||
|
|
3
ruby.c
3
ruby.c
|
@ -430,7 +430,7 @@ proc_options(argc, argv)
|
||||||
goto reswitch;
|
goto reswitch;
|
||||||
|
|
||||||
case 'v':
|
case 'v':
|
||||||
if (verbose) {
|
if (argv0 == 0 || verbose) {
|
||||||
s++;
|
s++;
|
||||||
goto reswitch;
|
goto reswitch;
|
||||||
}
|
}
|
||||||
|
@ -990,6 +990,7 @@ ruby_set_argv(argc, argv)
|
||||||
if (origargv) dln_argv0 = origargv[0];
|
if (origargv) dln_argv0 = origargv[0];
|
||||||
else dln_argv0 = argv[0];
|
else dln_argv0 = argv[0];
|
||||||
#endif
|
#endif
|
||||||
|
rb_ary_clear(rb_argv);
|
||||||
for (i=0; i < argc; i++) {
|
for (i=0; i < argc; i++) {
|
||||||
rb_ary_push(rb_argv, rb_tainted_str_new2(argv[i]));
|
rb_ary_push(rb_argv, rb_tainted_str_new2(argv[i]));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#define RUBY_VERSION "1.7.0"
|
#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_VERSION_CODE 170
|
||||||
#define RUBY_RELEASE_CODE 20010312
|
#define RUBY_RELEASE_CODE 20010313
|
||||||
|
|
Loading…
Add table
Reference in a new issue