summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-05-17 09:54:20 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-05-17 09:54:20 +0000
commitc8bd43a967355ddb5acb2fad757db3faaf7465fb (patch)
treebdf0448fcda73f30315d5591be793946c826ca16
parent32599f5a9d24bf31d4c105be859ccf3f659bf227 (diff)
arity/strict yield
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_3@469 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog34
-rw-r--r--class.c5
-rw-r--r--dln.c2
-rw-r--r--eval.c133
-rw-r--r--ext/extmk.rb.nt3
-rw-r--r--ext/gdbm/extconf.rb6
-rw-r--r--ext/pty/pty.c2
-rw-r--r--ext/readline/readline.c81
-rw-r--r--ext/socket/addrinfo.h7
-rw-r--r--ext/tcltklib/tcltklib.c51
-rw-r--r--lex.c149
-rw-r--r--object.c12
-rw-r--r--parse.c6
-rw-r--r--parse.y6
-rw-r--r--random.c2
-rw-r--r--range.c4
-rw-r--r--regex.c44
-rw-r--r--string.c4
-rw-r--r--win32/Makefile8
19 files changed, 380 insertions, 179 deletions
diff --git a/ChangeLog b/ChangeLog
index 55ed4c9ee9..942085036e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,37 @@
+Mon May 17 12:26:31 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (read_escape): char may be unsigned.
+
+ * string.c (rb_str_succ): ditto.
+
+ * string.c (tr_trans): ditto.
+
+ * object.c (Init_Object): methods `&', `|', `^' are added to nil.
+
+ * range.c (rb_range_beg_len): it should be OK for [0..-len-1].
+
+ * regex.c (re_search): search for byte literal within mbcs.
+
+ * regex.c (is_in_list): parsh
+
+ * regex.c (re_compile_fastmap): should have not alter the loop
+ variable `j' if TRASLATE_P().
+
+ * regex.c (re_compile_pattern): escaped characters should be read
+ by PATFETCH_RAW(c).
+
+Sat May 15 11:23:51 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_match): endline2 (\Z) should not match at the point
+ between a newline and end-of-line, like endline ($).
+
+ * class.c (include_class_new): should initialize iv_tbl to share
+ between module and iclass.
+
+Fri May 14 08:50:27 1999 Akira Endo <akendo@t3.rim.or.jp>
+
+ * regex.c (re_compile_fastmap): it should be k != 0 to skip.
+
Fri May 14 12:46:56 1999 Yukihiro Matsumoto <matz@netlab.co.jp>
* time.c (time_load): a bug in old marshal format support.
diff --git a/class.c b/class.c
index b831c6a3b9..32dc0e1372 100644
--- a/class.c
+++ b/class.c
@@ -199,8 +199,11 @@ include_class_new(module, super)
NEWOBJ(klass, struct RClass);
OBJSETUP(klass, rb_cClass, T_ICLASS);
- klass->m_tbl = RCLASS(module)->m_tbl;
+ if (!RCLASS(module)->iv_tbl) {
+ RCLASS(module)->iv_tbl = st_init_numtable();
+ }
klass->iv_tbl = RCLASS(module)->iv_tbl;
+ klass->m_tbl = RCLASS(module)->m_tbl;
klass->super = super;
if (TYPE(module) == T_ICLASS) {
RBASIC(klass)->klass = RBASIC(module)->klass;
diff --git a/dln.c b/dln.c
index b41603c55d..d041ac4fe7 100644
--- a/dln.c
+++ b/dln.c
@@ -1348,7 +1348,7 @@ dln_load(file)
if (init_fct == NULL) {
aix_loaderror(file);
}
- if (loadbind(0, main_module, init_fct) == -1) {
+ if (loadbind(0, main_module, (void*)init_fct) == -1) {
aix_loaderror(file);
}
(*init_fct)();
diff --git a/eval.c b/eval.c
index 7545a03ac4..46bf5fe9a0 100644
--- a/eval.c
+++ b/eval.c
@@ -681,8 +681,8 @@ static VALUE rb_yield_0 _((VALUE, VALUE, VALUE));
static VALUE rb_call _((VALUE,VALUE,ID,int,VALUE*,int));
static VALUE module_setup _((VALUE,NODE*));
-static VALUE massign _((VALUE,NODE*,VALUE));
-static void assign _((VALUE,NODE*,VALUE));
+static VALUE massign _((VALUE,NODE*,VALUE,int));
+static void assign _((VALUE,NODE*,VALUE,int));
static int safe_level = 0;
/* safe-level:
@@ -2314,7 +2314,7 @@ rb_eval(self, node)
break;
case NODE_MASGN:
- result = massign(self, node, rb_eval(self, node->nd_value));
+ result = massign(self, node, rb_eval(self, node->nd_value),0);
break;
case NODE_LASGN:
@@ -3162,10 +3162,15 @@ rb_yield_0(val, self, klass)
if (!self) self = block->self;
node = block->body;
if (block->var) {
- if (nd_type(block->var) == NODE_MASGN)
- massign(self, block->var, val);
- else
- assign(self, block->var, val);
+ PUSH_TAG(PROT_NONE);
+ if ((state = EXEC_TAG()) == 0) {
+ if (nd_type(block->var) == NODE_MASGN)
+ massign(self, block->var, val, 1);
+ else
+ assign(self, block->var, val, 1);
+ }
+ POP_TAG();
+ if (state) goto pop_state;
}
PUSH_ITER(block->iter);
PUSH_TAG(PROT_NONE);
@@ -3201,6 +3206,7 @@ rb_yield_0(val, self, klass)
}
}
POP_TAG();
+ pop_state:
POP_ITER();
POP_CLASS();
POP_VARS();
@@ -3227,13 +3233,14 @@ rb_f_loop()
}
static VALUE
-massign(self, node, val)
+massign(self, node, val, check)
VALUE self;
NODE *node;
VALUE val;
+ int check;
{
NODE *list;
- int i, len;
+ int i = 0, len;
list = node->nd_head;
@@ -3243,33 +3250,46 @@ massign(self, node, val)
}
len = RARRAY(val)->len;
for (i=0; list && i<len; i++) {
- assign(self, list->nd_head, RARRAY(val)->ptr[i]);
+ assign(self, list->nd_head, RARRAY(val)->ptr[i], check);
list = list->nd_next;
}
+ if (check && list) goto arg_error;
if (node->nd_args) {
if (!list && i<len) {
- assign(self, node->nd_args, rb_ary_new4(len-i, RARRAY(val)->ptr+i));
+ assign(self, node->nd_args, rb_ary_new4(len-i, RARRAY(val)->ptr+i), check);
}
else {
- assign(self, node->nd_args, rb_ary_new2(0));
+ assign(self, node->nd_args, rb_ary_new2(0), check);
}
}
+ else if (check && i<len) goto arg_error;
}
else if (node->nd_args) {
- assign(self, node->nd_args, Qnil);
+ assign(self, node->nd_args, Qnil, check);
}
+
+ if (check && list) goto arg_error;
while (list) {
- assign(self, list->nd_head, Qnil);
+ i++;
+ assign(self, list->nd_head, Qnil, check);
list = list->nd_next;
}
return val;
+
+ arg_error:
+ while (list) {
+ i++;
+ list = list->nd_next;
+ }
+ rb_raise(rb_eArgError, "wrong # of arguments (%d for %d)", len, i);
}
static void
-assign(self, lhs, val)
+assign(self, lhs, val, check)
VALUE self;
NODE *lhs;
VALUE val;
+ int check;
{
switch (nd_type(lhs)) {
case NODE_GASGN:
@@ -3299,7 +3319,7 @@ assign(self, lhs, val)
break;
case NODE_MASGN:
- massign(self, lhs, val);
+ massign(self, lhs, val, check);
break;
case NODE_CALL:
@@ -3852,7 +3872,7 @@ rb_call0(klass, recv, id, argc, argv, body, nosuper)
NODE *opt = node->nd_opt;
while (opt && argc) {
- assign(recv, opt->nd_head, *argv);
+ assign(recv, opt->nd_head, *argv, 1);
argv++; argc--;
opt = opt->nd_next;
}
@@ -5427,10 +5447,19 @@ proc_call(proc, args)
struct BLOCK * volatile old_block;
struct BLOCK *data;
volatile VALUE result = Qnil;
- int state;
+ int state, n;
volatile int orphan;
volatile int safe = safe_level;
+ Data_Get_Struct(proc, struct BLOCK, data);
+ orphan = blk_orphan(data);
+
+ /* PUSH BLOCK from data */
+ old_block = ruby_block;
+ ruby_block = data;
+ PUSH_ITER(ITER_CUR);
+ ruby_frame->iter = ITER_CUR;
+
if (TYPE(args) == T_ARRAY) {
switch (RARRAY(args)->len) {
case 0:
@@ -5442,15 +5471,6 @@ proc_call(proc, args)
}
}
- Data_Get_Struct(proc, struct BLOCK, data);
- orphan = blk_orphan(data);
-
- /* PUSH BLOCK from data */
- old_block = ruby_block;
- ruby_block = data;
- PUSH_ITER(ITER_CUR);
- ruby_frame->iter = ITER_CUR;
-
if (orphan) {/* orphan procedure */
if (rb_iterator_p()) {
ruby_block->frame.iter = ITER_CUR;
@@ -5495,6 +5515,31 @@ proc_call(proc, args)
}
static VALUE
+proc_arity(proc)
+ VALUE proc;
+{
+ struct BLOCK *data;
+ NODE *list;
+ int n;
+
+ Data_Get_Struct(proc, struct BLOCK, data);
+ if (data->var == 0) return 0;
+ switch (nd_type(data->var)) {
+ default:
+ return INT2FIX(-1);
+ case NODE_MASGN:
+ list = data->var->nd_head;
+ n = 0;
+ while (list) {
+ n++;
+ list = list->nd_next;
+ }
+ if (data->var->nd_args) return INT2FIX(-n);
+ return INT2FIX(n);
+ }
+}
+
+static VALUE
block_pass(self, node)
VALUE self;
NODE *node;
@@ -5646,6 +5691,38 @@ method_call(argc, argv, method)
}
static VALUE
+method_arity(method)
+ VALUE method;
+{
+ struct METHOD *data;
+ NODE *body;
+ int n;
+
+ Data_Get_Struct(method, struct METHOD, data);
+
+ body = data->body;
+ switch (nd_type(body)) {
+ case NODE_CFUNC:
+ if (body->nd_argc < 0) return INT2FIX(-1);
+ return INT2FIX(body->nd_argc);
+ case NODE_ZSUPER:
+ return INT2FIX(-1);
+ case NODE_ATTRSET:
+ return INT2FIX(1);
+ case NODE_IVAR:
+ return INT2FIX(0);
+ default:
+ body = body->nd_next; /* skip NODE_SCOPE */
+ if (nd_type(body) == NODE_BLOCK)
+ body = body->nd_head;
+ if (!body) return INT2FIX(0);
+ n = body->nd_cnt;
+ if (body->nd_rest) n = -n;
+ return INT2FIX(n);
+ }
+}
+
+static VALUE
method_inspect(method)
VALUE method;
{
@@ -5710,6 +5787,7 @@ Init_Proc()
rb_define_singleton_method(rb_cProc, "new", proc_s_new, 0);
rb_define_method(rb_cProc, "call", proc_call, -2);
+ rb_define_method(rb_cProc, "arity", proc_arity, 0);
rb_define_method(rb_cProc, "[]", proc_call, -2);
rb_define_global_function("proc", rb_f_lambda, 0);
rb_define_global_function("lambda", rb_f_lambda, 0);
@@ -5722,6 +5800,7 @@ Init_Proc()
rb_undef_method(CLASS_OF(rb_cMethod), "new");
rb_define_method(rb_cMethod, "call", method_call, -1);
rb_define_method(rb_cMethod, "[]", method_call, -1);
+ rb_define_method(rb_cMethod, "arity", method_arity, 0);
rb_define_method(rb_cMethod, "inspect", method_inspect, 0);
rb_define_method(rb_cMethod, "to_s", method_inspect, 0);
rb_define_method(rb_cMethod, "to_proc", method_proc, 0);
diff --git a/ext/extmk.rb.nt b/ext/extmk.rb.nt
index 379d1bbb41..436cac295f 100644
--- a/ext/extmk.rb.nt
+++ b/ext/extmk.rb.nt
@@ -59,6 +59,7 @@ def older(file1, file2)
return false
end
+CFLAGS = ""
#LINK = "cl -o conftest.exe -I../.. -Zi -O -I. %s conftest.c %s > nul"
LINK = "cl -o conftest.exe -Zi -O %s conftest.c %s > nul"
CPP = "cl -E -I../.. -I../../missing -I../../win32 -I. -Zi -O %s conftest.c > nul"
@@ -435,8 +436,6 @@ def extmake(target)
return if $nodynamic and not $static
- $CFLAGS = nil
- $LDFLAGS = nil
$LOCAL_LIBS = "" # to be assigned in extconf.rb
$CFLAGS = ""
$LDFLAGS = ""
diff --git a/ext/gdbm/extconf.rb b/ext/gdbm/extconf.rb
index 3c36f29f14..bb51ac8971 100644
--- a/ext/gdbm/extconf.rb
+++ b/ext/gdbm/extconf.rb
@@ -1,7 +1,7 @@
require 'mkmf'
$LDFLAGS = "-L/usr/local/lib"
-have_library("gdbm", "gdbm_open")
-have_header("gdbm.h")
-if have_func("gdbm_open")
+if have_library("gdbm", "gdbm_open") and
+ have_header("gdbm.h") and
+ have_func("gdbm_open") then
create_makefile("gdbm")
end
diff --git a/ext/pty/pty.c b/ext/pty/pty.c
index 3748b55e47..8184b90185 100644
--- a/ext/pty/pty.c
+++ b/ext/pty/pty.c
@@ -180,7 +180,7 @@ chld_changed()
rb_raise(rb_eRuntimeError, "Stopped: %d",cpid);
}
#else
-#error "Either IF_STOPPED or WIFSTOPPED is needed"
+---->> Either IF_STOPPED or WIFSTOPPED is needed <<----
#endif /* WIFSTOPPED */
#endif /* IF_STOPPED */
if (n >= 0) {
diff --git a/ext/readline/readline.c b/ext/readline/readline.c
index dbee8c7963..60d45bf56b 100644
--- a/ext/readline/readline.c
+++ b/ext/readline/readline.c
@@ -23,7 +23,10 @@ readline_event()
}
static VALUE
-readline_readline(int argc, VALUE *argv, VALUE self)
+readline_readline(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
VALUE tmp, add_hist, result;
char *prompt = NULL;
@@ -45,7 +48,9 @@ readline_readline(int argc, VALUE *argv, VALUE self)
}
static VALUE
-readline_s_set_completion_proc(VALUE self, VALUE proc)
+readline_s_set_completion_proc(self, proc)
+ VALUE self;
+ VALUE proc;
{
if (!rb_respond_to(proc, rb_intern("call")))
rb_raise(rb_eArgError, "argument have to respond to `call'");
@@ -53,25 +58,32 @@ readline_s_set_completion_proc(VALUE self, VALUE proc)
}
static VALUE
-readline_s_get_completion_proc(VALUE self)
+readline_s_get_completion_proc(self)
+ VALUE self;
{
return rb_iv_get(mReadline, COMPLETION_PROC);
}
static VALUE
-readline_s_set_completion_case_fold(VALUE self, VALUE val)
+readline_s_set_completion_case_fold(self, val)
+ VALUE self;
+ VALUE val;
{
return rb_iv_set(mReadline, COMPLETION_CASE_FOLD, val);
}
static VALUE
-readline_s_get_completion_case_fold(VALUE self)
+readline_s_get_completion_case_fold(self)
+ VALUE self;
{
return rb_iv_get(mReadline, COMPLETION_CASE_FOLD);
}
static char **
-readline_attempted_completion_function(char *text, int start, int end)
+readline_attempted_completion_function(text, start, end)
+ char *text;
+ int start;
+ int end;
{
VALUE proc, ary, temp;
char **result;
@@ -133,27 +145,32 @@ readline_attempted_completion_function(char *text, int start, int end)
}
static VALUE
-readline_s_vi_editing_mode(VALUE self)
+readline_s_vi_editing_mode(self)
+ VALUE self;
{
rl_vi_editing_mode(1,0);
return Qnil;
}
static VALUE
-readline_s_emacs_editing_mode(VALUE self)
+readline_s_emacs_editing_mode(self)
+ VALUE self;
{
rl_emacs_editing_mode(1,0);
return Qnil;
}
static VALUE
-hist_to_s(VALUE self)
+hist_to_s(self)
+ VALUE self;
{
return rb_str_new2("HISTORY");
}
static VALUE
-hist_get(VALUE self, VALUE index)
+hist_get(self, index)
+ VALUE self;
+ VALUE index;
{
HISTORY_STATE *state;
int i;
@@ -167,7 +184,10 @@ hist_get(VALUE self, VALUE index)
}
static VALUE
-hist_set(VALUE self, VALUE index, VALUE str)
+hist_set(self, index, str)
+ VALUE self;
+ VALUE index;
+ VALUE str;
{
HISTORY_STATE *state;
int i;
@@ -182,15 +202,19 @@ hist_set(VALUE self, VALUE index, VALUE str)
}
static VALUE
-hist_push(VALUE self, VALUE str)
+hist_push(self, str)
+ VALUE self;
+ VALUE str;
{
add_history(STR2CSTR(str));
return self;
}
static VALUE
-hist_push_method(int argc, VALUE *argv,
- VALUE self)
+hist_push_method(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
VALUE str;
@@ -202,7 +226,8 @@ hist_push_method(int argc, VALUE *argv,
}
static VALUE
-hist_pop(VALUE self)
+hist_pop(self)
+ VALUE self;
{
HISTORY_STATE *state;
HIST_ENTRY *entry;
@@ -217,7 +242,8 @@ hist_pop(VALUE self)
}
static VALUE
-hist_shift(VALUE self)
+hist_shift(self)
+ VALUE self;
{
HISTORY_STATE *state;
HIST_ENTRY *entry;
@@ -232,7 +258,8 @@ hist_shift(VALUE self)
}
static VALUE
-hist_each(VALUE self)
+hist_each(self)
+ VALUE self;
{
HISTORY_STATE *state;
int i;
@@ -245,7 +272,8 @@ hist_each(VALUE self)
}
static VALUE
-hist_length(VALUE self)
+hist_length(self)
+ VALUE self;
{
HISTORY_STATE *state;
@@ -254,7 +282,8 @@ hist_length(VALUE self)
}
static VALUE
-hist_empty_p(VALUE self)
+hist_empty_p(self)
+ VALUE self;
{
HISTORY_STATE *state;
@@ -266,7 +295,9 @@ hist_empty_p(VALUE self)
}
static VALUE
-hist_delete_at(VALUE self, VALUE index)
+hist_delete_at(self, index)
+ VALUE self;
+ VALUE index;
{
HISTORY_STATE *state;
HIST_ENTRY *entry;
@@ -282,7 +313,9 @@ hist_delete_at(VALUE self, VALUE index)
}
static VALUE
-filename_completion_proc_call(VALUE self, VALUE str)
+filename_completion_proc_call(self, str)
+ VALUE self;
+ VALUE str;
{
VALUE result;
char **matches;
@@ -307,7 +340,9 @@ filename_completion_proc_call(VALUE self, VALUE str)
}
static VALUE
-username_completion_proc_call(VALUE self, VALUE str)
+username_completion_proc_call(self, str)
+ VALUE self;
+ VALUE str;
{
VALUE result;
char **matches;
@@ -332,7 +367,7 @@ username_completion_proc_call(VALUE self, VALUE str)
}
void
-Init_readline(void)
+Init_readline()
{
VALUE histary, fcomp, ucomp;
diff --git a/ext/socket/addrinfo.h b/ext/socket/addrinfo.h
index d4e2091d69..6ea4a823f6 100644
--- a/ext/socket/addrinfo.h
+++ b/ext/socket/addrinfo.h
@@ -154,4 +154,11 @@ extern void freehostent __P((struct hostent *));
extern void freeaddrent __P((struct addrinfo *));
extern char *gai_strerror __P((int));
+/* In case there is no definition of offsetof() provided - though any proper
+Standard C system should have one. */
+
+#ifndef offsetof
+#define offsetof(p_type,field) ((size_t)&(((p_type *)0)->field))
+#endif
+
#endif
diff --git a/ext/tcltklib/tcltklib.c b/ext/tcltklib/tcltklib.c
index a08391b7bb..ffc6f2f57c 100644
--- a/ext/tcltklib/tcltklib.c
+++ b/ext/tcltklib/tcltklib.c
@@ -49,7 +49,8 @@ typedef struct {
} Tk_TimerData;
/* timer callback */
-void _timer_for_tcl (ClientData clientData)
+void _timer_for_tcl(clientData)
+ ClientData clientData;
{
Tk_TimerData *timer = (Tk_TimerData*)clientData;
@@ -64,7 +65,8 @@ void _timer_for_tcl (ClientData clientData)
/* execute Tk_MainLoop */
static VALUE
-lib_mainloop(VALUE self)
+lib_mainloop(self)
+ VALUE self;
{
Tk_TimerData *timer;
@@ -95,7 +97,9 @@ struct tcltkip {
/* Tcl command `ruby' */
static VALUE
-ip_eval_rescue(VALUE *failed, VALUE einfo)
+ip_eval_rescue(failed, einfo)
+ VALUE *failed;
+ VALUE einfo;
{
*failed = einfo;
return Qnil;
@@ -103,10 +107,17 @@ ip_eval_rescue(VALUE *failed, VALUE einfo)
static int
#if TCL_MAJOR_VERSION >= 8
-ip_ruby(ClientData clientData, Tcl_Interp *interp,
- int argc, Tcl_Obj *CONST argv[])
+ip_ruby(clientData, interp, argc, argv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int argc;
+ Tcl_Obj *CONST argv[];
#else
-ip_ruby(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[])
+ip_ruby(clientData, interp, argc, argv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int argc;
+ char *argv[];
#endif
{
VALUE res;
@@ -163,7 +174,8 @@ ip_ruby(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[])
/* destroy interpreter */
static void
-ip_free(struct tcltkip *ptr)
+ip_free(ptr)
+ struct tcltkip *ptr;
{
DUMP1("Tcl_DeleteInterp");
Tcl_DeleteInterp(ptr->ip);
@@ -172,7 +184,8 @@ ip_free(struct tcltkip *ptr)
/* create and initialize interpreter */
static VALUE
-ip_new(VALUE self)
+ip_new(self)
+ VALUE self;
{
struct tcltkip *ptr; /* tcltkip data struct */
VALUE obj; /* newly created object */
@@ -214,7 +227,9 @@ ip_new(VALUE self)
/* eval string in tcl by Tcl_Eval() */
static VALUE
-ip_eval(VALUE self, VALUE str)
+ip_eval(self, str)
+ VALUE self;
+ VALUE str;
{
char *s;
char *buf; /* Tcl_Eval requires re-writable string region */
@@ -240,7 +255,10 @@ ip_eval(VALUE self, VALUE str)
static VALUE
-ip_toUTF8(VALUE self, VALUE str, VALUE encodename)
+ip_toUTF8(self, str, encodename)
+ VALUE self;
+ VALUE str;
+ VALUE encodename;
{
#ifndef TCL_UTF_MAX
return str;
@@ -272,7 +290,10 @@ ip_toUTF8(VALUE self, VALUE str, VALUE encodename)
}
static VALUE
-ip_fromUTF8(VALUE self, VALUE str, VALUE encodename)
+ip_fromUTF8(self, str, encodename)
+ VALUE self;
+ VALUE str;
+ VALUE encodename;
{
#ifndef TCL_UTF_MAX
return str;
@@ -305,7 +326,10 @@ ip_fromUTF8(VALUE self, VALUE str, VALUE encodename)
static VALUE
-ip_invoke(int argc, VALUE *argv, VALUE obj)
+ip_invoke(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
{
struct tcltkip *ptr; /* tcltkip data struct */
int i;
@@ -384,7 +408,8 @@ ip_invoke(int argc, VALUE *argv, VALUE obj)
/* get return code from Tcl_Eval() */
static VALUE
-ip_retval(VALUE self)
+ip_retval(self)
+ VALUE self;
{
struct tcltkip *ptr; /* tcltkip data struct */
diff --git a/lex.c b/lex.c
index 1abc048638..62e1ef6f61 100644
--- a/lex.c
+++ b/lex.c
@@ -1,5 +1,5 @@
-/* C code produced by gperf version 2.5 (GNU C++ version) */
-/* Command-line: gperf -p -j1 -i 1 -g -o -t -N rb_reserved_word -k1,3,$ keywords */
+/* C code produced by gperf version 2.7.1 (19981006 egcs) */
+/* Command-line: gperf -p -j1 -i 1 -g -o -t -N rb_reserved_word -k1,3,$ ./keywords */
struct kwtable {char *name; int id[2]; enum lex_state state;};
#define TOTAL_KEYWORDS 40
@@ -10,28 +10,41 @@ struct kwtable {char *name; int id[2]; enum lex_state state;};
/* maximum key range = 50, duplicates = 0 */
#ifdef __GNUC__
-inline
+__inline
#endif
static unsigned int
hash (str, len)
- register char *str;
- register int unsigned len;
+ register const char *str;
+ register unsigned int len;
{
static unsigned char asso_values[] =
{
- 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
- 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
- 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
- 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
- 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
- 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
- 56, 56, 56, 11, 56, 56, 36, 56, 1, 37,
- 31, 1, 56, 56, 56, 56, 29, 56, 1, 56,
- 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
- 56, 56, 56, 56, 56, 1, 56, 32, 1, 2,
- 1, 1, 4, 23, 56, 17, 56, 20, 9, 2,
- 9, 26, 14, 56, 5, 1, 1, 16, 56, 21,
- 20, 9, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 11, 56, 56, 36, 56, 1, 37,
+ 31, 1, 56, 56, 56, 56, 29, 56, 1, 56,
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 1, 56, 32, 1, 2,
+ 1, 1, 4, 23, 56, 17, 56, 20, 9, 2,
+ 9, 26, 14, 56, 5, 1, 1, 16, 56, 21,
+ 20, 9, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
+ 56, 56, 56, 56, 56, 56
};
register int hval = len;
@@ -39,68 +52,68 @@ hash (str, len)
{
default:
case 3:
- hval += asso_values[str[2]];
+ hval += asso_values[(unsigned char)str[2]];
case 2:
case 1:
- hval += asso_values[str[0]];
+ hval += asso_values[(unsigned char)str[0]];
break;
}
- return hval + asso_values[str[len - 1]];
+ return hval + asso_values[(unsigned char)str[len - 1]];
}
#ifdef __GNUC__
-inline
+__inline
#endif
struct kwtable *
rb_reserved_word (str, len)
- register char *str;
+ register const char *str;
register unsigned int len;
{
static struct kwtable wordlist[] =
{
- {"",}, {"",}, {"",}, {"",}, {"",}, {"",},
- {"end", kEND, kEND, EXPR_END},
- {"else", kELSE, kELSE, EXPR_BEG},
- {"case", kCASE, kCASE, EXPR_BEG},
- {"ensure", kENSURE, kENSURE, EXPR_BEG},
- {"module", kMODULE, kMODULE, EXPR_BEG},
- {"elsif", kELSIF, kELSIF, EXPR_BEG},
- {"def", kDEF, kDEF, EXPR_FNAME},
- {"rescue", kRESCUE, kRESCUE, EXPR_MID},
- {"not", kNOT, kNOT, EXPR_BEG},
- {"then", kTHEN, kTHEN, EXPR_BEG},
- {"yield", kYIELD, kYIELD, EXPR_END},
- {"for", kFOR, kFOR, EXPR_BEG},
- {"self", kSELF, kSELF, EXPR_END},
- {"false", kFALSE, kFALSE, EXPR_END},
- {"retry", kRETRY, kRETRY, EXPR_END},
- {"return", kRETURN, kRETURN, EXPR_MID},
- {"true", kTRUE, kTRUE, EXPR_END},
- {"if", kIF, kIF_MOD, EXPR_BEG},
- {"defined?", kDEFINED, kDEFINED, EXPR_END},
- {"super", kSUPER, kSUPER, EXPR_END},
- {"undef", kUNDEF, kUNDEF, EXPR_FNAME},
- {"break", kBREAK, kBREAK, EXPR_END},
- {"in", kIN, kIN, EXPR_BEG},
- {"do", kDO, kDO, EXPR_BEG},
- {"nil", kNIL, kNIL, EXPR_END},
- {"until", kUNTIL, kUNTIL_MOD, EXPR_BEG},
- {"unless", kUNLESS, kUNLESS_MOD, EXPR_BEG},
- {"or", kOR, kOR, EXPR_BEG},
- {"next", kNEXT, kNEXT, EXPR_END},
- {"when", kWHEN, kWHEN, EXPR_BEG},
- {"redo", kREDO, kREDO, EXPR_END},
- {"and", kAND, kAND, EXPR_BEG},
- {"begin", kBEGIN, kBEGIN, EXPR_BEG},
- {"__LINE__", k__LINE__, k__LINE__, EXPR_END},
- {"class", kCLASS, kCLASS, EXPR_CLASS},
- {"__FILE__", k__FILE__, k__FILE__, EXPR_END},
- {"END", klEND, klEND, EXPR_END},
- {"BEGIN", klBEGIN, klBEGIN, EXPR_END},
- {"while", kWHILE, kWHILE_MOD, EXPR_BEG},
- {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",},
- {"",},
- {"alias", kALIAS, kALIAS, EXPR_FNAME},
+ {""}, {""}, {""}, {""}, {""}, {""},
+ {"end", kEND, kEND, EXPR_END},
+ {"else", kELSE, kELSE, EXPR_BEG},
+ {"case", kCASE, kCASE, EXPR_BEG},
+ {"ensure", kENSURE, kENSURE, EXPR_BEG},
+ {"module", kMODULE, kMODULE, EXPR_BEG},
+ {"elsif", kELSIF, kELSIF, EXPR_BEG},
+ {"def", kDEF, kDEF, EXPR_FNAME},
+ {"rescue", kRESCUE, kRESCUE, EXPR_MID},
+ {"not", kNOT, kNOT, EXPR_BEG},
+ {"then", kTHEN, kTHEN, EXPR_BEG},
+ {"yield", kYIELD, kYIELD, EXPR_END},
+ {"for", kFOR, kFOR, EXPR_BEG},
+ {"self", kSELF, kSELF, EXPR_END},
+ {"false", kFALSE, kFALSE, EXPR_END},
+ {"retry", kRETRY, kRETRY, EXPR_END},
+ {"return", kRETURN, kRETURN, EXPR_MID},
+ {"true", kTRUE, kTRUE, EXPR_END},
+ {"if", kIF, kIF_MOD, EXPR_BEG},
+ {"defined?", kDEFINED, kDEFINED, EXPR_END},
+ {"super", kSUPER, kSUPER, EXPR_END},
+ {"undef", kUNDEF, kUNDEF, EXPR_FNAME},
+ {"break", kBREAK, kBREAK, EXPR_END},
+ {"in", kIN, kIN, EXPR_BEG},
+ {"do", kDO, kDO, EXPR_BEG},
+ {"nil", kNIL, kNIL, EXPR_END},
+ {"until", kUNTIL, kUNTIL_MOD, EXPR_BEG},
+ {"unless", kUNLESS, kUNLESS_MOD, EXPR_BEG},
+ {"or", kOR, kOR, EXPR_BEG},
+ {"next", kNEXT, kNEXT, EXPR_END},
+ {"when", kWHEN, kWHEN, EXPR_BEG},
+ {"redo", kREDO, kREDO, EXPR_END},
+ {"and", kAND, kAND, EXPR_BEG},
+ {"begin", kBEGIN, kBEGIN, EXPR_BEG},
+ {"__LINE__", k__LINE__, k__LINE__, EXPR_END},
+ {"class", kCLASS, kCLASS, EXPR_CLASS},
+ {"__FILE__", k__FILE__, k__FILE__, EXPR_END},
+ {"END", klEND, klEND, EXPR_END},
+ {"BEGIN", klBEGIN, klBEGIN, EXPR_END},
+ {"while", kWHILE, kWHILE_MOD, EXPR_BEG},
+ {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+ {""},
+ {"alias", kALIAS, kALIAS, EXPR_FNAME}
};
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
@@ -109,9 +122,9 @@ rb_reserved_word (str, len)
if (key <= MAX_HASH_VALUE && key >= 0)
{
- register char *s = wordlist[key].name;
+ register const char *s = wordlist[key].name;
- if (*s == *str && !strcmp (str + 1, s + 1))
+ if (*str == *s && !strcmp (str + 1, s + 1))
return &wordlist[key];
}
}
diff --git a/object.c b/object.c
index d6a4a72e07..4118dc76d2 100644
--- a/object.c
+++ b/object.c
@@ -1019,6 +1019,8 @@ Init_Object()
rb_define_method(rb_mKernel, "kind_of?", rb_obj_is_kind_of, 1);
rb_define_method(rb_mKernel, "is_a?", rb_obj_is_kind_of, 1);
+ rb_define_global_function("singleton_method_added", rb_obj_dummy, 1);
+
rb_define_global_function("sprintf", rb_f_sprintf, -1);
rb_define_global_function("format", rb_f_sprintf, -1);
@@ -1034,18 +1036,14 @@ Init_Object()
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);
+ rb_define_method(rb_cNilClass, "^", false_xor, 1);
rb_define_method(rb_cNilClass, "nil?", rb_true, 0);
rb_undef_method(CLASS_OF(rb_cNilClass), "new");
rb_define_global_const("NIL", Qnil);
- /* default addition */
-#ifdef NIL_PLUS
- rb_define_method(rb_cNilClass, "+", nil_plus, 1);
-#endif
-
- rb_define_global_function("singleton_method_added", rb_obj_dummy, 1);
-
rb_define_method(rb_cModule, "===", rb_mod_eqq, 1);
rb_define_method(rb_cModule, "<=>", rb_mod_cmp, 1);
rb_define_method(rb_cModule, "<", rb_mod_lt, 1);
diff --git a/parse.c b/parse.c
index 40a586d84c..8b62868663 100644
--- a/parse.c
+++ b/parse.c
@@ -4945,8 +4945,10 @@ read_escape()
int i;
for (i=0; i<2; i++) {
- buf[i] = nextc();
- if (buf[i] == -1) goto eof;
+ int cc = nextc();
+
+ if (cc == -1) goto eof;
+ buf[i] = cc;
if (!ISXDIGIT(buf[i])) {
pushback(buf[i]);
break;
diff --git a/parse.y b/parse.y
index cabced742b..9ce595da4c 100644
--- a/parse.y
+++ b/parse.y
@@ -1882,8 +1882,10 @@ read_escape()
int i;
for (i=0; i<2; i++) {
- buf[i] = nextc();
- if (buf[i] == -1) goto eof;
+ int cc = nextc();
+
+ if (cc == -1) goto eof;
+ buf[i] = cc;
if (!ISXDIGIT(buf[i])) {
pushback(buf[i]);
break;
diff --git a/random.c b/random.c
index 137b34d579..081d31ed00 100644
--- a/random.c
+++ b/random.c
@@ -69,7 +69,7 @@ void srand48 _((long));
#endif /* HAVE_RANDOM */
/* 0 <= RANDOM_NUMBER <= 1 */
-#define RANDOM_NUMBER (((double)RANDOM())/(double)RANDOM_MAX)
+#define RANDOM_NUMBER (((double)RANDOM())/(double)RANDOM_MAX+1)
#endif /* not HAVE_DRAND48 */
diff --git a/range.c b/range.c
index d2ce1f0058..51bcc2f81f 100644
--- a/range.c
+++ b/range.c
@@ -189,7 +189,7 @@ rb_range_beg_len(range, begp, lenp, len, err)
beg += len;
if (beg < 0) goto out_of_range;
}
- if (err == 2) {
+ if (err == 0 || err == 2) {
if (beg > len) goto out_of_range;
if (end > len || (!EXCL(range) && end == len))
goto out_of_range;
@@ -197,7 +197,7 @@ rb_range_beg_len(range, begp, lenp, len, err)
if (end < 0) {
end += len;
if (end < 0) {
- if (err == 1 && e == -1 && !EXCL(range)) {
+ if (beg == 0 && end == -1 && !EXCL(range)) {
len = 0;
goto length_set;
}
diff --git a/regex.c b/regex.c
index 52094fe87b..29e720776b 100644
--- a/regex.c
+++ b/regex.c
@@ -75,7 +75,7 @@ void *xcalloc _((unsigned long,unsigned long));
void *xrealloc _((void*,unsigned long));
void free _((void*));
-/* #define NO_ALLOCA /* try it out for now */
+/* #define NO_ALLOCA */ /* try it out for now */
#ifndef NO_ALLOCA
/* Make alloca work the best possible way. */
#ifdef __GNUC__
@@ -678,11 +678,10 @@ is_in_list(c, b)
{
unsigned short size;
unsigned short i, j;
- int result = 0;
size = *b++;
if ((int)c / BYTEWIDTH < (int)size && b[c / BYTEWIDTH] & 1 << c % BYTEWIDTH) {
- return 2;
+ return 1;
}
b += size + 2;
size = EXTRACT_UNSIGNED(&b[-2]);
@@ -699,7 +698,7 @@ is_in_list(c, b)
if (i < size && EXTRACT_MBC(&b[i*8]) <= c
&& ((unsigned char)c != '\n' && (unsigned char)c != '\0'))
return 1;
- return result;
+ return 0;
}
static void
@@ -1183,7 +1182,7 @@ re_compile_pattern(pattern, size, bufp)
switch (c) {
case '$':
if (bufp->options & RE_OPTION_POSIXLINE) {
- BUFPUSH(endbuf2);
+ BUFPUSH(endbuf);
}
else {
p0 = p;
@@ -1359,7 +1358,7 @@ re_compile_pattern(pattern, size, bufp)
/* \ escapes characters when inside [...]. */
if (c == '\\') {
- PATFETCH(c);
+ PATFETCH_RAW(c);
switch (c) {
case 'w':
for (c = 0; c < (1 << BYTEWIDTH); c++) {
@@ -2610,8 +2609,7 @@ re_compile_fastmap(bufp)
fastmap[translate['\n']] = 1;
else
fastmap['\n'] = 1;
-
- if (bufp->can_be_null == 0)
+ if ((options & RE_OPTION_POSIXLINE) == 0 && bufp->can_be_null == 0)
bufp->can_be_null = 2;
break;
@@ -2680,7 +2678,7 @@ re_compile_fastmap(bufp)
/* Get to the number of times to succeed. */
EXTRACT_NUMBER(k, p + 2);
/* Increment p past the n for when k != 0. */
- if (k == 0) {
+ if (k != 0) {
p += 4;
}
else {
@@ -2763,9 +2761,8 @@ re_compile_fastmap(bufp)
multi-byte char. See set_list_bits(). */
for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--)
if (p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH))) {
- if (TRANSLATE_P())
- j = translate[j];
- fastmap[j] = (j>0x7f?(ismbchar(j)?0:2):1);
+ int tmp = TRANSLATE_P()?translate[j]:j;
+ fastmap[tmp] = (tmp>0x7f)?2:1;
}
{
unsigned short size;
@@ -2974,11 +2971,12 @@ re_search(bufp, string, size, startpos, range, regs)
int len = mbclen(c) - 1;
if (fastmap[c])
break;
- p += len;
- range -= len + 1;
- c = *p;
- if (fastmap[c] == 2)
- break;
+ while (len--) {
+ c = *p++;
+ range--;
+ if (fastmap[c] == 2)
+ goto startpos_adjust;
+ }
}
else {
if (fastmap[MAY_TRANSLATE() ? translate[c] : c])
@@ -2986,6 +2984,7 @@ re_search(bufp, string, size, startpos, range, regs)
range--;
}
}
+ startpos_adjust:
startpos += irange - range;
}
else { /* Searching backwards. */
@@ -3664,7 +3663,10 @@ re_match(bufp, string_arg, size, pos, regs)
else if (TRANSLATE_P())
cc = c = (unsigned char)translate[c];
- part = not = is_in_list(c, p);
+ not = is_in_list(c, p);
+ if (!not) {
+ not = is_in_list(cc, p);
+ }
if (*(p - 1) == (unsigned char)charset_not) {
not = !not;
}
@@ -3707,8 +3709,10 @@ re_match(bufp, string_arg, size, pos, regs)
/* Match at the very end of the data. */
case endbuf2:
- if (AT_STRINGS_END(d))
- break;
+ if (AT_STRINGS_END(d)) {
+ if (size == 0 || d[-1] != '\n')
+ break;
+ }
/* .. or newline just before the end of the data. */
if (*d == '\n' && AT_STRINGS_END(d+1))
break;
diff --git a/string.c b/string.c
index 09c494463e..f7ebe49caf 100644
--- a/string.c
+++ b/string.c
@@ -701,7 +701,7 @@ rb_str_succ(orig)
{
VALUE str, str2;
char *sbeg, *s;
- char c = -1;
+ int c = -1;
str = rb_str_new(RSTRING(orig)->ptr, RSTRING(orig)->len);
@@ -1708,7 +1708,7 @@ tr_trans(str, src, repl, sflag)
}
}
else {
- char r;
+ int r;
for (i=0; i<256; i++) {
trans[i] = 0;
diff --git a/win32/Makefile b/win32/Makefile
index 89a51004fb..4275d93a55 100644
--- a/win32/Makefile
+++ b/win32/Makefile
@@ -19,7 +19,7 @@ CFLAGS = -nologo -DNT=1 -Ox -I. -I./missing
LDFLAGS = $(CFLAGS) -Fm
#CFLAGS = -nologo -DNT=1 -Zi -MD
#LDFLAGS = $(CFLAGS) -Fm -MD
-LIBS = $(EXTLIBS) advapi32.lib wsock32.lib
+LIBS = advapi32.lib wsock32.lib
MISSING = crypt.obj alloca.obj win32.obj fnmatch.obj isinf.obj isnan.obj
prefix =
@@ -85,7 +85,7 @@ miniruby$(binsuffix): $(OBJS) $(MAINOBJ) $(EXTOBJS)
@echo $(EXTOBJS)
@echo $(LIBS)
@rm -f miniruby$(binsuffix)
- $(PURIFY) $(CC) $(LDFLAGS) $(MAINOBJ) $(EXTOBJS) $(LIBRUBY_A) $(LIBS) -o $@
+ $(PURIFY) $(CC) $(LDFLAGS) $(MAINOBJ) $(EXTOBJS) $(LIBS) -o $@
$(PROGRAM): $(LIBRUBY) $(MAINOBJ) rubymw.dll
@rm -f $(PROGRAM)
@@ -105,7 +105,7 @@ install: rbconfig.rb
clean:; @rm -f $(OBJS) $(LIBRUBY) rbconfig.rb
@rm -f ext/extinit.c ext/extinit.obj *.obj
- @-./miniruby$(binsuffix) -Xext extmk.rb clean 2> /dev/null || true
+ @.\miniruby$(binsuffix) -Xext extmk.rb clean 2> nul || true
distclean: clean
@rm -f Makefile ext/extmk.rb config.h
@@ -118,7 +118,7 @@ realclean: distclean
@rm -f lex.c
test: miniruby$(binsuffix)
- @./miniruby$(binsuffix) $(srcdir)/rubytest.rb
+ @.\miniruby$(binsuffix) $(srcdir)/rubytest.rb
.c.obj:
$(CC) $(CFLAGS) $(CPPFLAGS) -c $<