Permalink
Browse files

2000-05-25

git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@715 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information...
1 parent de8e3c8 commit bbd798caa2e148e0ebd10b6a6f9aeaf1301a54d0 matz committed May 25, 2000
Showing with 161 additions and 115 deletions.
  1. +34 −1 ChangeLog
  2. +1 −0 ToDo
  3. +3 −1 dir.c
  4. +78 −83 eval.c
  5. +2 −2 ext/pty/pty.c
  6. +10 −9 ext/socket/socket.c
  7. +1 −1 file.c
  8. +7 −9 io.c
  9. +19 −2 object.c
  10. +2 −0 parse.y
  11. +1 −1 regex.h
  12. +2 −2 version.h
  13. +0 −4 win32/Makefile
  14. +1 −0 win32/ruby.def
View
@@ -1,11 +1,44 @@
+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()
* lib/net/telnet.rb improve: binmode(), telnetmode() interface
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>
View
@@ -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
View
@@ -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;
View
@@ -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;
}
View
@@ -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
View
@@ -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) {
View
@@ -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;
View
@@ -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()) {
Oops, something went wrong. Retry.

0 comments on commit bbd798c

Please sign in to comment.