From 8aad024e3ac6524f8bc09d839a331f926eab30ec Mon Sep 17 00:00:00 2001 From: matz Date: Wed, 22 Sep 1999 04:30:11 +0000 Subject: 19990922 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 37 +++++++++++++++++++++++++++++++++---- eval.c | 8 ++++++-- ext/socket/extconf.rb | 4 +++- ext/socket/socket.c | 9 ++++++++- io.c | 7 ++++--- lib/telnet.rb | 42 ++++++++++++++++++++++++++++-------------- regex.c | 4 ++-- string.c | 4 ++-- win32/Makefile | 6 +++--- win32/ruby.def | 5 ++++- win32/win32.c | 18 ++++++++++++++++-- 11 files changed, 109 insertions(+), 35 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3e2deca7b6..068b093929 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,38 @@ +Wed Sep 22 09:20:11 1999 Masahiro Tomita + + * ext/socket/socket.c: SOCKS5 support. + +Wed Sep 22 00:35:30 1999 Yukihiro Matsumoto + + * string.c (rb_str_include): should return boolean value. + + * regex.c (re_compile_fastmap): wrong comparison with mbc. + + * eval.c (specific_eval): default sourcefile name should be + "(eval)" for module_eval etc. + +Wed Sep 22 00:06:07 1999 Katsuyuki Komatsu + + * win32/Makefile: update rules. + + * io.c (io_fread): should not assign in char, it maybe -1. + +Tue Sep 21 23:57:54 1999 Yukihiro Matsumoto + + * eval.c (call_trace_func): should not propagate retval in + trace_func. + +Mon Sep 20 21:35:39 1999 Katsuyuki Komatsu + + * win32/win32.c (myselect): assume non socket files are always + readable/writable. + Mon Sep 20 01:08:02 1999 Yukihiro Matsumoto * io.c (io_fread): should not block other threads. * io.c (rb_io_synchronized): renamed from rb_io_unbuffered(); do - not call setbuf(NULL) any more. + not call setbuf(NULL) anymore. Sat Sep 18 13:45:43 1999 Yukihiro Matsumoto @@ -3772,7 +3801,7 @@ Sat Mar 28 20:40:12 1998 Yukihiro Matsumoto Sat Mar 28 16:07:11 1998 WATANABE Hirofumi - * io.c (io_closed): should not cause exception fot closed IO. + * io.c (io_closed): should not cause exception for closed IO. * string.c (str_tr): returned nil for success. @@ -4526,7 +4555,7 @@ Fri Dec 12 00:50:25 1997 Yukihiro Matsumoto * eval.c (rb_eval): new visibility status `function'. * parse.y (yycompile): do not clear eval_tree. thus enable multipe - command line script by optn `-e'. + command line script by option `-e'. * eval.c (rb_eval): END execute just once. @@ -5011,7 +5040,7 @@ Mon Sep 1 11:43:57 1997 WATANABE Hirofumi Fri Aug 29 11:10:21 1997 Yukihiro Matsumoto * class.c (class_instance_methods): same method names should not - appear more than twice. + appear more than once. * parse.y (yylex): spaces can follow =begin/=end. diff --git a/eval.c b/eval.c index 8d69936d03..d22cf137ee 100644 --- a/eval.c +++ b/eval.c @@ -648,6 +648,10 @@ static struct tag *prot_tag; prot_tag = _tag.prev; \ } +#define POP_TMPTAG() \ + prot_tag = _tag.prev; \ +} + #define TAG_RETURN 0x1 #define TAG_BREAK 0x2 #define TAG_NEXT 0x3 @@ -1724,7 +1728,7 @@ call_trace_func(event, file, line, self, id, klass) self?rb_f_binding(self):Qnil, klass)); } - POP_TAG(); + POP_TMPTAG(); /* do not propagate retval */ POP_FRAME(); rb_thread_critical--; @@ -4488,7 +4492,7 @@ specific_eval(argc, argv, klass, self) VALUE *argv; VALUE klass, self; { - char *file = 0; + char *file = "(eval)"; int line = 1; int iter = rb_iterator_p(); diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb index 191abf09a6..f2eddc0bba 100644 --- a/ext/socket/extconf.rb +++ b/ext/socket/extconf.rb @@ -271,7 +271,9 @@ if have_func(test_func) have_func("uname") end if ENV["SOCKS_SERVER"] or enable_config("socks", false) - if have_library("socks", "Rconnect") + if have_library("socks5", "SOCKSinit") + $CFLAGS="-DSOCKS5 -DSOCKS" + elsif have_library("socks", "Rconnect") $CFLAGS="-DSOCKS" end end diff --git a/ext/socket/socket.c b/ext/socket/socket.c index 4c0934a87b..3ff6af441e 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -63,9 +63,13 @@ static VALUE rb_eSocket; #ifdef SOCKS VALUE rb_cSOCKSSocket; +#ifdef SOCKS5 +#include +#else void SOCKSinit(); int Rconnect(); #endif +#endif #define INET_CLIENT 0 #define INET_SERVER 1 @@ -630,12 +634,15 @@ ruby_connect(fd, sockaddr, len, socks) #else # define NONBLOCKING O_NONBLOCK #endif +#endif +#ifdef SOCKS5 + if (!socks) #endif fcntl(fd, F_SETFL, mode|NONBLOCKING); #endif /* HAVE_FCNTL */ for (;;) { -#ifdef SOCKS +#if defined(SOCKS) && !defined(SOCKS5) if (socks) { status = Rconnect(fd, sockaddr, len); } diff --git a/io.c b/io.c index 3aa95e2cae..c1c7d511db 100644 --- a/io.c +++ b/io.c @@ -449,14 +449,15 @@ io_fread(ptr, len, f) FILE *f; { size_t n = len; + int c; while (n--) { - *ptr = getc(f); - if (*ptr == EOF) { + c = getc(f); + if (c == EOF) { *ptr = '\0'; break; } - ptr++; + *ptr++ = c; if (!READ_DATA_PENDING(f)) { rb_thread_wait_fd(fileno(f)); } diff --git a/lib/telnet.rb b/lib/telnet.rb index 3b0fc9ddaa..b161ae8c6c 100644 --- a/lib/telnet.rb +++ b/lib/telnet.rb @@ -1,11 +1,11 @@ =begin -$Date: 1999/09/17 17:41:41 $ +$Date: 1999/09/21 21:24:07 $ == SIMPLE TELNET CLIANT LIBRARY telnet.rb -Version 0.40 +Version 0.50 Wakou Aoyama @@ -86,6 +86,7 @@ of cource, set sync=true or flush is necessary. === SEND STRING host.print("string") + # == host.write("string\n") === TURN TELNET COMMAND INTERPRETATION @@ -154,6 +155,12 @@ of cource, set sync=true or flush is necessary. == HISTORY +=== Version 0.50 + +1999/09/21 21:24:07 + +- add write method + === Version 0.40 1999/09/17 17:41:41 @@ -398,8 +405,8 @@ class Telnet < SimpleDelegator EOL = CR + LF v = $-v $-v = false - VERSION = "0.40" - RELEASE_DATE = "$Date: 1999/09/17 17:41:41 $" + VERSION = "0.50" + RELEASE_DATE = "$Date: 1999/09/21 21:24:07 $" $-v = v def initialize(options) @@ -503,33 +510,33 @@ $-v = v if IAC == $1 # handle escaped IAC characters IAC elsif AYT == $1 # respond to "IAC AYT" (are you there) - @sock.write("nobody here but us pigeons" + EOL) + self.write("nobody here but us pigeons" + EOL) '' elsif DO[0] == $1[0] # respond to "IAC DO x" if OPT_BINARY[0] == $1[1] @telnet_option["BINARY"] = true - @sock.write(IAC + WILL + OPT_BINARY) + self.write(IAC + WILL + OPT_BINARY) else - @sock.write(IAC + WONT + $1[1..1]) + self.write(IAC + WONT + $1[1..1]) end '' elsif DONT[0] == $1[0] # respond to "IAC DON'T x" with "IAC WON'T x" - @sock.write(IAC + WONT + $1[1..1]) + self.write(IAC + WONT + $1[1..1]) '' elsif WILL[0] == $1[0] # respond to "IAC WILL x" if OPT_ECHO[0] == $1[1] - @sock.write(IAC + DO + OPT_ECHO) + self.write(IAC + DO + OPT_ECHO) elsif OPT_SGA[0] == $1[1] @telnet_option["SGA"] = true - @sock.write(IAC + DO + OPT_SGA) + self.write(IAC + DO + OPT_SGA) end '' elsif WONT[0] == $1[0] # respond to "IAC WON'T x" if OPT_ECHO[0] == $1[1] - @sock.write(IAC + DONT + OPT_ECHO) + self.write(IAC + DONT + OPT_ECHO) elsif OPT_SGA[0] == $1[1] @telnet_option["SGA"] = false - @sock.write(IAC + DONT + OPT_SGA) + self.write(IAC + DONT + OPT_SGA) end '' end @@ -591,6 +598,14 @@ $-v = v line end + def write(string) + length = string.length + while 0 < length + IO::select(nil, [@sock]) + length -= @sock.syswrite(string) + end + end + def print(string) str = string.dup + "\n" @@ -609,7 +624,7 @@ $-v = v end end - @sock.write(str) + self.write(str) end def cmd(options) @@ -624,7 +639,6 @@ $-v = v string = options end - IO::select(nil, [@sock]) self.print(string) if iterator? waitfor({"Prompt" => match, "Timeout" => time_out}){|c| yield c } diff --git a/regex.c b/regex.c index ffc7acc5d1..d6687b97eb 100644 --- a/regex.c +++ b/regex.c @@ -1112,7 +1112,7 @@ re_compile_pattern(pattern, size, bufp) register const char *p = pattern; const char *nextp; const char *pend = pattern + size; - register unsigned c, c1; + register unsigned int c, c1; const char *p0; int numlen; @@ -2832,7 +2832,7 @@ re_compile_fastmap(bufp) while (beg <= end) { /* NOTE: Charset for multi-byte chars might contain single-byte chars. We must reject them. */ - if (beg < 0x100) + if (c < 0x100) fastmap[beg] = 2; else if (ismbchar(beg)) fastmap[beg] = 1; diff --git a/string.c b/string.c index 7bb9d09966..f7366cf99a 100644 --- a/string.c +++ b/string.c @@ -1275,7 +1275,7 @@ rb_str_include(str, arg) for (i=0; ifd_count; + if (wr) r += wr->fd_count; + if (ex && ex->fd_count > 0) { + // exceptional condition never happen for normal files + if (r > 0) + ex->fd_count = 0; + else { + errno = EBADF; + r = SOCKET_ERROR; + } + } break; } } -- cgit v1.2.3