summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog35
-rw-r--r--ToDo1
-rw-r--r--dir.c4
-rw-r--r--eval.c161
-rw-r--r--ext/pty/pty.c4
-rw-r--r--ext/socket/socket.c19
-rw-r--r--file.c2
-rw-r--r--io.c16
-rw-r--r--object.c21
-rw-r--r--parse.y2
-rw-r--r--regex.h2
-rw-r--r--version.h4
-rw-r--r--win32/Makefile4
-rw-r--r--win32/ruby.def1
14 files changed, 161 insertions, 115 deletions
diff --git a/ChangeLog b/ChangeLog
index 5d12dc93d2..248467fc83 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,34 @@
+Wed May 24 23:17:50 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * win32/Makefile: remove unnecessary mv and rm command call.
+
+Thu May 25 01:35:15 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * parse.y (tokadd_escape): forgot to add `\x' to hexadecimal
+ escape sequences.
+
+ * object.c (rb_obj_dup): dup for normal object (T_OBJECT) copies
+ instance variables only.
+
+Wed May 24 23:49:47 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * object.c (rb_mod_initialize): should provide initialize.
+
+Wed May 24 21:01:04 2000 Katsuyuki Komatsu <komatsu@sarion.co.jp>
+
+ * ext/pty/pty.c: use "" instead of <> to include ruby.h and rubyio.h
+ for BeOS (PowerPC).
+
+ * file.c (rb_find_file): should check dln_find_file() result.
+
+ * win32/ruby.def: add rb_block_given_p.
+
+Wed May 24 16:32:45 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * io.c (rb_io_popen): popen does not take 3rd argument anymore.
+
+ * re.c (rb_reg_desc): re may be zero, check before dereferencing.
+
Wed May 24 16:03:06 2000 Wakou Aoyama <wakou@fsinet.or.jp>
* lib/cgi.rb bug fix: CGI::escape(), CGI::Cookie::new()
@@ -5,7 +36,9 @@ Wed May 24 16:03:06 2000 Wakou Aoyama <wakou@fsinet.or.jp>
Wed May 24 13:12:31 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
- * misc/ruby-mode.el (ruby-parse-region): support `while .. do' etc.
+ * misc/ruby-mode.el (ruby-parse-region): support `while .. do'
+ etc. But corresponding keywords must be at the beginning of
+ line.
Tue May 23 23:50:12 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
diff --git a/ToDo b/ToDo
index 117582c935..89fd0b3a4a 100644
--- a/ToDo
+++ b/ToDo
@@ -76,6 +76,7 @@ Standard Libraries
* String#{pred,prev}, String#downto
* optional stepsize argument for succ()
* Ruby module -- Ruby::Version, Ruby::Interpreter
+* introduce Boolean class; super of TrueClass, FalseClass
Extension Libraries
diff --git a/dir.c b/dir.c
index cfc990406c..03b0efd31d 100644
--- a/dir.c
+++ b/dir.c
@@ -272,7 +272,9 @@ static VALUE
dir_s_open(klass, dirname)
VALUE klass, dirname;
{
- VALUE dir = dir_s_new(1, &dirname, klass);
+ VALUE dir = Data_Wrap_Struct(klass, 0, free_dir, 0);
+
+ dir_initialize(dir, dirname);
if (rb_block_given_p()) {
rb_ensure(rb_yield, dir, dir_close, dir);
return Qnil;
diff --git a/eval.c b/eval.c
index aabe1e598a..8220274a04 100644
--- a/eval.c
+++ b/eval.c
@@ -3330,7 +3330,7 @@ rb_yield_0(val, self, klass, acheck)
static unsigned serial = 1;
if (!ruby_frame->iter || !ruby_block) {
- rb_raise(rb_eLocalJumpError, "yield called out of iterator");
+ rb_raise(rb_eLocalJumpError, "yield called out of block");
}
PUSH_VARS();
@@ -3513,7 +3513,7 @@ assign(self, lhs, val, check)
case NODE_LASGN:
if (ruby_scope->local_vars == 0)
- rb_bug("unexpected iterator variable assignment");
+ rb_bug("unexpected local variable assignment");
ruby_scope->local_vars[lhs->nd_cnt] = val;
break;
@@ -5768,7 +5768,7 @@ proc_new(klass)
struct RVarmap *vars;
if (!rb_block_given_p() && !rb_f_block_given_p()) {
- rb_raise(rb_eArgError, "tried to create Procedure-Object out of iterator");
+ rb_raise(rb_eArgError, "tried to create Procedure-Object without a block");
}
proc = Data_Make_Struct(klass, struct BLOCK, blk_mark, blk_free, data);
@@ -6243,9 +6243,9 @@ VALUE rb_cThread;
extern VALUE rb_last_status;
enum thread_status {
+ THREAD_TO_KILL,
THREAD_RUNNABLE,
THREAD_STOPPED,
- THREAD_TO_KILL,
THREAD_KILLED
};
@@ -6719,7 +6719,6 @@ rb_thread_schedule()
int n, max;
int need_select = 0;
- select_err:
rb_thread_pending = 0;
if (curr_thread == curr_thread->next
&& curr_thread->status == THREAD_RUNNABLE)
@@ -6732,6 +6731,7 @@ rb_thread_schedule()
curr = curr->prev;
}
+ again:
max = 0;
FD_ZERO(&readfds);
FD_ZERO(&writefds);
@@ -6740,14 +6740,17 @@ rb_thread_schedule()
now = -1.0;
FOREACH_THREAD_FROM(curr, th) {
- if (!next && (th->status == THREAD_RUNNABLE || th->status == THREAD_TO_KILL)) {
- found = 1;
+ if (!found) {
+ if (th->status <= THREAD_RUNNABLE)
+ found = 1;
}
- if ((th->wait_for & WAIT_JOIN) && rb_thread_dead(th->join)) {
- th->join = 0;
- th->wait_for = 0;
- th->status = THREAD_RUNNABLE;
- found = 1;
+ if (th->status != THREAD_STOPPED) continue;
+ if (th->wait_for & WAIT_JOIN) {
+ if (rb_thread_dead(th->join)) {
+ th->wait_for = 0;
+ th->status = THREAD_RUNNABLE;
+ found = 1;
+ }
}
if (th->wait_for & WAIT_FD) {
FD_SET(th->fd, &readfds);
@@ -6780,87 +6783,79 @@ rb_thread_schedule()
END_FOREACH_FROM(curr, th);
/* Do the select if needed */
- if (need_select) {
- do {
- /* Convert delay to a timeval */
- /* If a thread is runnable, just poll */
- if (found) {
- delay_tv.tv_sec = 0;
- delay_tv.tv_usec = 0;
- delay_ptr = &delay_tv;
- }
- else if (delay == DELAY_INFTY) {
- delay_ptr = 0;
- }
- else {
- delay_tv.tv_sec = delay;
- delay_tv.tv_usec = (delay - (double)delay_tv.tv_sec)*1e6;
- delay_ptr = &delay_tv;
- }
-
- n = select(max+1, &readfds, &writefds, &exceptfds, delay_ptr);
- if (n < 0) {
- if (rb_trap_pending) rb_trap_exec();
- if (errno = EINTR) goto select_err;
- FOREACH_THREAD(th) {
- if (th->wait_for & WAIT_SELECT) {
- int v = 0;
-
- v |= find_bad_fds(&readfds, &th->readfds, th->fd);
- v |= find_bad_fds(&writefds, &th->writefds, th->fd);
- v |= find_bad_fds(&exceptfds, &th->exceptfds, th->fd);
- if (v) {
- th->select_value = n;
- n = max;
- }
+ if (need_select || !found) {
+ /* Convert delay to a timeval */
+ /* If a thread is runnable, just poll */
+ if (found) {
+ delay_tv.tv_sec = 0;
+ delay_tv.tv_usec = 0;
+ delay_ptr = &delay_tv;
+ }
+ else if (delay == DELAY_INFTY) {
+ delay_ptr = 0;
+ }
+ else {
+ delay_tv.tv_sec = delay;
+ delay_tv.tv_usec = (delay - (double)delay_tv.tv_sec)*1e6;
+ delay_ptr = &delay_tv;
+ }
+
+ n = select(max+1, &readfds, &writefds, &exceptfds, delay_ptr);
+ if (n < 0) {
+ if (rb_trap_pending) rb_trap_exec();
+ if (errno = EINTR) goto again;
+ FOREACH_THREAD(th) {
+ if (th->wait_for & WAIT_SELECT) {
+ int v = 0;
+
+ v |= find_bad_fds(&readfds, &th->readfds, th->fd);
+ v |= find_bad_fds(&writefds, &th->writefds, th->fd);
+ v |= find_bad_fds(&exceptfds, &th->exceptfds, th->fd);
+ if (v) {
+ th->select_value = n;
+ n = max;
}
}
- END_FOREACH(th);
}
- if (n >= 0) {
- now = -1.0;
- /* Some descriptors are ready.
- Make the corresponding threads runnable. */
- FOREACH_THREAD_FROM(curr, th) {
- if ((th->wait_for&WAIT_FD) && FD_ISSET(th->fd, &readfds)) {
- /* Wake up only one thread per fd. */
- FD_CLR(th->fd, &readfds);
- th->status = THREAD_RUNNABLE;
- th->fd = 0;
- th->wait_for = 0;
- found = 1;
- }
- if ((th->wait_for&WAIT_SELECT) &&
- (match_fds(&readfds, &th->readfds, max) ||
- match_fds(&writefds, &th->writefds, max) ||
- match_fds(&exceptfds, &th->exceptfds, max))) {
- /* Wake up only one thread per fd. */
- th->status = THREAD_RUNNABLE;
- th->wait_for = 0;
- intersect_fds(&readfds, &th->readfds, max);
- intersect_fds(&writefds, &th->writefds, max);
- intersect_fds(&exceptfds, &th->exceptfds, max);
- th->select_value = n;
- found = 1;
- }
- if (th->wait_for & WAIT_TIME) {
- if (now < 0.0) now = timeofday();
- if (th->delay <= now) {
- th->wait_for = 0;
- th->status = THREAD_RUNNABLE;
- found = 1;
- }
- }
+ END_FOREACH(th);
+ }
+ if (n > 0) {
+ now = -1.0;
+ /* Some descriptors are ready.
+ Make the corresponding threads runnable. */
+ FOREACH_THREAD_FROM(curr, th) {
+ if ((th->wait_for&WAIT_FD) && FD_ISSET(th->fd, &readfds)) {
+ /* Wake up only one thread per fd. */
+ FD_CLR(th->fd, &readfds);
+ th->status = THREAD_RUNNABLE;
+ th->fd = 0;
+ th->wait_for = 0;
+ found = 1;
+ }
+ if ((th->wait_for&WAIT_SELECT) &&
+ (match_fds(&readfds, &th->readfds, max) ||
+ match_fds(&writefds, &th->writefds, max) ||
+ match_fds(&exceptfds, &th->exceptfds, max))) {
+ /* Wake up only one thread per fd. */
+ th->status = THREAD_RUNNABLE;
+ th->wait_for = 0;
+ intersect_fds(&readfds, &th->readfds, max);
+ intersect_fds(&writefds, &th->writefds, max);
+ intersect_fds(&exceptfds, &th->exceptfds, max);
+ th->select_value = n;
+ found = 1;
}
- END_FOREACH_FROM(curr, th);
}
- } while (!found && delay != DELAY_INFTY);
+ END_FOREACH_FROM(curr, th);
+ }
/* The delays for some of the threads should have expired.
Go through the loop once more, to check the delays. */
+ if (!found && delay != DELAY_INFTY)
+ goto again;
}
FOREACH_THREAD_FROM(curr, th) {
- if (th->status == THREAD_RUNNABLE || th->status == THREAD_TO_KILL) {
+ if (!next && (th->status <= THREAD_RUNNABLE)) {
if (!next || next->priority < th->priority)
next = th;
}
diff --git a/ext/pty/pty.c b/ext/pty/pty.c
index 52257b0560..66907416eb 100644
--- a/ext/pty/pty.c
+++ b/ext/pty/pty.c
@@ -15,8 +15,8 @@
#endif
#include <ctype.h>
-#include <ruby.h>
-#include <rubyio.h>
+#include "ruby.h"
+#include "rubyio.h"
#include <signal.h>
#ifdef HAVE_SYS_STROPTS_H
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index 3f479a303a..0d55e9db30 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -104,9 +104,9 @@ struct sockaddr_storage {
};
#endif
-#define LOOKUP_ORDER_INET 0
-#define LOOKUP_ORDER_INET6 1
-#define LOOKUP_ORDER_UNSPEC 2
+#define LOOKUP_ORDER_UNSPEC 0
+#define LOOKUP_ORDER_INET 1
+#define LOOKUP_ORDER_INET6 2
#if defined(DEFAULT_LOOKUP_ORDER_UNSPEC)
# define LOOKUP_ORDER_DEFAULT LOOKUP_ORDER_UNSPEC
@@ -1928,6 +1928,11 @@ sock_s_getnameinfo(argc, argv)
sa = flags = Qnil;
rb_scan_args(argc, argv, "11", &sa, &flags);
+ fl = 0;
+ if (!NIL_P(flags)) {
+ fl = NUM2INT(flags);
+ }
+
if (TYPE(sa) == T_STRING) {
if (sizeof(ss) < RSTRING(sa)->len) {
rb_raise(rb_eTypeError, "sockaddr length too big");
@@ -1968,9 +1973,10 @@ sock_s_getnameinfo(argc, argv)
strcpy(pbuf, "0");
pptr = NULL;
}
- else if (!NIL_P(port)) {
+ else if (FIXNUM_P(port)) {
snprintf(pbuf, sizeof(pbuf), "%ld", NUM2INT(port));
pptr = pbuf;
+ fl |= NI_NUMERICSERV;
}
else {
strncpy(pbuf, STR2CSTR(port), sizeof(pbuf));
@@ -1999,11 +2005,6 @@ sock_s_getnameinfo(argc, argv)
rb_raise(rb_eTypeError, "expecting String or Array");
}
- fl = 0;
- if (!NIL_P(flags)) {
- fl = NUM2INT(flags);
- }
-
error = getnameinfo(sap, SA_LEN(sap), hbuf, sizeof(hbuf),
pbuf, sizeof(pbuf), fl);
if (error) {
diff --git a/file.c b/file.c
index 3e0a19d37b..c6a0544cd9 100644
--- a/file.c
+++ b/file.c
@@ -2093,7 +2093,7 @@ rb_find_file(file)
}
path = dln_find_file(file, path);
- if (stat(path, &st) == 0) {
+ if (path && stat(path, &st) == 0) {
return path;
}
return 0;
diff --git a/io.c b/io.c
index 4ce2339bbe..f5b6e45e85 100644
--- a/io.c
+++ b/io.c
@@ -1591,9 +1591,9 @@ rb_io_popen(str, argc, argv, klass)
VALUE klass;
{
char *mode;
- VALUE pname, pmode, port, proc;
+ VALUE pname, pmode, port;
- if (rb_scan_args(argc, argv, "12", &pname, &pmode, &proc) == 1) {
+ if (rb_scan_args(argc, argv, "11", &pname, &pmode) == 1) {
mode = "r";
}
else {
@@ -1603,15 +1603,13 @@ rb_io_popen(str, argc, argv, klass)
port = pipe_open(str, mode);
if (NIL_P(port)) {
/* child */
- if (!NIL_P(proc)) {
- rb_eval_cmd(proc, rb_ary_new2(0));
- }
- else if (rb_block_given_p()) {
+ if (rb_block_given_p()) {
rb_yield(Qnil);
+ fflush(stdout);
+ fflush(stderr);
+ _exit(0);
}
- fflush(stdout);
- fflush(stderr);
- _exit(0);
+ return Qnil;
}
RBASIC(port)->klass = klass;
if (rb_block_given_p()) {
diff --git a/object.c b/object.c
index 1a8e20368c..410c964d0e 100644
--- a/object.c
+++ b/object.c
@@ -100,11 +100,10 @@ rb_obj_clone(obj)
rb_raise(rb_eTypeError, "can't clone %s", rb_class2name(CLASS_OF(obj)));
}
clone = rb_obj_alloc(RBASIC(obj)->klass);
+ ROBJECT(clone)->iv_tbl = 0; /* avoid GC crash */
CLONESETUP(clone,obj);
if (ROBJECT(obj)->iv_tbl) {
ROBJECT(clone)->iv_tbl = st_copy(ROBJECT(obj)->iv_tbl);
- RBASIC(clone)->klass = rb_singleton_class_clone(RBASIC(obj)->klass);
- RBASIC(clone)->flags = RBASIC(obj)->flags;
}
return clone;
@@ -114,6 +113,15 @@ static VALUE
rb_obj_dup(obj)
VALUE obj;
{
+ VALUE dup;
+
+ if (TYPE(obj) == T_OBJECT) {
+ dup = rb_obj_alloc(RBASIC(obj)->klass);
+ if (ROBJECT(obj)->iv_tbl) {
+ ROBJECT(dup)->iv_tbl = st_copy(ROBJECT(obj)->iv_tbl);
+ }
+ return dup;
+ }
return rb_funcall(obj, rb_intern("clone"), 0, 0);
}
@@ -624,6 +632,14 @@ rb_mod_cmp(mod, arg)
}
static VALUE
+rb_mod_initialize(argc, argv)
+ int argc;
+ VALUE *argv;
+{
+ return Qnil;
+}
+
+static VALUE
rb_module_s_new(klass)
VALUE klass;
{
@@ -1145,6 +1161,7 @@ Init_Object()
rb_define_private_method(rb_cModule, "attr_accessor", rb_mod_attr_accessor, -1);
rb_define_singleton_method(rb_cModule, "new", rb_module_s_new, 0);
+ rb_define_method(rb_cModule, "initialize", rb_mod_initialize, -1);
rb_define_method(rb_cModule, "instance_methods", rb_class_instance_methods, -1);
rb_define_method(rb_cModule, "public_instance_methods", rb_class_instance_methods, -1);
rb_define_method(rb_cModule, "protected_instance_methods", rb_class_protected_instance_methods, -1);
diff --git a/parse.y b/parse.y
index f292e775bc..b07a10af9e 100644
--- a/parse.y
+++ b/parse.y
@@ -2154,6 +2154,8 @@ tokadd_escape()
{
int numlen;
+ tokadd('\\');
+ tokadd(c);
scan_hex(lex_p, 2, &numlen);
while (numlen--)
tokadd(nextc());
diff --git a/regex.h b/regex.h
index 3c2d1ad50e..c82ddd1ef2 100644
--- a/regex.h
+++ b/regex.h
@@ -76,7 +76,7 @@
/* works line Perl's /s; it's called POSIX for wrong reason */
#define RE_OPTION_POSIXLINE (RE_OPTION_MULTILINE|RE_OPTION_SINGLELINE)
/* search for longest match, in accord with POSIX regexp */
-#define RE_OPTION_LONGEST (RE_OPTION_POSIXLINE<<1)
+#define RE_OPTION_LONGEST (RE_OPTION_SINGLELINE<<1)
#define RE_MAY_IGNORECASE (RE_OPTION_LONGEST<<1)
#define RE_OPTIMIZE_ANCHOR (RE_MAY_IGNORECASE<<1)
diff --git a/version.h b/version.h
index 4fc16ca24b..18271e8d67 100644
--- a/version.h
+++ b/version.h
@@ -1,4 +1,4 @@
#define RUBY_VERSION "1.5.4"
-#define RUBY_RELEASE_DATE "2000-05-24"
+#define RUBY_RELEASE_DATE "2000-05-25"
#define RUBY_VERSION_CODE 154
-#define RUBY_RELEASE_CODE 20000524
+#define RUBY_RELEASE_CODE 20000525
diff --git a/win32/Makefile b/win32/Makefile
index af9349a070..620e2d731a 100644
--- a/win32/Makefile
+++ b/win32/Makefile
@@ -91,11 +91,9 @@ ext/extmk.rb: ext/extmk.rb.in rbconfig.rb
miniruby$(EXEEXT): $(OBJS) $(MAINOBJ) $(EXTOBJS)
@echo $(EXTOBJS)
@echo $(LIBS)
- @rm -f $@
$(PURIFY) $(CC) $(LDFLAGS) $(MAINOBJ) $(EXTOBJS) $(OBJS) $(LIBS) -o $@
$(PROGRAM): $(LIBRUBY) $(MAINOBJ) $(LIBRUBY_SO)
- @rm -f $@
$(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINOBJ) -o $@ $(LIBRUBYARG) -link /STACK:$(STACK)
$(LIBRUBY_A): $(OBJS) dmyext.obj
@@ -106,9 +104,7 @@ rubymw.lib: ruby.def
$(LIBRUBY_SO): $(LIBRUBY_A) $(EXTOBJS) ruby.def
set LIB=.\win32;$(ORGLIBPATH)
- @rm -f $@
$(CC) $(LDFLAGS) $(MAINOBJ) $(EXTOBJS) $(LIBRUBY_A) $(LIBS) -o $@ -link /DLL /DEF:ruby.def
- @mv rubymw.map rubydll.map
install: rbconfig.rb
.\miniruby.exe $(srcdir)/instruby.rb $(DESTDIR)
diff --git a/win32/ruby.def b/win32/ruby.def
index 3f4791b0a9..722480d353 100644
--- a/win32/ruby.def
+++ b/win32/ruby.def
@@ -287,6 +287,7 @@ EXPORTS
rb_exc_fatal
rb_interrupt
rb_jump_tag
+ rb_block_given_p
rb_iterator_p
rb_yield
rb_iterate