yarv-diff:125
From: ko1 atdot.net
Date: 27 Oct 2005 02:54:31 -0000
Subject: [yarv-diff:125] r281 - in trunk: . win32 yarvtest
Author: ko1
Date: 2005-10-27 11:54:30 +0900 (Thu, 27 Oct 2005)
New Revision: 281
Modified:
trunk/ChangeLog
trunk/bignum.c
trunk/defines.h
trunk/disasm.c
trunk/enum.c
trunk/eval.c
trunk/eval_method.h
trunk/file.c
trunk/gc.c
trunk/insns.def
trunk/intern.h
trunk/io.c
trunk/node.h
trunk/numeric.c
trunk/object.c
trunk/pack.c
trunk/parse.y
trunk/process.c
trunk/range.c
trunk/ruby.h
trunk/test.rb
trunk/util.c
trunk/util.h
trunk/variable.c
trunk/version.h
trunk/win32/win32.c
trunk/yarvtest/test_bin.rb
Log:
* some files : import from ruby 1.9.0 (2005-10-12)
* insns.def, compile.c, yarvcore.h, yarvcore.c : add insns "bitblt" and "answer"
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2005-10-16 14:41:33 UTC (rev 280)
+++ trunk/ChangeLog 2005-10-27 02:54:30 UTC (rev 281)
@@ -4,6 +4,11 @@
# from Mon, 03 May 2004 01:24:19 +0900
#
+2005-10-27(Thu) 11:50:15 +0900 Koichi Sasada <ko1 atdot.net>
+
+ * some files : import from ruby 1.9.0 (2005-10-12)
+
+
2005-10-16(Sun) 14:50:02 +0900 Koichi Sasada <ko1 atdot.net>
* insns.def, compile.c, yarvcore.h, yarvcore.c : add insns "bitblt" and "answer"
Modified: trunk/bignum.c
===================================================================
--- trunk/bignum.c 2005-10-16 14:41:33 UTC (rev 280)
+++ trunk/bignum.c 2005-10-27 02:54:30 UTC (rev 281)
@@ -2,8 +2,8 @@
bignum.c -
- $Author: ocean $
- $Date: 2005/09/14 06:32:29 $
+ $Author: akr $
+ $Date: 2005/10/01 04:11:43 $
created at: Fri Jun 10 00:48:55 JST 1994
Copyright (C) 1993-2003 Yukihiro Matsumoto
@@ -1934,25 +1934,6 @@
return x;
}
-VALUE
-rb_big_rand(VALUE max, double *rand_buf)
-{
- VALUE v;
- long len = RBIGNUM(max)->len;
-
- if (BIGZEROP(max)) {
- return rb_float_new(rand_buf[0]);
- }
- v = bignew(len,1);
- len--;
- BDIGITS(v)[len] = BDIGITS(max)[len] * rand_buf[len];
- while (len--) {
- BDIGITS(v)[len] = ((BDIGIT)~0) * rand_buf[len];
- }
-
- return v;
-}
-
/*
* call-seq:
* big.size -> integer
Modified: trunk/defines.h
===================================================================
--- trunk/defines.h 2005-10-16 14:41:33 UTC (rev 280)
+++ trunk/defines.h 2005-10-27 02:54:30 UTC (rev 281)
@@ -2,8 +2,8 @@
defines.h -
- $Author: ocean $
- $Date: 2005/09/14 06:32:30 $
+ $Author: matz $
+ $Date: 2005/10/05 16:15:16 $
created at: Wed May 18 00:21:44 JST 1994
************************************************/
@@ -42,13 +42,17 @@
#endif
#define xmalloc ruby_xmalloc
+#define xmalloc2 ruby_xmalloc2
#define xcalloc ruby_xcalloc
#define xrealloc ruby_xrealloc
+#define xrealloc2 ruby_xrealloc2
#define xfree ruby_xfree
void *xmalloc(long);
+void *xmalloc2(long,long);
void *xcalloc(long,long);
void *xrealloc(void*,long);
+void *xrealloc2(void*,long,long);
void xfree(void*);
#if SIZEOF_LONG_LONG > 0
Modified: trunk/disasm.c
===================================================================
--- trunk/disasm.c 2005-10-16 14:41:33 UTC (rev 280)
+++ trunk/disasm.c 2005-10-27 02:54:30 UTC (rev 281)
@@ -363,9 +363,7 @@
"NODE_ERRINFO",
"NODE_DEFINED",
"NODE_POSTEXE",
-#ifdef C_ALLOCA
"NODE_ALLOCA",
-#endif
"NODE_BMETHOD",
"NODE_MEMO",
"NODE_IFUNC",
Modified: trunk/enum.c
===================================================================
--- trunk/enum.c 2005-10-16 14:41:33 UTC (rev 280)
+++ trunk/enum.c 2005-10-27 02:54:30 UTC (rev 281)
@@ -2,8 +2,8 @@
enum.c -
- $Author: ocean $
- $Date: 2005/09/12 10:44:19 $
+ $Author: nobu $
+ $Date: 2005/10/11 12:30:47 $
created at: Fri Oct 1 15:15:19 JST 1993
Copyright (C) 1993-2003 Yukihiro Matsumoto
@@ -433,10 +433,10 @@
}
static int
-sort_by_cmp(NODE **aa, NODE **bb)
+sort_by_cmp(const void *ap, const void *bp, void *data)
{
- VALUE a = aa[0]->u1.value;
- VALUE b = bb[0]->u1.value;
+ VALUE a = (*(NODE *const *)ap)->u1.value;
+ VALUE b = (*(NODE *const *)bp)->u1.value;
return rb_cmpint(rb_funcall(a, id_cmp, 1, b), a, b);
}
@@ -527,7 +527,7 @@
RBASIC(ary)->klass = 0;
rb_iterate(rb_each, obj, sort_by_i, ary);
if (RARRAY(ary)->len > 1) {
- qsort(RARRAY(ary)->ptr, RARRAY(ary)->len, sizeof(VALUE), sort_by_cmp, 0);
+ ruby_qsort(RARRAY(ary)->ptr, RARRAY(ary)->len, sizeof(VALUE), sort_by_cmp, 0);
}
if (RBASIC(ary)->klass) {
rb_raise(rb_eRuntimeError, "sort_by reentered");
Modified: trunk/eval.c
===================================================================
--- trunk/eval.c 2005-10-16 14:41:33 UTC (rev 280)
+++ trunk/eval.c 2005-10-27 02:54:30 UTC (rev 281)
@@ -691,11 +691,42 @@
* optional second parameter evaluates to +true+.
*/
+static NODE *basic_respond_to = 0;
+
+int
+rb_obj_respond_to(VALUE obj, ID id, int priv)
+{
+ VALUE klass = CLASS_OF(obj);
+
+ if (rb_method_node(klass, respond_to) == basic_respond_to) {
+ return rb_method_boundp(klass, id, !priv);
+ }
+ else {
+ VALUE args[2];
+ int n = 0;
+ args[n++] = ID2SYM(id);
+ if (priv) args[n++] = Qtrue;
+ return rb_funcall2(obj, respond_to, n, args);
+ }
+}
+
+int
+rb_respond_to(VALUE obj, ID id)
+{
+ return rb_obj_respond_to(obj, id, Qfalse);
+}
+
+/*
+ * call-seq:
+ * obj.respond_to?(symbol, include_private=false) => true or false
+ *
+ * Returns +true+> if _obj_ responds to the given
+ * method. Private methods are included in the search only if the
+ * optional second parameter evaluates to +true+.
+ */
+
static VALUE
-rb_obj_respond_to(argc, argv, obj)
- int argc;
- VALUE *argv;
- VALUE obj;
+obj_respond_to(int argc, VALUE *argv, VALUE obj)
{
VALUE mid, priv;
ID id;
@@ -2670,7 +2701,7 @@
rb_define_global_function("method_missing", rb_method_missing, -1);
rb_define_global_function("loop", rb_f_loop, 0);
- rb_define_method(rb_mKernel, "respond_to?", rb_obj_respond_to, -1);
+ rb_define_method(rb_mKernel, "respond_to?", obj_respond_to, -1);
respond_to = rb_intern("respond_to?");
basic_respond_to = rb_method_node(rb_cObject, respond_to);
rb_global_variable((VALUE*)&basic_respond_to);
Modified: trunk/eval_method.h
===================================================================
--- trunk/eval_method.h 2005-10-16 14:41:33 UTC (rev 280)
+++ trunk/eval_method.h 2005-10-27 02:54:30 UTC (rev 281)
@@ -411,25 +411,6 @@
}
}
-
-static NODE *basic_respond_to = 0;
-
-int
-rb_respond_to(obj, id)
- VALUE obj;
- ID id;
-{
- VALUE klass = CLASS_OF(obj);
- if (rb_method_node(klass, respond_to) == basic_respond_to &&
- rb_method_boundp(klass, id, 0)) {
- return Qtrue;
- }
- else{
- return rb_funcall(obj, respond_to, 1, ID2SYM(id));
- }
- return Qfalse;
-}
-
static VALUE
ruby_cbase(){
UNSUPPORTED(ruby_cbase);
Modified: trunk/file.c
===================================================================
--- trunk/file.c 2005-10-16 14:41:33 UTC (rev 280)
+++ trunk/file.c 2005-10-27 02:54:30 UTC (rev 281)
@@ -2,8 +2,8 @@
file.c -
- $Author: nobu $
- $Date: 2005/09/20 13:25:59 $
+ $Author: eban $
+ $Date: 2005/10/12 02:26:14 $
created at: Mon Nov 15 12:24:34 JST 1993
Copyright (C) 1993-2003 Yukihiro Matsumoto
@@ -542,8 +542,8 @@
{
VALUE str;
int i;
- static struct {
- char *name;
+ static const struct {
+ const char *name;
VALUE (*func)(VALUE);
} member[] = {
{"dev", rb_stat_dev},
@@ -2695,8 +2695,9 @@
static VALUE rb_file_join(VALUE ary, VALUE sep);
static VALUE
-file_inspect_join(VALUE ary, VALUE *arg, int recur)
+file_inspect_join(VALUE ary, VALUE argp, int recur)
{
+ VALUE *arg = (VALUE *)argp;
if (recur) return rb_str_new2("[...]");
return rb_file_join(arg[0], arg[1]);
}
@@ -3017,14 +3018,14 @@
* ?d | boolean | True if file1 exists and is a directory
* ?e | boolean | True if file1 exists
* ?f | boolean | True if file1 exists and is a regular file
- * ?g | boolean | True if files has the \CF{setgid} bit
+ * ?g | boolean | True if file1 has the \CF{setgid} bit
* | | set (false under NT)
* ?G | boolean | True if file1 exists and has a group
* | | ownership equal to the caller's group
* ?k | boolean | True if file1 exists and has the sticky bit set
- * ?l | boolean | True if files exists and is a symbolic link
+ * ?l | boolean | True if file1 exists and is a symbolic link
* ?M | Time | Last modification time for file1
- * ?o | boolean | True if files exists and is owned by
+ * ?o | boolean | True if file1 exists and is owned by
* | | the caller's effective uid
* ?O | boolean | True if file1 exists and is owned by
* | | the caller's real uid
@@ -3033,7 +3034,7 @@
* | | uid/gid of the caller
* ?R | boolean | True if file is readable by the real
* | | uid/gid of the caller
- * ?s | int/nil | If files has nonzero size, return the size,
+ * ?s | int/nil | If file1 has nonzero size, return the size,
* | | otherwise return nil
* ?S | boolean | True if file1 exists and is a socket
* ?u | boolean | True if file1 has the setuid bit set
@@ -3840,7 +3841,7 @@
#ifndef DOSISH
static int
-path_check_1(VALUE path)
+path_check_0(VALUE path, int loadpath)
{
struct stat st;
char *p0 = StringValueCStr(path);
@@ -3855,7 +3856,7 @@
rb_str_cat2(newpath, "/");
rb_str_cat2(newpath, p0);
- return path_check_1(newpath);
+ return path_check_0(newpath, loadpath);
}
for (;;) {
#ifndef S_IWOTH
@@ -3863,7 +3864,7 @@
#endif
if (stat(p0, &st) == 0 && S_ISDIR(st.st_mode) && (st.st_mode & S_IWOTH)
#ifdef S_ISVTX
- && !(st.st_mode & S_ISVTX)
+ && (loadpath || !(st.st_mode & S_ISVTX))
#endif
&& !access(p0, W_OK)) {
rb_warn("Insecure world writable dir %s, mode 0%o", p0, st.st_mode);
@@ -3879,6 +3880,17 @@
}
#endif
+static int
+fpath_check(path)
+ char *path;
+{
+#ifndef DOSISH
+ return path_check_0(rb_str_new2(path), Qfalse);
+#else
+ return 1;
+#endif
+}
+
int
rb_path_check(const char *path)
{
@@ -3894,7 +3906,7 @@
if (!p) p = pend;
for (;;) {
- if (!path_check_1(rb_str_new(p0, p - p0))) {
+ if (!path_check_0(rb_str_new(p0, p - p0), Qtrue)) {
return 0; /* not safe */
}
p0 = p + 1;
@@ -4001,7 +4013,7 @@
#if defined(__MACOS__) || defined(riscos)
if (is_macos_native_path(f)) {
- if (rb_safe_level() >= 1 && !rb_path_check(f)) {
+ if (rb_safe_level() >= 1 && !fpath_check(f)) {
rb_raise(rb_eSecurityError, "loading from unsafe file %s", f);
}
if (file_load_ok(f)) return path;
@@ -4009,7 +4021,7 @@
#endif
if (is_absolute_path(f)) {
- if (rb_safe_level() >= 1 && !rb_path_check(f)) {
+ if (rb_safe_level() >= 1 && !fpath_check(f)) {
rb_raise(rb_eSecurityError, "loading from unsafe file %s", f);
}
if (file_load_ok(f)) return path;
@@ -4050,7 +4062,7 @@
return 0; /* no path, no load */
}
f = dln_find_file(f, lpath);
- if (rb_safe_level() >= 1 && !rb_path_check(f)) {
+ if (rb_safe_level() >= 1 && !fpath_check(f)) {
rb_raise(rb_eSecurityError, "loading from unsafe file %s", f);
}
if (file_load_ok(f)) {
Modified: trunk/gc.c
===================================================================
--- trunk/gc.c 2005-10-16 14:41:33 UTC (rev 280)
+++ trunk/gc.c 2005-10-27 02:54:30 UTC (rev 281)
@@ -3,7 +3,7 @@
gc.c -
$Author: nobu $
- $Date: 2005/09/17 16:10:53 $
+ $Date: 2005/10/08 09:58:23 $
created at: Tue Oct 5 09:44:46 JST 1993
Copyright (C) 1993-2003 Yukihiro Matsumoto
@@ -135,11 +135,21 @@
}
void *
+ruby_xmalloc2(long n, long size)
+{
+ long len = size * n;
+ if (len < n || (n > 0 && len < size)) {
+ rb_raise(rb_eArgError, "malloc: possible integer overflow");
+ }
+ return ruby_xmalloc(len);
+}
+
+void *
ruby_xcalloc(long n, long size)
{
void *mem;
- mem = xmalloc(n * size);
+ mem = ruby_xmalloc2(n, size);
memset(mem, 0, n * size);
return mem;
@@ -153,7 +163,7 @@
if (size < 0) {
rb_raise(rb_eArgError, "negative re-allocation size");
}
- if (!ptr) return xmalloc(size);
+ if (!ptr) return ruby_xmalloc(size);
if (size == 0) size = 1;
malloc_increase += size;
RUBY_CRITICAL(mem = realloc(ptr, size));
@@ -169,6 +179,16 @@
return mem;
}
+void *
+ruby_xrealloc2(void *ptr, long n, long size)
+{
+ long len = size * n;
+ if (len < n || (n > 0 && len < size)) {
+ rb_raise(rb_eArgError, "realloc: possible integer overflow");
+ }
+ return ruby_xrealloc(ptr, len);
+}
+
void
ruby_xfree(void *x)
{
@@ -835,13 +855,11 @@
case NODE_BLOCK_ARG:
case NODE_POSTEXE:
break;
-#ifdef C_ALLOCA
case NODE_ALLOCA:
mark_locations_array((VALUE*)obj->as.node.u1.value,
obj->as.node.u3.cnt);
ptr = (VALUE)obj->as.node.u2.node;
goto again;
-#endif
default: /* unlisted NODE */
if (is_pointer_to_heap(obj->as.node.u1.node)) {
@@ -1168,11 +1186,9 @@
RUBY_CRITICAL(free(RANY(obj)->as.node.u1.tbl));
}
break;
-#ifdef C_ALLOCA
case NODE_ALLOCA:
RUBY_CRITICAL(free(RANY(obj)->as.node.u1.node));
break;
-#endif
}
return; /* no need to free iv_tbl */
Modified: trunk/insns.def
===================================================================
--- trunk/insns.def 2005-10-16 14:41:33 UTC (rev 280)
+++ trunk/insns.def 2005-10-27 02:54:30 UTC (rev 281)
@@ -1704,12 +1704,17 @@
long a, b, c;
a = FIX2LONG(recv);
- b = FIX2LONG(obj);
- c = a * b;
- val = LONG2FIX(c);
+ if(a == 0){
+ val = recv;
+ }
+ else{
+ b = FIX2LONG(obj);
+ c = a * b;
+ val = LONG2FIX(c);
- if(FIX2LONG(val) != c || c/a != b){
- val = rb_big_mul(rb_int2big(a), rb_int2big(b));
+ if(FIX2LONG(val) != c || c/a != b){
+ val = rb_big_mul(rb_int2big(a), rb_int2big(b));
+ }
}
}
else if(!SPECIAL_CONST_P(recv) &&
Modified: trunk/intern.h
===================================================================
--- trunk/intern.h 2005-10-16 14:41:33 UTC (rev 280)
+++ trunk/intern.h 2005-10-27 02:54:30 UTC (rev 281)
@@ -2,8 +2,8 @@
intern.h -
- $Author: ocean $
- $Date: 2005/09/14 08:30:15 $
+ $Author: nobu $
+ $Date: 2005/10/11 12:42:32 $
created at: Thu Jun 10 14:22:17 JST 1993
Copyright (C) 1993-2003 Yukihiro Matsumoto
@@ -108,7 +108,6 @@
VALUE rb_big_or(VALUE, VALUE);
VALUE rb_big_xor(VALUE, VALUE);
VALUE rb_big_lshift(VALUE, VALUE);
-VALUE rb_big_rand(VALUE, double*);
/* class.c */
VALUE rb_class_boot(VALUE);
VALUE rb_class_new(VALUE);
@@ -222,6 +221,7 @@
void rb_dvar_push(ID, VALUE);
VALUE *rb_svar(int);
VALUE rb_eval_cmd(VALUE, VALUE, int);
+int rb_obj_respond_to(VALUE, ID, int);
int rb_respond_to(VALUE, ID);
void rb_interrupt(void);
VALUE rb_apply(VALUE, ID, VALUE);
@@ -282,7 +282,7 @@
VALUE rb_thread_local_aref(VALUE, ID);
VALUE rb_thread_local_aset(VALUE, ID, VALUE);
void rb_thread_atfork(void);
-VALUE rb_exec_recursive(VALUE(*)(ANYARGS),VALUE,VALUE);
+VALUE rb_exec_recursive(VALUE(*)(VALUE, VALUE, int),VALUE,VALUE);
/* file.c */
int eaccess(const char*, int);
VALUE rb_file_s_expand_path(int, VALUE *);
@@ -531,7 +531,7 @@
void rb_name_class(VALUE, ID);
VALUE rb_class_name(VALUE);
void rb_autoload(VALUE, ID, const char*);
-void rb_autoload_load(VALUE, ID);
+VALUE rb_autoload_load(VALUE, ID);
VALUE rb_autoload_p(VALUE, ID);
void rb_gc_mark_global_tbl(void);
VALUE rb_f_trace_var(int, VALUE*);
Modified: trunk/io.c
===================================================================
--- trunk/io.c 2005-10-16 14:41:33 UTC (rev 280)
+++ trunk/io.c 2005-10-27 02:54:30 UTC (rev 281)
@@ -2,8 +2,8 @@
io.c -
- $Author: akr $
- $Date: 2005/09/24 00:17:41 $
+ $Author: nobu $
+ $Date: 2005/10/08 10:33:24 $
created at: Fri Oct 15 18:08:59 JST 1993
Copyright (C) 1993-2003 Yukihiro Matsumoto
@@ -3433,7 +3433,7 @@
rb_io_flush(io);
/* copy OpenFile structure */
- fptr->mode = orig->mode;
+ fptr->mode = orig->mode & ~FMODE_PREP;
fptr->pid = orig->pid;
fptr->lineno = orig->lineno;
if (orig->path) fptr->path = strdup(orig->path);
@@ -3501,7 +3501,7 @@
* ios.print(obj, ...) => nil
*
* Writes the given object(s) to <em>ios</em>. The stream must be
- * opened for writing. If the output record separator (<code>$\</code>)
+ * opened for writing. If the output record separator (<code>$\\</code>)
* is not <code>nil</code>, it will be appended to the output. If no
* arguments are given, prints <code>$_</code>. Objects that aren't
* strings will be converted by calling their <code>to_s</code> method.
@@ -3554,7 +3554,7 @@
* Prints each object in turn to <code>$stdout</code>. If the output
* field separator (<code>$,</code>) is not +nil+, its
* contents will appear between each field. If the output record
- * separator (<code>$\</code>) is not +nil+, it will be
+ * separator (<code>$\\</code>) is not +nil+, it will be
* appended to the output. If no arguments are given, prints
* <code>$_</code>. Objects that aren't strings will be converted by
* calling their <code>to_s</code> method.
Modified: trunk/node.h
===================================================================
--- trunk/node.h 2005-10-16 14:41:33 UTC (rev 280)
+++ trunk/node.h 2005-10-27 02:54:30 UTC (rev 281)
@@ -2,8 +2,8 @@
node.h -
- $Author: ocean $
- $Date: 2005/09/14 06:32:31 $
+ $Author: nobu $
+ $Date: 2005/10/08 09:58:23 $
created at: Fri May 28 15:14:02 JST 1993
Copyright (C) 1993-2003 Yukihiro Matsumoto
@@ -116,9 +116,7 @@
NODE_ERRINFO,
NODE_DEFINED,
NODE_POSTEXE,
-#ifdef C_ALLOCA
NODE_ALLOCA,
-#endif
NODE_BMETHOD,
NODE_MEMO,
NODE_IFUNC,
Modified: trunk/numeric.c
===================================================================
--- trunk/numeric.c 2005-10-16 14:41:33 UTC (rev 280)
+++ trunk/numeric.c 2005-10-27 02:54:30 UTC (rev 281)
@@ -3,7 +3,7 @@
numeric.c -
$Author: matz $
- $Date: 2005/09/19 16:01:05 $
+ $Date: 2005/10/05 16:15:16 $
created at: Fri Aug 13 18:33:09 JST 1993
Copyright (C) 1993-2003 Yukihiro Matsumoto
@@ -11,6 +11,7 @@
**********************************************************************/
#include "ruby.h"
+#include "env.h"
#include <ctype.h>
#include <math.h>
#include <stdio.h>
@@ -179,7 +180,7 @@
static VALUE
num_sadded(VALUE x, VALUE name)
{
- rb_frame_pop(); /* pop frame for "singleton_method_added" */
+ ruby_frame = ruby_frame->prev; /* pop frame for "singleton_method_added" */
/* Numerics should be values; singleton_methods should not be added to them */
rb_raise(rb_eTypeError,
"can't define singleton method \"%s\" for %s",
@@ -2038,18 +2039,8 @@
}
}
-/*
- * call-seq:
- * fix / numeric => numeric_result
- * fix.div(numeric) => numeric_result
- *
- * Performs division: the class of the resulting object depends on
- * the class of <code>numeric</code> and on the magnitude of the
- * result.
- */
-
static VALUE
-fix_div(VALUE x, VALUE y)
+fix_divide(VALUE x, VALUE y, int flo)
{
if (FIXNUM_P(y)) {
long div;
@@ -2062,7 +2053,13 @@
x = rb_int2big(FIX2LONG(x));
return rb_big_div(x, y);
case T_FLOAT:
+ if (flo) {
return rb_float_new((double)FIX2LONG(x) / RFLOAT(y)->value);
+ }
+ else {
+ long div = (double)FIX2LONG(x) / RFLOAT(y)->value;
+ return LONG2NUM(div);
+ }
default:
return rb_num_coerce_bin(x, y);
}
@@ -2070,6 +2067,34 @@
/*
* call-seq:
+ * fix / numeric => numeric_result
+ *
+ * Performs division: the class of the resulting object depends on
+ * the class of <code>numeric</code> and on the magnitude of the
+ * result.
+ */
+
+static VALUE
+fix_div(VALUE x, VALUE y)
+{
+ return fix_divide(x, y, Qtrue);
+}
+
+/*
+ * call-seq:
+ * fix.div(numeric) => numeric_result
+ *
+ * Performs integer division: returns integer value.
+ */
+
+static VALUE
+fix_idiv(VALUE x, VALUE y)
+{
+ return fix_divide(x, y, Qfalse);
+}
+
+/*
+ * call-seq:
* fix % other => Numeric
* fix.modulo(other) => Numeric
*
@@ -2823,7 +2848,7 @@
rb_define_method(rb_cFixnum, "-", fix_minus, 1);
rb_define_method(rb_cFixnum, "*", fix_mul, 1);
rb_define_method(rb_cFixnum, "/", fix_div, 1);
- rb_define_method(rb_cFixnum, "div", fix_div, 1);
+ rb_define_method(rb_cFixnum, "div", fix_idiv, 1);
rb_define_method(rb_cFixnum, "%", fix_mod, 1);
rb_define_method(rb_cFixnum, "modulo", fix_mod, 1);
rb_define_method(rb_cFixnum, "divmod", fix_divmod, 1);
Modified: trunk/object.c
===================================================================
--- trunk/object.c 2005-10-16 14:41:33 UTC (rev 280)
+++ trunk/object.c 2005-10-27 02:54:30 UTC (rev 281)
@@ -2,8 +2,8 @@
object.c -
- $Author: ocean $
- $Date: 2005/09/12 10:44:20 $
+ $Author: matz $
+ $Date: 2005/10/05 16:15:15 $
created at: Thu Jul 15 12:01:24 JST 1993
Copyright (C) 1993-2003 Yukihiro Matsumoto
@@ -729,21 +729,6 @@
/*
* call-seq:
- * nil.to_a => []
- *
- * Always returns an empty array.
- *
- * nil.to_a #=> []
- */
-
-static VALUE
-nil_to_a(VALUE obj)
-{
- return rb_ary_new2(0);
-}
-
-/*
- * call-seq:
* nil.inspect => "nil"
*
* Always returns the string "nil".
@@ -2448,7 +2433,6 @@
rb_define_method(rb_cNilClass, "to_i", nil_to_i, 0);
rb_define_method(rb_cNilClass, "to_f", nil_to_f, 0);
rb_define_method(rb_cNilClass, "to_s", nil_to_s, 0);
- rb_define_method(rb_cNilClass, "to_a", nil_to_a, 0);
rb_define_method(rb_cNilClass, "inspect", nil_inspect, 0);
rb_define_method(rb_cNilClass, "&", false_and, 1);
rb_define_method(rb_cNilClass, "|", false_or, 1);
Modified: trunk/pack.c
===================================================================
--- trunk/pack.c 2005-10-16 14:41:33 UTC (rev 280)
+++ trunk/pack.c 2005-10-27 02:54:30 UTC (rev 281)
@@ -2,8 +2,8 @@
pack.c -
- $Author: akr $
- $Date: 2005/09/24 00:17:41 $
+ $Author: matz $
+ $Date: 2005/10/05 16:15:15 $
created at: Thu Feb 10 15:17:05 JST 1994
Copyright (C) 1993-2003 Yukihiro Matsumoto
@@ -349,12 +349,12 @@
# define EXTEND32(x)
#else
/* invariant in modulo 1<<31 */
-# define EXTEND32(x) do {if (!natint) {(x) = (I32)(((1<<31)-1-(x))^~(~0<<31))}} while(0)
+# define EXTEND32(x) do {if (!natint) {(x) = (I32)(((1<<31)-1-(x))^~(~0<<31));}} while(0)
#endif
#if SIZEOF_SHORT == SIZE16
# define EXTEND16(x)
#else
-# define EXTEND16(x) do { if (!natint) {(x) = (short)(((1<<15)-1-(x))^~(~0<<15))}} while(0)
+# define EXTEND16(x) do { if (!natint) {(x) = (short)(((1<<15)-1-(x))^~(~0<<15));}} while(0)
#endif
#ifdef HAVE_LONG_LONG
Modified: trunk/parse.y
===================================================================
--- trunk/parse.y 2005-10-16 14:41:33 UTC (rev 280)
+++ trunk/parse.y 2005-10-27 02:54:30 UTC (rev 281)
@@ -2,8 +2,8 @@
parse.y -
- $Author: ocean $
- $Date: 2005/09/25 00:39:22 $
+ $Author: nobu $
+ $Date: 2005/10/11 12:42:32 $
created at: Fri May 28 18:02:42 JST 1993
Copyright (C) 1993-2004 Yukihiro Matsumoto
@@ -13,8 +13,11 @@
%{
#define YYDEBUG 1
+#define YYERROR_VERBOSE 1
+#define YYSTACK_USE_ALLOCA 0
#include "ruby.h"
+#include "env.h"
#include "intern.h"
#include "node.h"
#include "st.h"
@@ -22,7 +25,14 @@
#include <errno.h>
#include <ctype.h>
-extern int ruby_in_eval;
+#define YYMALLOC(size) rb_parser_malloc(parser, size)
+#define YYREALLOC(ptr, size) rb_parser_realloc(parser, ptr, size)
+#define YYCALLOC(nelem, size) rb_parser_calloc(parser, nelem, size)
+#define YYFREE(ptr) rb_parser_free(parser, ptr)
+#define malloc YYMALLOC
+#define realloc YYREALLOC
+#define calloc YYCALLOC
+#define free YYFREE
#define ID_SCOPE_SHIFT 3
#define ID_SCOPE_MASK 0x07
@@ -242,8 +252,19 @@
#endif
int line_count;
int has_shebang;
+
+#ifdef YYMALLOC
+ NODE *heap;
+#endif
};
+#ifdef YYMALLOC
+void *rb_parser_malloc(struct parser_params *, size_t);
+void *rb_parser_realloc(struct parser_params *, void *, size_t);
+void *rb_parser_calloc(struct parser_params *, size_t, size_t);
+void rb_parser_free(struct parser_params *, void *);
+#endif
+
static int parser_yyerror(struct parser_params*, const char*);
#define yyerror(msg) parser_yyerror(parser, msg)
@@ -2562,11 +2583,10 @@
}
| tLPAREN_ARG expr {lex_state = EXPR_ENDARG;} rparen
{
+ rb_warning0("(...) interpreted as grouped expression");
/*%%%*/
- rb_warning("(...) interpreted as grouped expression");
$$ = $2;
/*%
- rb_warning0("(...) interpreted as grouped expression");
$$ = dispatch1(paren, $2);
%*/
}
@@ -4488,9 +4508,7 @@
#define ripper_flush(p) (p->tokp = p->parser_lex_p)
static void
-ripper_dispatch_scan_event(parser, t)
- struct parser_params *parser;
- int t;
+ripper_dispatch_scan_event(struct parser_params *parser, int t)
{
VALUE str;
@@ -4502,9 +4520,7 @@
}
static void
-ripper_dispatch_delayed_token(parser, t)
- struct parser_params *parser;
- int t;
+ripper_dispatch_delayed_token(struct parser_params *parser, int t)
{
int saved_line = ruby_sourceline;
char *saved_tokp = parser->tokp;
@@ -4535,9 +4551,7 @@
#define is_identchar(c) (SIGN_EXTEND_CHAR(c)!=-1&&(ISALNUM(c) || (c) == '_' || ismbchar(c)))
static int
-parser_yyerror(parser, msg)
- struct parser_params *parser;
- const char *msg;
+parser_yyerror(struct parser_params *parser, const char *msg)
{
#ifndef RIPPER
char *p, *pe, *buf;
@@ -4585,10 +4599,7 @@
#ifndef RIPPER
static NODE*
-yycompile(parser, f, line)
- struct parser_params *parser;
- char *f;
- int line;
+yycompile(struct parser_params *parser, const char *f, int line)
{
int n;
const char *kcode_save;
@@ -4658,8 +4669,7 @@
}
static VALUE
-lex_getline(parser)
- struct parser_params *parser;
+lex_getline(struct parser_params *parser)
{
VALUE line = (*parser->parser_lex_gets)(parser, parser->parser_lex_input);
#ifndef RIPPER
@@ -4672,10 +4682,7 @@
#ifndef RIPPER
NODE*
-rb_compile_string(f, s, line)
- const char *f;
- VALUE s;
- int line;
+rb_compile_string(const char *f, VALUE s, int line)
{
VALUE volatile vparser = rb_parser_new();
@@ -4683,11 +4690,7 @@
}
NODE*
-rb_parser_compile_string(vparser, f, s, line)
- volatile VALUE vparser;
- const char *f;
- VALUE s;
- int line;
+rb_parser_compile_string(volatile VALUE vparser, const char *f, VALUE s, int line)
{
struct parser_params *parser;
@@ -4702,36 +4705,25 @@
}
NODE*
-rb_compile_cstr(f, s, len, line)
- const char *f, *s;
- int len, line;
+rb_compile_cstr(const char *f, const char *s, int len, int line)
{
return rb_compile_string(f, rb_str_new(s, len), line);
}
NODE*
-rb_parser_compile_cstr(vparser, f, s, len, line)
- volatile VALUE vparser;
- const char *f, *s;
- int len, line;
+rb_parser_compile_cstr(volatile VALUE vparser, const char *f, const char *s, int len, int line)
{
return rb_parser_compile_string(vparser, f, rb_str_new(s, len), line);
}
-static VALUE lex_io_gets(struct parser_params *, VALUE);
static VALUE
-lex_io_gets(parser, io)
- struct parser_params *parser;
- VALUE io;
+lex_io_gets(struct parser_params *parser, VALUE io)
{
return rb_io_gets(io);
}
NODE*
-rb_compile_file(f, file, start)
- const char *f;
- VALUE file;
- int start;
+rb_compile_file(const char *f, VALUE file, int start)
{
VALUE volatile vparser = rb_parser_new();
@@ -4739,11 +4731,7 @@
}
NODE*
-rb_parser_compile_file(vparser, f, file, start)
- volatile VALUE vparser;
- const char *f;
- VALUE file;
- int start;
+rb_parser_compile_file(volatile VALUE vparser, const char *f, VALUE file, int start)
{
struct parser_params *parser;
@@ -4757,8 +4745,7 @@
#endif /* !RIPPER */
static inline int
-parser_nextc(parser)
- struct parser_params *parser;
+parser_nextc(struct parser_params *parser)
{
int c;
@@ -4815,9 +4802,7 @@
}
static void
-parser_pushback(parser, c)
- struct parser_params *parser;
- int c;
+parser_pushback(struct parser_params *parser, int c)
{
if (c == -1) return;
lex_p--;
@@ -4836,8 +4821,7 @@
#define toklast() (tokidx>0?tokenbuf[tokidx-1]:0)
static char*
-parser_newtok(parser)
- struct parser_params *parser;
+parser_newtok(struct parser_params *parser)
{
tokidx = 0;
if (!tokenbuf) {
@@ -4852,9 +4836,7 @@
}
static void
-parser_tokadd(parser, c)
- struct parser_params *parser;
- char c;
+parser_tokadd(struct parser_params *parser, char c)
{
tokenbuf[tokidx++] = c;
if (tokidx >= toksiz) {
@@ -4864,8 +4846,7 @@
}
static int
-parser_read_escape(parser)
- struct parser_params *parser;
+parser_read_escape(struct parser_params *parser)
{
int c;
@@ -4964,9 +4945,7 @@
}
static int
-parser_tokadd_escape(parser, term)
- struct parser_params *parser;
- int term;
+parser_tokadd_escape(struct parser_params *parser, int term)
{
int c;
@@ -5051,8 +5030,7 @@
}
static int
-parser_regx_options(parser)
- struct parser_params *parser;
+parser_regx_options(struct parser_params *parser)
{
char kcode = 0;
int options = 0;
@@ -5118,18 +5096,15 @@
};
static void
-dispose_string(str)
- VALUE str;
+dispose_string(VALUE str)
{
xfree(RSTRING(str)->ptr);
rb_gc_force_recycle(str);
}
static int
-parser_tokadd_string(parser, func, term, paren, nest)
- struct parser_params *parser;
- int func, term, paren;
- long *nest;
+parser_tokadd_string(struct parser_params *parser,
+ int func, int term, int paren, long *nest)
{
int c;
unsigned char uc;
@@ -5215,9 +5190,7 @@
#else
# define NEW_STRTERM(func, term, paren) ripper_new_strterm(parser, func, term, paren)
static NODE *
-ripper_new_strterm(parser, func, term, paren)
- struct parser_params *parser;
- VALUE func, term, paren;
+ripper_new_strterm(struct parser_params *parser, VALUE func, VALUE term, VALUE paren)
{
NODE *node = NEW_STRTERM0(func, term, paren);
nd_set_line(node, ruby_sourceline);
@@ -5226,9 +5199,7 @@
#endif
static int
-parser_parse_string(parser, quote)
- struct parser_params *parser;
- NODE *quote;
+parser_parse_string(struct parser_params *parser, NODE *quote)
{
int func = quote->nd_func;
int term = nd_term(quote);
@@ -5279,8 +5250,7 @@
}
static int
-parser_heredoc_identifier(parser)
- struct parser_params *parser;
+parser_heredoc_identifier(struct parser_params *parser)
{
int c = nextc(), term, func = 0, len;
unsigned int uc;
@@ -5351,9 +5321,7 @@
}
static void
-parser_heredoc_restore(parser, here)
- struct parser_params *parser;
- NODE *here;
+parser_heredoc_restore(struct parser_params *parser, NODE *here)
{
VALUE line;
@@ -5378,10 +5346,8 @@
}
static int
-parser_whole_match_p(parser, eos, len, indent)
- struct parser_params *parser;
- char *eos;
- int len, indent;
+parser_whole_match_p(struct parser_params *parser,
+ const char *eos, int len, int indent)
{
char *p = lex_pbeg;
int n;
@@ -5396,9 +5362,7 @@
}
static int
-parser_here_document(parser, here)
- struct parser_params *parser;
- NODE *here;
+parser_here_document(struct parser_params *parser, NODE *here)
{
int c, func, indent = 0;
char *eos, *p, *pend;
@@ -5483,14 +5447,13 @@
#ifndef RIPPER
static void
-arg_ambiguous()
+arg_ambiguous(void)
{
rb_warning("ambiguous first argument; put parentheses or even spaces");
}
#else
static void
-ripper_arg_ambiguous(parser)
- struct parser_params *parser;
+ripper_arg_ambiguous(struct parser_params *parser)
{
dispatch0(arg_ambiguous);
}
@@ -5498,9 +5461,7 @@
#endif
static int
-lvar_defined_gen(parser, id)
- struct parser_params *parser;
- ID id;
+lvar_defined_gen(struct parser_params *parser, ID id)
{
#ifndef RIPPER
return (dyna_in_block() && dvar_defined(id)) || local_id(id);
@@ -5513,11 +5474,8 @@
#ifndef RIPPER
typedef void (*rb_pragma_setter_t)(struct parser_params *parser, const char *name, const char *val);
-static void pragma_encoding(struct parser_params *, const char *, const char *);
static void
-pragma_encoding(parser, name, val)
- struct parser_params *parser;
- const char *name, *val;
+pragma_encoding(struct parser_params *parser, const char *name, const char *val)
{
if (parser && parser->line_count != (parser->has_shebang ? 2 : 1))
return;
@@ -5535,9 +5493,7 @@
#endif
static const char *
-pragma_marker(str, len)
- const char *str;
- int len;
+pragma_marker(const char *str, int len)
{
int i = 2;
@@ -5570,10 +5526,7 @@
}
static int
-parser_pragma(parser, str, len)
- struct parser_params *parser;
- const char *str;
- int len;
+parser_pragma(struct parser_params *parser, const char *str, int len)
{
VALUE name = 0, val = 0;
const char *beg, *end, *vbeg, *vend;
@@ -5657,8 +5610,7 @@
}
static void
-parser_prepare(parser)
- struct parser_params *parser;
+parser_prepare(struct parser_params *parser)
{
int c = nextc();
switch (c) {
@@ -5684,8 +5636,7 @@
#define IS_BEG() (lex_state == EXPR_BEG || lex_state == EXPR_MID || lex_state == EXPR_VALUE || lex_state == EXPR_CLASS)
static int
-parser_yylex(parser)
- struct parser_params *parser;
+parser_yylex(struct parser_params *parser)
{
register int c;
int space_seen = 0;
@@ -6927,11 +6878,9 @@
#if YYPURE
static int
-yylex(lval, p)
- void *lval, *p;
+yylex(void *lval, void *p)
#else
-yylex(p)
- void *p;
+yylex(void *p)
#endif
{
struct parser_params *parser = (struct parser_params*)p;
@@ -6956,9 +6905,7 @@
#ifndef RIPPER
NODE*
-rb_node_newnode(type, a0, a1, a2)
- enum node_type type;
- VALUE a0, a1, a2;
+rb_node_newnode(enum node_type type, VALUE a0, VALUE a1, VALUE a2)
{
NODE *n = (NODE*)rb_newobj();
@@ -6975,22 +6922,19 @@
}
static enum node_type
-nodetype(node) /* for debug */
- NODE *node;
+nodetype(NODE *node) /* for debug */
{
return (enum node_type)nd_type(node);
}
static int
-nodeline(node)
- NODE *node;
+nodeline(NODE *node)
{
return nd_line(node);
}
static NODE*
-newline_node(node)
- NODE *node;
+newline_node(NODE *node)
{
if (node) {
node->flags |= NODE_NEWLINE;
@@ -6999,8 +6943,7 @@
}
static void
-fixpos(node, orig)
- NODE *node, *orig;
+fixpos(NODE *node, NODE *orig)
{
if (!node) return;
if (!orig) return;
@@ -7010,9 +6953,7 @@
}
static void
-parser_warning(node, mesg)
- NODE *node;
- const char *mesg;
+parser_warning(NODE *node, const char *mesg)
{
int line = ruby_sourceline;
ruby_sourceline = nd_line(node);
@@ -7021,9 +6962,7 @@
}
static void
-parser_warn(node, mesg)
- NODE *node;
- const char *mesg;
+parser_warn(NODE *node, const char *mesg)
{
int line = ruby_sourceline;
ruby_sourceline = nd_line(node);
@@ -7032,8 +6971,7 @@
}
static NODE*
-block_append(head, tail)
- NODE *head, *tail;
+block_append(NODE *head, NODE *tail)
{
NODE *end, *h = head, *nd;
@@ -7087,8 +7025,7 @@
/* append item to the list */
static NODE*
-list_append(list, item)
- NODE *list, *item;
+list_append(NODE *list, NODE *item)
{
NODE *last;
@@ -7108,8 +7045,7 @@
/* concat two lists */
static NODE*
-list_concat(head, tail)
- NODE *head, *tail;
+list_concat(NODE *head, NODE *tail)
{
NODE *last;
@@ -7134,8 +7070,7 @@
/* concat two string literals */
static NODE *
-literal_concat(head, tail)
- NODE *head, *tail;
+literal_concat(NODE *head, NODE *tail)
{
enum node_type htype;
@@ -7184,8 +7119,7 @@
}
static NODE *
-evstr2dstr(node)
- NODE *node;
+evstr2dstr(NODE *node)
{
if (nd_type(node) == NODE_EVSTR) {
node = list_append(NEW_DSTR(rb_str_new(0, 0)), node);
@@ -7194,8 +7128,7 @@
}
static NODE *
-new_evstr(node)
- NODE *node;
+new_evstr(NODE *node)
{
NODE *head = node;
@@ -7209,12 +7142,7 @@
}
static NODE *
-call_op_gen(parser, recv, id, narg, arg1)
- struct parser_params *parser;
- NODE *recv;
- ID id;
- int narg;
- NODE *arg1;
+call_op_gen(struct parser_params *parser, NODE *recv, ID id, int narg, NODE *arg1)
{
value_expr(arg1);
if (narg == 1) {
@@ -7228,10 +7156,7 @@
}
static NODE*
-match_op_gen(parser, node1, node2)
- struct parser_params *parser;
- NODE *node1;
- NODE *node2;
+match_op_gen(struct parser_params *parser, NODE *node1, NODE *node2)
{
local_cnt('~');
@@ -7267,9 +7192,7 @@
}
static NODE*
-gettable_gen(parser, id)
- struct parser_params *parser;
- ID id;
+gettable_gen(struct parser_params *parser, ID id)
{
if (id == kSELF) {
return NEW_SELF();
@@ -7313,10 +7236,7 @@
}
static NODE*
-assignable_gen(parser, id, val)
- struct parser_params *parser;
- ID id;
- NODE *val;
+assignable_gen(struct parser_params *parser, ID id, NODE *val)
{
value_expr(val);
if (id == kSELF) {
@@ -7374,9 +7294,7 @@
}
static void
-shadowing_lvar_gen(parser, name)
- struct parser_params *parser;
- ID name;
+shadowing_lvar_gen(struct parser_params *parser, ID name)
{
if (dvar_defined(name) || local_id(name)) {
rb_warningS("shadowing outer local variable - %s", rb_id2name(name));
@@ -7384,10 +7302,7 @@
}
static NODE*
-new_bv_gen(parser, name, val)
- struct parser_params *parser;
- ID name;
- NODE *val;
+new_bv_gen(struct parser_params *parser, ID name, NODE *val)
{
if (!is_local_id(name)) {
compile_error(PARSER_ARG "invalid local variable - %s",
@@ -7400,9 +7315,7 @@
}
static NODE *
-aryset_gen(parser, recv, idx)
- struct parser_params *parser;
- NODE *recv, *idx;
+aryset_gen(struct parser_params *parser, NODE *recv, NODE *idx)
{
if (recv && nd_type(recv) == NODE_SELF)
recv = (NODE *)1;
@@ -7412,8 +7325,7 @@
}
static void
-block_dup_check(node)
- NODE *node;
+block_dup_check(NODE *node)
{
if (node && nd_type(node) == NODE_BLOCK_PASS) {
compile_error(PARSER_ARG "both block arg and actual block given");
@@ -7421,8 +7333,7 @@
}
ID
-rb_id_attrset(id)
- ID id;
+rb_id_attrset(ID id)
{
id &= ~ID_SCOPE_MASK;
id |= ID_ATTRSET;
@@ -7430,10 +7341,7 @@
}
static NODE *
-attrset_gen(parser, recv, id)
- struct parser_params *parser;
- NODE *recv;
- ID id;
+attrset_gen(struct parser_params *parser, NODE *recv, ID id)
{
if (recv && nd_type(recv) == NODE_SELF)
recv = (NODE *)1;
@@ -7443,8 +7351,7 @@
}
static void
-rb_backref_error(node)
- NODE *node;
+rb_backref_error(NODE *node)
{
switch (nd_type(node)) {
case NODE_NTH_REF:
@@ -7457,18 +7364,14 @@
}
static NODE *
-arg_concat(node1, node2)
- NODE *node1;
- NODE *node2;
+arg_concat(NODE *node1, NODE *node2)
{
if (!node2) return node1;
return NEW_ARGSCAT(node1, node2);
}
static NODE *
-arg_add(node1, node2)
- NODE *node1;
- NODE *node2;
+arg_add(NODE *node1, NODE *node2)
{
if (!node1) return NEW_LIST(node2);
if (nd_type(node1) == NODE_ARRAY) {
@@ -7480,9 +7383,7 @@
}
static NODE*
-node_assign_gen(parser, lhs, rhs)
- struct parser_params *parser;
- NODE *lhs, *rhs;
+node_assign_gen(struct parser_params *parser, NODE *lhs, NODE *rhs)
{
if (!lhs) return 0;
@@ -7514,9 +7415,7 @@
}
static int
-value_expr_gen(parser, node)
- struct parser_params *parser;
- NODE *node;
+value_expr_gen(struct parser_params *parser, NODE *node)
{
int cond = 0;
@@ -7567,9 +7466,7 @@
}
static void
-void_expr_gen(parser, node)
- struct parser_params *parser;
- NODE *node;
+void_expr_gen(struct parser_params *parser, NODE *node)
{
char *useless = 0;
@@ -7659,9 +7556,7 @@
}
static void
-void_stmts_gen(parser, node)
- struct parser_params *parser;
- NODE *node;
+void_stmts_gen(struct parser_params *parser, NODE *node)
{
if (!RTEST(ruby_verbose)) return;
if (!node) return;
@@ -7675,8 +7570,7 @@
}
static NODE *
-remove_begin(node)
- NODE *node;
+remove_begin(NODE *node)
{
NODE **n = &node;
while (*n) {
@@ -7689,8 +7583,7 @@
}
static void
-reduce_nodes(body)
- NODE **body;
+reduce_nodes(NODE **body)
{
NODE *node = *body;
@@ -7743,9 +7636,7 @@
}
static int
-assign_in_cond(parser, node)
- struct parser_params *parser;
- NODE *node;
+assign_in_cond(struct parser_params *parser, NODE *node)
{
switch (nd_type(node)) {
case NODE_MASGN:
@@ -7784,7 +7675,7 @@
}
static int
-e_option_supplied()
+e_option_supplied(void)
{
if (strcmp(ruby_sourcefile, "-e") == 0)
return Qtrue;
@@ -7792,17 +7683,13 @@
}
static void
-warn_unless_e_option(node, str)
- NODE *node;
- const char *str;
+warn_unless_e_option(NODE *node, const char *str)
{
if (!e_option_supplied()) parser_warn(node, str);
}
static void
-warning_unless_e_option(node, str)
- NODE *node;
- const char *str;
+warning_unless_e_option(NODE *node, const char *str)
{
if (!e_option_supplied()) parser_warning(node, str);
}
@@ -7810,9 +7697,7 @@
static NODE *cond0(struct parser_params*,NODE*);
static NODE*
-range_op(parser, node)
- struct parser_params *parser;
- NODE *node;
+range_op(struct parser_params *parser, NODE *node)
{
enum node_type type;
@@ -7830,8 +7715,7 @@
}
static int
-literal_node(node)
- NODE *node;
+literal_node(NODE *node)
{
if (!node) return 1; /* same as NODE_NIL */
switch (nd_type(node)) {
@@ -7852,9 +7736,7 @@
}
static NODE*
-cond0(parser, node)
- struct parser_params *parser;
- NODE *node;
+cond0(struct parser_params *parser, NODE *node)
{
if (node == 0) return 0;
assign_in_cond(parser, node);
@@ -7916,9 +7798,7 @@
}
static NODE*
-cond_gen(parser, node)
- struct parser_params *parser;
- NODE *node;
+cond_gen(struct parser_params *parser, NODE *node)
{
if (node == 0) return 0;
value_expr(node);
@@ -7926,10 +7806,7 @@
}
static NODE*
-logop_gen(parser, type, left, right)
- struct parser_params *parser;
- enum node_type type;
- NODE *left, *right;
+logop_gen(struct parser_params *parser, enum node_type type, NODE *left, NODE *right)
{
value_expr(left);
if (left && nd_type(left) == type) {
@@ -7944,8 +7821,7 @@
}
static int
-cond_negative(nodep)
- NODE **nodep;
+cond_negative(NODE **nodep)
{
NODE *c = *nodep;
@@ -7959,8 +7835,7 @@
}
static void
-no_blockarg(node)
- NODE *node;
+no_blockarg(NODE *node)
{
if (node && nd_type(node) == NODE_BLOCK_PASS) {
rb_compile_error("block argument should not be given");
@@ -7968,8 +7843,7 @@
}
static NODE *
-ret_args(node)
- NODE *node;
+ret_args(NODE *node)
{
if (node) {
no_blockarg(node);
@@ -7989,8 +7863,7 @@
}
static NODE *
-new_yield(node)
- NODE *node;
+new_yield(NODE *node)
{
long state = Qtrue;
@@ -8011,8 +7884,7 @@
}
static NODE*
-negate_lit(node)
- NODE *node;
+negate_lit(NODE *node)
{
switch (TYPE(node->nd_lit)) {
case T_FIXNUM:
@@ -8031,9 +7903,7 @@
}
static NODE *
-arg_blk_pass(node1, node2)
- NODE *node1;
- NODE *node2;
+arg_blk_pass(NODE *node1, NODE *node2)
{
if (node2) {
node2->nd_head = node1;
@@ -8043,8 +7913,7 @@
}
static NODE*
-arg_prepend(node1, node2)
- NODE *node1, *node2;
+arg_prepend(NODE *node1, NODE *node2)
{
switch (nd_type(node2)) {
case NODE_ARRAY:
@@ -8064,10 +7933,7 @@
}
static int
-arg_dup_check(vid, m, list, node)
- ID vid;
- VALUE m, list;
- NODE *node;
+arg_dup_check(ID vid, VALUE m, VALUE list, NODE *node)
{
VALUE sym = ID2SYM(vid);
if ((m && rb_ary_includes(m, sym)) || rb_ary_includes(list, sym)) {
@@ -8079,10 +7945,7 @@
}
static NODE*
-new_args_gen(parser, m, o, r, b)
- struct parser_params *parser;
- VALUE m;
- NODE *o, *r, *b;
+new_args_gen(struct parser_params *parser, VALUE m, NODE *o, NODE *r, NODE *b)
{
int saved_line = ruby_sourceline;
NODE *tmp;
@@ -8402,9 +8265,7 @@
}
NODE *
-rb_parser_while_loop(node, chop, split)
- NODE *node;
- int chop, split;
+rb_parser_while_loop(NODE *node, int chop, int split)
{
NODE *prelude = 0;
@@ -8483,21 +8344,20 @@
} global_symbols = {tLAST_TOKEN};
void
-Init_sym()
+Init_sym(void)
{
global_symbols.tbl = st_init_strtable_with_size(200);
global_symbols.rev = st_init_numtable_with_size(200);
}
static ID
-internal_id()
+internal_id(void)
{
return ID_INTERNAL | (++global_symbols.last_id << ID_SCOPE_SHIFT);
}
ID
-rb_intern(name)
- const char *name;
+rb_intern(const char *name)
{
const char *m = name;
ID id;
@@ -8572,8 +8432,7 @@
}
char *
-rb_id2name(id)
- ID id;
+rb_id2name(ID id)
{
char *name;
@@ -8611,10 +8470,7 @@
}
static int
-symbols_i(key, value, ary)
- char *key;
- ID value;
- VALUE ary;
+symbols_i(char *key, ID value, VALUE ary)
{
rb_ary_push(ary, ID2SYM(value));
return ST_CONTINUE;
@@ -8725,11 +8581,13 @@
parser->parsing_thread = Qnil;
parser->toplevel_p = Qtrue;
#endif
+#ifdef YYMALLOC
+ parser->heap = NULL;
+#endif
}
static void
-parser_mark(ptr)
- void *ptr;
+parser_mark(void *ptr)
{
struct parser_params *p = (struct parser_params*)ptr;
@@ -8746,11 +8604,13 @@
rb_gc_mark(p->result);
rb_gc_mark(p->parsing_thread);
#endif
+#ifdef YYMALLOC
+ rb_gc_mark((VALUE)p->heap);
+#endif
}
static void
-parser_free(ptr)
- void *ptr;
+parser_free(void *ptr)
{
struct parser_params *p = (struct parser_params*)ptr;
struct local_vars *local, *prev;
@@ -8769,7 +8629,7 @@
#ifndef RIPPER
static struct parser_params *
-parser_new()
+parser_new(void)
{
struct parser_params *p;
@@ -8780,7 +8640,7 @@
}
VALUE
-rb_parser_new()
+rb_parser_new(void)
{
struct parser_params *p = parser_new();
@@ -8795,15 +8655,71 @@
* This number starts from 1.
*/
VALUE
-rb_parser_end_seen_p(vparser)
- VALUE vparser;
+rb_parser_end_seen_p(VALUE vparser)
{
struct parser_params *parser;
Data_Get_Struct(vparser, struct parser_params, parser);
return ruby__end__seen ? Qtrue : Qfalse;
}
+
+#ifdef YYMALLOC
+#define HEAPCNT(n, size) ((size) % sizeof(YYSTYPE) ? 0 : (n) * (size) / sizeof(YYSTYPE))
+#define NEWHEAP(cnt) rb_node_newnode(NODE_ALLOCA, 0, (VALUE)parserp->heap, cnt)
+#define ADD2HEAP(n, ptr) ((parserp->heap = (n))->u1.node = (ptr))
+
+void *
+rb_parser_malloc(struct parser_params *parserp, size_t size)
+{
+ NODE *n = NEWHEAP(HEAPCNT(1, size));
+
+ return ADD2HEAP(n, xmalloc(size));
+}
+
+void *
+rb_parser_calloc(struct parser_params *parserp, size_t nelem, size_t size)
+{
+ NODE *n = NEWHEAP(HEAPCNT(nelem, size));
+
+ return ADD2HEAP(n, xcalloc(nelem, size));
+}
+
+void *
+rb_parser_realloc(struct parser_params *parserp, void *ptr, size_t size)
+{
+ NODE *n;
+ size_t cnt = HEAPCNT(1, size);
+
+ if (ptr && (n = parserp->heap) != NULL) {
+ do {
+ if (n->u1.node == ptr) {
+ n->u1.node = ptr = xrealloc(ptr, size);
+ if (n->u3.cnt) n->u3.cnt = cnt;
+ return ptr;
+ }
+ } while ((n = n->u2.node) != NULL);
+ }
+ n = NEWHEAP(cnt);
+ return ADD2HEAP(n, xrealloc(ptr, size));
+}
+
+void
+rb_parser_free(struct parser_params *parserp, void *ptr)
+{
+ NODE **prev = &parserp->heap, *n;
+
+ while (n = *prev) {
+ if (n->u1.node == ptr) {
+ *prev = n->u2.node;
+ rb_gc_force_recycle((VALUE)n);
+ break;
+ }
+ prev = &n->u2.node;
+ }
+ xfree(ptr);
+}
#endif
+#endif
#ifdef RIPPER
#ifdef RIPPER_DEBUG
@@ -8811,8 +8727,7 @@
/* :nodoc: */
static VALUE
-ripper_validate_object(self, x)
- VALUE self, x;
+ripper_validate_object(VALUE self, VALUE x)
{
if (x == Qfalse) return x;
if (x == Qtrue) return x;
@@ -8843,28 +8758,20 @@
#define validate(x)
static VALUE
-ripper_dispatch0(parser, mid)
- struct parser_params *parser;
- ID mid;
+ripper_dispatch0(struct parser_params *parser, ID mid)
{
return rb_funcall(parser->value, mid, 0);
}
static VALUE
-ripper_dispatch1(parser, mid, a)
- struct parser_params *parser;
- ID mid;
- VALUE a;
+ripper_dispatch1(struct parser_params *parser, ID mid, VALUE a)
{
validate(a);
return rb_funcall(parser->value, mid, 1, a);
}
static VALUE
-ripper_dispatch2(parser, mid, a, b)
- struct parser_params *parser;
- ID mid;
- VALUE a, b;
+ripper_dispatch2(struct parser_params *parser, ID mid, VALUE a, VALUE b)
{
validate(a);
validate(b);
@@ -8872,10 +8779,7 @@
}
static VALUE
-ripper_dispatch3(parser, mid, a, b, c)
- struct parser_params *parser;
- ID mid;
- VALUE a, b, c;
+ripper_dispatch3(struct parser_params *parser, ID mid, VALUE a, VALUE b, VALUE c)
{
validate(a);
validate(b);
@@ -8884,10 +8788,7 @@
}
static VALUE
-ripper_dispatch4(parser, mid, a, b, c, d)
- struct parser_params *parser;
- ID mid;
- VALUE a, b, c, d;
+ripper_dispatch4(struct parser_params *parser, ID mid, VALUE a, VALUE b, VALUE c, VALUE d)
{
validate(a);
validate(b);
@@ -8897,10 +8798,7 @@
}
static VALUE
-ripper_dispatch5(parser, mid, a, b, c, d, e)
- struct parser_params *parser;
- ID mid;
- VALUE a, b, c, d, e;
+ripper_dispatch5(struct parser_params *parser, ID mid, VALUE a, VALUE b, VALUE c, VALUE d, VALUE e)
{
validate(a);
validate(b);
@@ -8965,8 +8863,7 @@
};
static const char*
-keyword_id_to_str(id)
- ID id;
+keyword_id_to_str(ID id)
{
struct kw_assoc *a;
@@ -8978,8 +8875,7 @@
}
static VALUE
-ripper_id2sym(id)
- ID id;
+ripper_id2sym(ID id)
{
const char *name;
char buf[8];
@@ -9010,100 +8906,64 @@
}
static VALUE
-ripper_intern(s)
- const char *s;
+ripper_intern(const char *s)
{
return ID2SYM(rb_intern(s));
}
-#ifdef HAVE_STDARG_PROTOTYPES
-# include <stdarg.h>
-# define va_init_list(a,b) va_start(a,b)
-#else
-# include <varargs.h>
-# define va_init_list(a,b) va_start(a)
-#endif
-
static void
-#ifdef HAVE_STDARG_PROTOTYPES
ripper_compile_error(struct parser_params *parser, const char *fmt, ...)
-#else
-ripper_compile_error(parser, fmt, va_alist)
- struct parser_params *parser;
- const char *fmt;
- va_dcl
-#endif
{
VALUE str;
va_list args;
- va_init_list(args, fmt);
+ va_start(args, fmt);
str = rb_vsprintf(fmt, args);
va_end(args);
rb_funcall(parser->value, rb_intern("compile_error"), 1, str);
}
static void
-ripper_warn0(parser, fmt)
- struct parser_params *parser;
- const char *fmt;
+ripper_warn0(struct parser_params *parser, const char *fmt)
{
rb_funcall(parser->value, rb_intern("warn"), 1, rb_str_new2(fmt));
}
static void
-ripper_warnI(parser, fmt, a)
- struct parser_params *parser;
- const char *fmt;
- int a;
+ripper_warnI(struct parser_params *parser, const char *fmt, int a)
{
rb_funcall(parser->value, rb_intern("warn"), 2,
rb_str_new2(fmt), INT2NUM(a));
}
static void
-ripper_warnS(parser, fmt, str)
- struct parser_params *parser;
- const char *fmt;
- const char *str;
+ripper_warnS(struct parser_params *parser, const char *fmt, const char *str)
{
rb_funcall(parser->value, rb_intern("warn"), 2,
rb_str_new2(fmt), rb_str_new2(str));
}
static void
-ripper_warning0(parser, fmt)
- struct parser_params *parser;
- const char *fmt;
+ripper_warning0(struct parser_params *parser, const char *fmt)
{
rb_funcall(parser->value, rb_intern("warning"), 1, rb_str_new2(fmt));
}
static void
-ripper_warningS(parser, fmt, str)
- struct parser_params *parser;
- const char *fmt;
- const char *str;
+ripper_warningS(struct parser_params *parser, const char *fmt, const char *str)
{
rb_funcall(parser->value, rb_intern("warning"), 2,
rb_str_new2(fmt), rb_str_new2(str));
}
-static VALUE ripper_lex_get_generic(struct parser_params *, VALUE);
-
static VALUE
-ripper_lex_get_generic(parser, src)
- struct parser_params *parser;
- VALUE src;
+ripper_lex_get_generic(struct parser_params *parser, VALUE src)
{
return rb_funcall(src, ripper_id_gets, 0);
}
-static VALUE ripper_s_allocate(VALUE);
-
static VALUE
-ripper_s_allocate(klass)
- VALUE klass;
+ripper_s_allocate(VALUE klass)
{
struct parser_params *p;
VALUE self;
@@ -9115,16 +8975,6 @@
return self;
}
-static int
-obj_respond_to(obj, mid)
- VALUE obj, mid;
-{
- VALUE st;
-
- st = rb_funcall(obj, rb_intern("respond_to?"), 2, mid, Qfalse);
- return RTEST(st);
-}
-
#define ripper_initialized_p(r) ((r)->parser_lex_input != 0)
/*
@@ -9138,17 +8988,14 @@
* See also Ripper#parse and Ripper.parse.
*/
static VALUE
-ripper_initialize(argc, argv, self)
- int argc;
- VALUE *argv;
- VALUE self;
+ripper_initialize(int argc, VALUE *argv, VALUE self)
{
struct parser_params *parser;
VALUE src, fname, lineno;
Data_Get_Struct(self, struct parser_params, parser);
rb_scan_args(argc, argv, "12", &src, &fname, &lineno);
- if (obj_respond_to(src, ID2SYM(ripper_id_gets))) {
+ if (rb_obj_respond_to(src, ripper_id_gets, 0)) {
parser->parser_lex_gets = ripper_lex_get_generic;
}
else {
@@ -9177,8 +9024,7 @@
* Get yydebug.
*/
static VALUE
-ripper_s_get_yydebug(self)
- VALUE self;
+ripper_s_get_yydebug(VALUE self)
{
return ripper_yydebug ? Qtrue : Qfalse;
}
@@ -9190,8 +9036,7 @@
* Set yydebug.
*/
static VALUE
-ripper_s_set_yydebug(self, flag)
- VALUE self, flag;
+ripper_s_set_yydebug(VALUE self, VALUE flag)
{
ripper_yydebug = RTEST(flag);
return flag;
@@ -9206,8 +9051,7 @@
};
static VALUE
-ripper_parse0(parser_v)
- VALUE parser_v;
+ripper_parse0(VALUE parser_v)
{
struct parser_params *parser;
@@ -9218,8 +9062,7 @@
}
static VALUE
-ripper_ensure(parser_v)
- VALUE parser_v;
+ripper_ensure(VALUE parser_v)
{
struct parser_params *parser;
@@ -9235,8 +9078,7 @@
* Start parsing and returns the value of the root action.
*/
static VALUE
-ripper_parse(self)
- VALUE self;
+ripper_parse(VALUE self)
{
struct parser_params *parser;
@@ -9264,8 +9106,7 @@
* This number starts from 0.
*/
static VALUE
-ripper_column(self)
- VALUE self;
+ripper_column(VALUE self)
{
struct parser_params *parser;
long col;
@@ -9287,8 +9128,7 @@
* This number starts from 1.
*/
static VALUE
-ripper_lineno(self)
- VALUE self;
+ripper_lineno(VALUE self)
{
struct parser_params *parser;
@@ -9303,8 +9143,7 @@
#ifdef RIPPER_DEBUG
/* :nodoc: */
static VALUE
-ripper_assert_Qundef(self, obj, msg)
- VALUE self, obj, msg;
+ripper_assert_Qundef(VALUE self, VALUE obj, VALUE msg)
{
StringValue(msg);
if (obj == Qundef) {
@@ -9315,8 +9154,7 @@
/* :nodoc: */
static VALUE
-ripper_value(self, obj)
- VALUE self, obj;
+ripper_value(VALUE self, VALUE obj)
{
return ULONG2NUM(obj);
}
Modified: trunk/process.c
===================================================================
--- trunk/process.c 2005-10-16 14:41:33 UTC (rev 280)
+++ trunk/process.c 2005-10-27 02:54:30 UTC (rev 281)
@@ -2,8 +2,8 @@
process.c -
- $Author: akr $
- $Date: 2005/09/24 16:36:11 $
+ $Author: matz $
+ $Date: 2005/10/05 16:15:15 $
created at: Tue Aug 10 14:30:50 JST 1993
Copyright (C) 1993-2003 Yukihiro Matsumoto
@@ -2756,6 +2756,7 @@
VALUE nochdir, noclose;
int n;
+ rb_secure(2);
rb_scan_args(argc, argv, "02", &nochdir, &noclose);
#if defined(HAVE_DAEMON)
Modified: trunk/range.c
===================================================================
--- trunk/range.c 2005-10-16 14:41:33 UTC (rev 280)
+++ trunk/range.c 2005-10-27 02:54:30 UTC (rev 281)
@@ -2,8 +2,8 @@
range.c -
- $Author: ocean $
- $Date: 2005/09/12 10:44:20 $
+ $Author: matz $
+ $Date: 2005/10/05 16:15:15 $
created at: Thu Aug 19 17:46:47 JST 1993
Copyright (C) 1993-2003 Yukihiro Matsumoto
@@ -449,9 +449,9 @@
}
else {
b = rb_check_to_integer(range, "begin");
- if (NIL_P(b)) return Qnil;
+ if (NIL_P(b)) return Qfalse;
e = rb_check_to_integer(range, "end");
- if (NIL_P(e)) return Qnil;
+ if (NIL_P(e)) return Qfalse;
excl = RTEST(rb_funcall(range, rb_intern("exclude_end?"), 0));
}
beg = NUM2LONG(b);
Modified: trunk/ruby.h
===================================================================
--- trunk/ruby.h 2005-10-16 14:41:33 UTC (rev 280)
+++ trunk/ruby.h 2005-10-27 02:54:30 UTC (rev 281)
@@ -2,7 +2,7 @@
ruby.h -
- $Author: nobu $
+ $Author: matz $
created at: Thu Jun 10 14:26:32 JST 1993
Copyright (C) 1993-2003 Yukihiro Matsumoto
@@ -479,9 +479,9 @@
#define OBJ_FROZEN(x) FL_TEST((x), FL_FREEZE)
#define OBJ_FREEZE(x) FL_SET((x), FL_FREEZE)
-#define ALLOC_N(type,n) (type*)xmalloc(sizeof(type)*(n))
+#define ALLOC_N(type,n) (type*)xmalloc2((n),sizeof(type))
#define ALLOC(type) (type*)xmalloc(sizeof(type))
-#define REALLOC_N(var,type,n) (var)=(type*)xrealloc((char*)(var),sizeof(type)*(n))
+#define REALLOC_N(var,type,n) (var)=(type*)xrealloc2((char*)(var),(n),sizeof(type))
#define ALLOCA_N(type,n) (type*)alloca(sizeof(type)*(n))
Modified: trunk/test.rb
===================================================================
--- trunk/test.rb 2005-10-16 14:41:33 UTC (rev 280)
+++ trunk/test.rb 2005-10-27 02:54:30 UTC (rev 281)
@@ -1,4 +1,6 @@
+p 0*1
+__END__
p bitblt
p the_answer_to_life_the_universe_and_everything
Modified: trunk/util.c
===================================================================
--- trunk/util.c 2005-10-16 14:41:33 UTC (rev 280)
+++ trunk/util.c 2005-10-27 02:54:30 UTC (rev 281)
@@ -2,8 +2,8 @@
util.c -
- $Author: ocean $
- $Date: 2005/09/14 06:32:32 $
+ $Author: nobu $
+ $Date: 2005/10/11 12:30:48 $
created at: Fri Mar 10 17:22:34 JST 1995
Copyright (C) 1993-2003 Yukihiro Matsumoto
@@ -470,12 +470,9 @@
((*cmp)(b,c,d)<0 ? b : ((*cmp)(a,c,d)<0 ? c : a)) : \
((*cmp)(b,c,d)>0 ? b : ((*cmp)(a,c,d)<0 ? a : c)))
-void ruby_qsort (base, nel, size, cmp, d)
- void* base;
- const int nel;
- const int size;
- int (*cmp)();
- void *d;
+void
+ruby_qsort(void* base, const int nel, const int size,
+ int (*cmp)(const void*, const void*, void*), void *d)
{
register char *l, *r, *m; /* l,r:left,right group m:median point */
register int t, eq_l, eq_r; /* eq_l: all items in left group are equal to S */
Modified: trunk/util.h
===================================================================
--- trunk/util.h 2005-10-16 14:41:33 UTC (rev 280)
+++ trunk/util.h 2005-10-27 02:54:30 UTC (rev 281)
@@ -2,8 +2,8 @@
util.h -
- $Author: ocean $
- $Date: 2005/09/14 06:32:32 $
+ $Author: nobu $
+ $Date: 2005/10/11 12:30:48 $
created at: Thu Mar 9 11:55:53 JST 1995
Copyright (C) 1993-2003 Yukihiro Matsumoto
@@ -43,8 +43,7 @@
void ruby_add_suffix(VALUE str, char *suffix);
#endif
-void ruby_qsort(void*, const int, const int, int (*)(), void*);
-#define qsort(b,n,s,c,d) ruby_qsort(b,n,s,c,d)
+void ruby_qsort(void*, const int, const int, int (*)(const void*,const void*,void*), void*);
void ruby_setenv(const char*, const char*);
void ruby_unsetenv(const char*);
Modified: trunk/variable.c
===================================================================
--- trunk/variable.c 2005-10-16 14:41:33 UTC (rev 280)
+++ trunk/variable.c 2005-10-27 02:54:30 UTC (rev 281)
@@ -1214,16 +1214,16 @@
return (NODE *)load;
}
-void
+VALUE
rb_autoload_load(VALUE klass, ID id)
{
VALUE file;
NODE *load = autoload_delete(klass, id);
if (!load || !(file = load->nd_lit) || rb_provided(RSTRING(file)->ptr)) {
- const_missing(klass, id);
+ return Qfalse;
}
- rb_require_safe(file, load->nd_nth);
+ return rb_require_safe(file, load->nd_nth);
}
static VALUE
@@ -1282,7 +1282,7 @@
while (tmp) {
while (RCLASS(tmp)->iv_tbl && st_lookup(RCLASS(tmp)->iv_tbl,id,&value)) {
if (value == Qundef) {
- rb_autoload_load(tmp, id);
+ if (!RTEST(rb_autoload_load(tmp, id))) break;
continue;
}
if (exclude && tmp == rb_cObject && klass != rb_cObject) {
Modified: trunk/version.h
===================================================================
--- trunk/version.h 2005-10-16 14:41:33 UTC (rev 280)
+++ trunk/version.h 2005-10-27 02:54:30 UTC (rev 281)
@@ -1,14 +1,14 @@
#define RUBY_VERSION "1.9.0"
-#define RUBY_RELEASE_DATE "2005-09-25"
+#define RUBY_RELEASE_DATE "2005-10-12"
#define RUBY_VERSION_CODE 190
-#define RUBY_RELEASE_CODE 20050925
+#define RUBY_RELEASE_CODE 20051012
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 9
#define RUBY_VERSION_TEENY 0
#define RUBY_RELEASE_YEAR 2005
-#define RUBY_RELEASE_MONTH 9
-#define RUBY_RELEASE_DAY 25
+#define RUBY_RELEASE_MONTH 10
+#define RUBY_RELEASE_DAY 12
RUBY_EXTERN const char ruby_version[];
RUBY_EXTERN const char ruby_release_date[];
Modified: trunk/win32/win32.c
===================================================================
--- trunk/win32/win32.c 2005-10-16 14:41:33 UTC (rev 280)
+++ trunk/win32/win32.c 2005-10-27 02:54:30 UTC (rev 281)
@@ -61,7 +61,7 @@
#endif
#if HAVE_WSAWAITFORMULTIPLEEVENTS
-# define USE_INTERRUPT_WINSOCK
+# define USE_INTERRUPT_WINSOCK 1
#endif
#if USE_INTERRUPT_WINSOCK
@@ -2007,21 +2007,34 @@
return ret;
}
+static void catch_interrupt(void);
static long
do_select(int nfds, fd_set *rd, fd_set *wr, fd_set *ex,
struct timeval *timeout)
{
long r = 0;
- if (nfds == 0 && timeout) {
- Sleep(timeout->tv_sec * 1000 + timeout->tv_usec / 1000);
+ if (nfds == 0) {
+ if (timeout)
+ rb_w32_sleep(timeout->tv_sec * 1000 + timeout->tv_usec / 1000);
+ else
+ rb_w32_sleep(INFINITE);
}
else {
+#if !USE_INTERRUPT_WINSOCK
+ int trap_immediate = rb_trap_immediate;
+#endif /* !USE_INTERRUPT_WINSOCK */
+ RUBY_CRITICAL(
r = select(nfds, rd, wr, ex, timeout);
if (r == SOCKET_ERROR) {
errno = map_errno(WSAGetLastError());
r = -1;
}
+ );
+#if !USE_INTERRUPT_WINSOCK
+ rb_trap_immediate = trap_immediate;
+ catch_interrupt();
+#endif /* !USE_INTERRUPT_WINSOCK */
}
return r;
@@ -2051,8 +2064,9 @@
fd_set cons_rd;
fd_set else_rd;
fd_set else_wr;
-#ifdef USE_INTERRUPT_WINSOCK
+#if USE_INTERRUPT_WINSOCK
fd_set trap;
+ int ret;
#endif /* USE_INTERRUPT_WINSOCK */
int nonsock = 0;
@@ -2099,7 +2113,6 @@
ex = &trap;
#endif /* USE_INTERRUPT_WINSOCK */
- RUBY_CRITICAL(
if (nonsock) {
struct timeval rest;
struct timeval wait;
@@ -2137,7 +2150,17 @@
}
else
r = do_select(nfds, rd, wr, ex, timeout);
- );
+
+#if USE_INTERRUPT_WINSOCK
+ RUBY_CRITICAL(ret = __WSAFDIsSet((SOCKET)interrupted_event, ex));
+ if (ret) {
+ // In this case, we must restore all FDs. But this is only a test
+ // code, so we think about that later.
+ errno = EINTR;
+ r = -1;
+ }
+#endif /* USE_INTERRUPT_WINSOCK */
+
return r;
}
Modified: trunk/yarvtest/test_bin.rb
===================================================================
--- trunk/yarvtest/test_bin.rb 2005-10-16 14:41:33 UTC (rev 280)
+++ trunk/yarvtest/test_bin.rb 2005-10-27 02:54:30 UTC (rev 281)
@@ -314,6 +314,18 @@
}
end
+ def test_mul
+ ae %q{
+ 2*0
+ }
+ ae %q{
+ 0*2
+ }
+ ae %q{
+ 2*2
+ }
+ end
+
def test_div
ae %q{
3/2
--
ML: yarv-diff quickml.atdot.net
Info: http://www.atdot.net/~ko1/quickml