From a62935cf06b9ee2ec72c749c732c226a18f4d389 Mon Sep 17 00:00:00 2001 From: matz Date: Thu, 18 May 2000 04:32:13 +0000 Subject: [PATCH] 2000-05-18 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@699 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 9 +++ ToDo | 11 ++++ eval.c | 48 +++++++++++---- ext/Setup | 2 +- ext/readline/extconf.rb | 7 ++- ext/socket/extconf.rb | 18 ++++++ ext/socket/socket.c | 128 ++++++++++++++++++++++++++++++++++++++-- intern.h | 14 ++--- parse.y | 2 + re.c | 2 - regex.c | 92 +++++++---------------------- regex.h | 6 +- version.h | 4 +- win32/ruby.def | 25 ++++++-- 14 files changed, 260 insertions(+), 108 deletions(-) diff --git a/ChangeLog b/ChangeLog index d3a867b35e..3cc375fa17 100644 --- a/ChangeLog +++ b/ChangeLog @@ -25,6 +25,15 @@ Wed May 17 00:40:15 2000 Katsuyuki Komatsu * win32/ruby.def: add symbol "rb_big_divmod". +May 16 19:45:32 2000 Katsuyuki Komatsu + + * intern.h: use EXTERN instead of extern. + + * win32/ruby.h: add rb_defout, rb_stdout, ruby_errinfo, + ruby_sourceline, ruby_sourcefile to work with eruby + reported by Hiroshi Saito . + Export both ruby_xmalloc and xmalloc etc. + Tue May 16 17:00:05 2000 Masaki Fukushima * eval.c (rb_thread_select): should check whether fds are null. diff --git a/ToDo b/ToDo index 84d0ea128a..fccb09d85e 100644 --- a/ToDo +++ b/ToDo @@ -87,6 +87,7 @@ Extension Libraries Ruby Libraries - net/http.rb +* add uri.rb * urllib.rb, nttplib.rb, etc. * format like perl's @@ -99,3 +100,13 @@ Misc - publish Ruby books * publish Ruby books in English + +Things To Do Before 1.6 + +* fix spec. for the following: + + * alternative for $! (exception? in? into? =>?) + * alternative for interator? + * regex - /p, /m + * odd? even? + * mkmf.rb - create_makefile("net/socket") diff --git a/eval.c b/eval.c index f4a5b72bd3..b753509a69 100644 --- a/eval.c +++ b/eval.c @@ -67,6 +67,8 @@ struct timeval { #include #endif +#include + VALUE rb_cProc; static VALUE rb_cBinding; static VALUE proc_call _((VALUE,VALUE)); @@ -6284,6 +6286,7 @@ struct thread { fd_set readfds; fd_set writefds; fd_set exceptfds; + int select_value; double delay; thread_t join; @@ -6681,6 +6684,23 @@ intersect_fds(dst, src, max) return Qfalse; } +static int +find_bad_fds(dst, src, max) + fd_set *dst, *src; + int max; +{ + struct stat s; + int i, test = Qfalse; + + for (i=0; i<=max; i++) { + if (FD_ISSET(i, src) && !FD_ISSET(i, dst)) { + FD_CLR(i, src); + test = Qtrue; + } + } + return test; +} + void rb_thread_schedule() { @@ -6738,7 +6758,7 @@ rb_thread_schedule() copy_fds(&exceptfds, &th->exceptfds, th->fd); if (max < th->fd) max = th->fd; need_select = 1; - th->fd = 0; + th->select_value = 0; } if (th->wait_for & WAIT_TIME) { if (th->delay <= now) { @@ -6777,15 +6797,21 @@ rb_thread_schedule() n = select(max+1, &readfds, &writefds, &exceptfds, delay_ptr); if (n < 0) { if (rb_trap_pending) rb_trap_exec(); - switch (errno) { - case EBADF: - /* xxx */ - case ENOMEM: - n = 0; - break; - default: - goto select_err; + 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; + } + } } + END_FOREACH(th); } if (n > 0) { /* Some descriptors are ready. @@ -6809,7 +6835,7 @@ rb_thread_schedule() intersect_fds(&readfds, &th->readfds, max); intersect_fds(&writefds, &th->writefds, max); intersect_fds(&exceptfds, &th->exceptfds, max); - th->fd = n; + th->select_value = n; found = 1; } } @@ -7018,7 +7044,7 @@ rb_thread_select(max, read, write, except, timeout) if (read) *read = curr_thread->readfds; if (write) *write = curr_thread->writefds; if (except) *except = curr_thread->exceptfds; - return curr_thread->fd; + return curr_thread->select_value; } static VALUE diff --git a/ext/Setup b/ext/Setup index 039747115f..e2f2412586 100644 --- a/ext/Setup +++ b/ext/Setup @@ -9,7 +9,7 @@ #md5 #pty #sdbm -#socket +socket #tk #tcltklib #gtk diff --git a/ext/readline/extconf.rb b/ext/readline/extconf.rb index 63ece61464..7db62745f3 100644 --- a/ext/readline/extconf.rb +++ b/ext/readline/extconf.rb @@ -2,9 +2,10 @@ require "mkmf" dir_config("readline") have_library("user32", nil) if /cygwin/ === RUBY_PLATFORM -have_library("termcap", "tgetnum") or - have_library("curses", "tgetnum") or - have_library("ncurses", "tgetnum") +have_library("ncurses", "tgetnum") or + have_library("termcap", "tgetnum") or + have_library("curses", "tgetnum") + if have_header("readline/readline.h") and have_header("readline/history.h") and have_library("readline", "readline") diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb index 46d5120e2e..9ac24cd763 100644 --- a/ext/socket/extconf.rb +++ b/ext/socket/extconf.rb @@ -99,6 +99,10 @@ EOF $ipv6lib="inet6" $ipv6libdir="/usr/local/v6/lib" $CFLAGS="-DINET6 "+$CFLAGS + else + $ipv6lib=with_config("ipv6-lib", nil) + $ipv6libdir=with_config("ipv6-libdir", nil) + $CFLAGS="-DINET6 "+$CFLAGS end if $ipv6lib @@ -273,6 +277,20 @@ EOS exit end +case with_config("ipv6-lookup-order", "INET") +when "INET" + $CFLAGS="-DDEFAULT_LOOKUP_ORDER_INET "+$CFLAGS +when "INET6" + $CFLAGS="-DDEFAULT_LOOKUP_ORDER_INET6 "+$CFLAGS +when "UNSPEC" + $CFLAGS="-DDEFAULT_LOOKUP_ORDER_UNSPEC "+$CFLAGS +else + print <options & RE_OPTION_POSIXLINE) { - BUFPUSH(endbuf); - } - else { - p0 = p; - /* When testing what follows the $, - look past the \-constructs that don't consume anything. */ + p0 = p; + /* When testing what follows the $, + look past the \-constructs that don't consume anything. */ - while (p0 != pend) { - if (*p0 == '\\' && p0 + 1 != pend - && (p0[1] == 'b' || p0[1] == 'B')) - p0 += 2; - else - break; - } - BUFPUSH(endline); + while (p0 != pend) { + if (*p0 == '\\' && p0 + 1 != pend + && (p0[1] == 'b' || p0[1] == 'B')) + p0 += 2; + else + break; } + BUFPUSH(endline); break; case '^': - if (bufp->options & RE_OPTION_POSIXLINE) - BUFPUSH(begbuf); - else - BUFPUSH(begline); + BUFPUSH(begline); break; case '+': @@ -1689,18 +1669,11 @@ re_compile_pattern(pattern, size, bufp) else options |= RE_OPTION_EXTENDED; break; + case 'p': - if (negative) { - if (options&RE_OPTION_POSIXLINE) { - options &= ~RE_OPTION_POSIXLINE; - BUFPUSH(posix_off); - } - } - else if (!(options&RE_OPTION_POSIXLINE)) { - options |= RE_OPTION_POSIXLINE; - BUFPUSH(posix_on); - } + FREE_AND_RETURN(stackb, "(?p) is deprecated"); break; + case 'm': if (negative) { if (options&RE_OPTION_MULTILINE) { @@ -1823,11 +1796,8 @@ re_compile_pattern(pattern, size, bufp) if ((options ^ stackp[-1]) & RE_OPTION_IGNORECASE) { BUFPUSH((options&RE_OPTION_IGNORECASE)?casefold_off:casefold_on); } - if ((options ^ stackp[-1]) & RE_OPTION_POSIXLINE) { - BUFPUSH((options&RE_OPTION_POSIXLINE)?posix_off:posix_on); - } if ((options ^ stackp[-1]) & RE_OPTION_MULTILINE) { - BUFPUSH((options&RE_OPTION_POSIXLINE)?mline_off:mline_on); + BUFPUSH((options&RE_OPTION_MULTILINE)?mline_off:mline_on); } pending_exact = 0; if (fixup_alt_jump) { @@ -2193,11 +2163,9 @@ re_compile_pattern(pattern, size, bufp) break; case 'Z': - if ((bufp->options & RE_OPTION_POSIXLINE) == 0) { - BUFPUSH(endbuf2); - break; - } - /* fall through */ + BUFPUSH(endbuf2); + break; + case 'z': BUFPUSH(endbuf); break; @@ -2787,11 +2755,6 @@ re_compile_fastmap(bufp) options ^= RE_OPTION_IGNORECASE; continue; - case posix_on: - case posix_off: - options ^= RE_OPTION_POSIXLINE; - continue; - case mline_on: case mline_off: options ^= RE_OPTION_MULTILINE; @@ -2802,7 +2765,7 @@ re_compile_fastmap(bufp) fastmap[translate['\n']] = 1; else fastmap['\n'] = 1; - if ((options & RE_OPTION_POSIXLINE) == 0 && bufp->can_be_null == 0) + if (bufp->can_be_null == 0) bufp->can_be_null = 2; break; @@ -2887,7 +2850,7 @@ re_compile_fastmap(bufp) case anychar_repeat: case anychar: for (j = 0; j < (1 << BYTEWIDTH); j++) { - if (j != '\n' || (options & RE_OPTION_POSIXLINE)) + if (j != '\n') fastmap[j] = 1; } if (bufp->can_be_null) { @@ -3165,9 +3128,6 @@ re_search(bufp, string, size, startpos, range, regs) } } if (bufp->options & RE_OPTIMIZE_ANCHOR) { - if (bufp->options&RE_OPTION_POSIXLINE) { - goto begbuf_match; - } anchor = 1; } @@ -3781,7 +3741,7 @@ re_match(bufp, string_arg, size, pos, regs) d += mbclen(*d); break; } - if (!(options&RE_OPTION_POSIXLINE) && + if (!(options&RE_OPTION_MULTILINE) && (TRANSLATE_P() ? translate[*d] : *d) == '\n') goto fail; SET_REGS_MATCHED; @@ -3799,7 +3759,7 @@ re_match(bufp, string_arg, size, pos, regs) d += mbclen(*d); continue; } - if (!(options&RE_OPTION_POSIXLINE) && + if (!(options&RE_OPTION_MULTILINE) && (TRANSLATE_P() ? translate[*d] : *d) == '\n') goto fail; SET_REGS_MATCHED; @@ -4129,14 +4089,6 @@ re_match(bufp, string_arg, size, pos, regs) options &= ~RE_OPTION_IGNORECASE; continue; - case posix_on: - options |= RE_OPTION_POSIXLINE; - continue; - - case posix_off: - options &= ~RE_OPTION_POSIXLINE; - continue; - case mline_on: options |= RE_OPTION_MULTILINE; continue; diff --git a/regex.h b/regex.h index 48696e0ee4..a1e3093a04 100644 --- a/regex.h +++ b/regex.h @@ -69,12 +69,10 @@ #define RE_OPTION_IGNORECASE (1L) /* perl-style extended pattern available */ #define RE_OPTION_EXTENDED (RE_OPTION_IGNORECASE<<1) -/* newline will be included for ., ^, $ does not handle newline - obsolete */ -#define RE_OPTION_POSIXLINE (RE_OPTION_EXTENDED<<1) /* newline will be included for . */ -#define RE_OPTION_MULTILINE (RE_OPTION_POSIXLINE<<1) +#define RE_OPTION_MULTILINE (RE_OPTION_EXTENDED<<1) /* search for longest match, in accord with POSIX regexp */ -#define RE_OPTION_LONGEST (RE_OPTION_POSIXLINE<<1) +#define RE_OPTION_LONGEST (RE_OPTION_MULTILINE<<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 9171d5212d..cdc2425d98 100644 --- a/version.h +++ b/version.h @@ -1,4 +1,4 @@ #define RUBY_VERSION "1.5.4" -#define RUBY_RELEASE_DATE "2000-05-17" +#define RUBY_RELEASE_DATE "2000-05-18" #define RUBY_VERSION_CODE 154 -#define RUBY_RELEASE_CODE 20000517 +#define RUBY_RELEASE_CODE 20000518 diff --git a/win32/ruby.def b/win32/ruby.def index 0d8fab5970..3f4791b0a9 100644 --- a/win32/ruby.def +++ b/win32/ruby.def @@ -36,6 +36,7 @@ EXPORTS ;eval.c rb_cProc ruby_safe_level + ruby_errinfo ruby_frame rb_cThread rb_thread_tick @@ -51,6 +52,14 @@ EXPORTS rb_cIO rb_eEOFError rb_eIOError + rb_stdin + rb_stdout + rb_stderr + rb_defout + rb_output_fs + rb_rs + rb_output_rs + rb_default_rs ;math.c rb_mMath ;numeric.c @@ -69,6 +78,9 @@ EXPORTS rb_cTrueClass rb_cFalseClass rb_cSymbol +;parse.c + ruby_sourcefile + ruby_sourceline ;prec.c rb_mPrecision ;process.c @@ -314,6 +326,7 @@ EXPORTS rb_thread_wakeup rb_thread_run rb_thread_stop + rb_thread_polling rb_thread_sleep rb_thread_sleep_forever rb_thread_create @@ -332,10 +345,10 @@ EXPORTS rb_find_file rb_path_check ;gc.c - xmalloc - xfree - xcalloc - xrealloc + ruby_xmalloc + ruby_xcalloc + ruby_xrealloc + ruby_xfree rb_global_variable rb_newobj rb_data_object_alloc @@ -348,6 +361,10 @@ EXPORTS rb_gc_mark_frame rb_gc rb_gc_call_finalizer_at_exit + xmalloc + xcalloc + xrealloc + xfree ;hash.c rb_hash_freeze rb_hash