diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-12-06 15:34:10 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-12-06 15:34:10 +0000 |
commit | d650fb0578a11109d3c4390c5c6435c4a2239991 (patch) | |
tree | b1819d0d7b6f69c916a88c027cb77cb2c10b561b | |
parent | 004127aa904cec52e80bbfc756c4a18b7f4970f0 (diff) | |
download | ruby-d650fb0578a11109d3c4390c5c6435c4a2239991.tar.gz |
* process.c (proc_setgroups): [ruby-dev:25081]
* re.c (rb_reg_eqq): document fix. [ruby-talk:122541]
* ext/socket/socket.c (sock_connect): use rb_str_new4().
[ruby-dev:25052]
* io.c (io_write): remove rb_str_locktmp(). [ruby-dev:25050]
* io.c (io_fwrite): takes VALUE string as an argument.
[ruby-dev:25050]
* ext/socket/socket.c (sock_connect): remove rb_str_locktmp().
[ruby-dev:25050]
* ext/socket/socket.c (udp_connect): [ruby-dev:25045]
* ext/socket/socket.c (udp_bind): ditto.
* ext/socket/socket.c (udp_send): ditto.
* ext/socket/socket.c (bsock_send): ditto.
* ext/socket/socket.c (s_recvfrom): ditto.
* hash.c (rb_hash_hash): should provide "hash" method where "eql?"
is redefined. [ruby-talk:122482]
* ext/socket/socket.c (bsock_setsockopt): [ruby-dev:25039]
* hash.c (rb_hash_hash): should provide "hash" method where "eql?"
is redefined. [ruby-talk:122482]
* ext/socket/socket.c (bsock_setsockopt): [ruby-dev:25039]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7483 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 49 | ||||
-rw-r--r-- | ext/socket/socket.c | 17 | ||||
-rw-r--r-- | hash.c | 44 | ||||
-rw-r--r-- | process.c | 4 | ||||
-rw-r--r-- | re.c | 4 |
5 files changed, 106 insertions, 12 deletions
@@ -1,3 +1,11 @@ +Tue Dec 7 00:27:37 2004 Yukihiro Matsumoto <matz@ruby-lang.org> + + * process.c (proc_setgroups): [ruby-dev:25081] + +Mon Dec 6 18:08:10 2004 Yukihiro Matsumoto <matz@ruby-lang.org> + + * re.c (rb_reg_eqq): document fix. [ruby-talk:122541] + Mon Dec 6 17:19:13 2004 Nobuyoshi Nakada <nobu@ruby-lang.org> * rubysig.h (TRAP_BEG, TRAP_END): safe errno around CHECK_INTS. @@ -8,6 +16,11 @@ Mon Dec 6 10:18:17 2004 Dave Thomas <dave@pragprog.com> * lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::look_for_directives_in): Oops - 1.8 doesn't have String#clear +Mon Dec 6 09:59:23 2004 Yukihiro Matsumoto <matz@ruby-lang.org> + + * ext/socket/socket.c (sock_connect): use rb_str_new4(). + [ruby-dev:25052] + Mon Dec 6 01:42:08 2004 GOTOU Yuuzou <gotoyuzo@notwork.org> * ext/openssl/ossl_pkey_rsa.c (ossl_rsa_public_encrypt, @@ -29,6 +42,38 @@ Sun Dec 5 19:39:17 2004 Nobuyoshi Nakada <nobu@ruby-lang.org> * lib/optparse.rb (OptionParser#order!): ignore case only for long option. [ruby-dev:25048] +Sat Dec 4 22:54:15 2004 Yukihiro Matsumoto <matz@ruby-lang.org> + + * io.c (io_write): remove rb_str_locktmp(). [ruby-dev:25050] + + * io.c (io_fwrite): takes VALUE string as an argument. + [ruby-dev:25050] + + * ext/socket/socket.c (sock_connect): remove rb_str_locktmp(). + [ruby-dev:25050] + + * ext/socket/socket.c (udp_connect): [ruby-dev:25045] + + * ext/socket/socket.c (udp_bind): ditto. + + * ext/socket/socket.c (udp_send): ditto. + + * ext/socket/socket.c (bsock_send): ditto. + + * ext/socket/socket.c (s_recvfrom): ditto. + + * hash.c (rb_hash_hash): should provide "hash" method where "eql?" + is redefined. [ruby-talk:122482] + +Sat Dec 4 00:35:08 2004 Yukihiro Matsumoto <matz@ruby-lang.org> + + * ext/socket/socket.c (bsock_setsockopt): [ruby-dev:25039] + +Sat Dec 4 22:54:15 2004 Yukihiro Matsumoto <matz@ruby-lang.org> + + * hash.c (rb_hash_hash): should provide "hash" method where "eql?" + is redefined. [ruby-talk:122482] + Sat Dec 4 14:54:52 2004 WATANABE Hirofumi <eban@ruby-lang.org> * eval.c (proc_invoke): use volatile `tmp' rather than `args'. @@ -63,6 +108,10 @@ Fri Dec 4 02:24:00 2004 NARUSE, Yui <naruse@ruby-lang.org> * ext/nkf/nkf-utf8/nkf.c: original nkf2 revision 1.47 +Sat Dec 4 00:35:08 2004 Yukihiro Matsumoto <matz@ruby-lang.org> + + * ext/socket/socket.c (bsock_setsockopt): [ruby-dev:25039] + Fri Dec 3 18:57:03 2004 Yukihiro Matsumoto <matz@ruby-lang.org> * lib/ostruct.rb: 1.9 marshaling support back-ported. diff --git a/ext/socket/socket.c b/ext/socket/socket.c index ebd8a32270..6a1d43ca31 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -275,7 +275,6 @@ bsock_setsockopt(sock, lev, optname, val) rb_secure(2); level = NUM2INT(lev); option = NUM2INT(optname); - GetOpenFile(sock, fptr); switch (TYPE(val)) { case T_FIXNUM: @@ -316,6 +315,7 @@ bsock_getsockopt(sock, lev, optname) option = NUM2INT(optname); len = 256; buf = ALLOCA_N(char,len); + GetOpenFile(sock, fptr); GetOpenFile(sock, fptr); if (getsockopt(fileno(fptr->f), level, option, buf, &len) < 0) @@ -370,14 +370,14 @@ bsock_send(argc, argv, sock) rb_secure(4); rb_scan_args(argc, argv, "21", &mesg, &flags, &to); + StringValue(mesg); + if (!NIL_P(to)) StringValue(to); GetOpenFile(sock, fptr); f = GetWriteFile(fptr); fd = fileno(f); rb_thread_fd_writable(fd); - StringValue(mesg); retry: if (!NIL_P(to)) { - StringValue(to); n = sendto(fd, RSTRING(mesg)->ptr, RSTRING(mesg)->len, NUM2INT(flags), (struct sockaddr*)RSTRING(to)->ptr, RSTRING(to)->len); } @@ -425,6 +425,7 @@ s_recvfrom(sock, argc, argv, from) if (flg == Qnil) flags = 0; else flags = NUM2INT(flg); + buflen = NUM2INT(len); GetOpenFile(sock, fptr); if (rb_read_pending(fptr->f)) { @@ -432,7 +433,6 @@ s_recvfrom(sock, argc, argv, from) } fd = fileno(fptr->f); - buflen = NUM2INT(len); str = rb_tainted_str_new(0, buflen); retry: @@ -1381,8 +1381,8 @@ udp_connect(sock, host, port) VALUE ret; rb_secure(3); - GetOpenFile(sock, fptr); arg.res = sock_addrinfo(host, port, SOCK_DGRAM, 0); + GetOpenFile(sock, fptr); arg.fd = fileno(fptr->f); ret = rb_ensure(udp_connect_internal, (VALUE)&arg, RUBY_METHOD_FUNC(freeaddrinfo), (VALUE)arg.res); @@ -1398,8 +1398,8 @@ udp_bind(sock, host, port) struct addrinfo *res0, *res; rb_secure(3); - GetOpenFile(sock, fptr); res0 = sock_addrinfo(host, port, SOCK_DGRAM, 0); + GetOpenFile(sock, fptr); for (res = res0; res; res = res->ai_next) { if (bind(fileno(fptr->f), res->ai_addr, res->ai_addrlen) < 0) { continue; @@ -1430,10 +1430,10 @@ udp_send(argc, argv, sock) rb_secure(4); rb_scan_args(argc, argv, "4", &mesg, &flags, &host, &port); - GetOpenFile(sock, fptr); + StringValue(mesg); res0 = sock_addrinfo(host, port, SOCK_DGRAM, 0); + GetOpenFile(sock, fptr); f = GetWriteFile(fptr); - StringValue(mesg); for (res = res0; res; res = res->ai_next) { retry: n = sendto(fileno(f), RSTRING(mesg)->ptr, RSTRING(mesg)->len, NUM2INT(flags), @@ -1903,6 +1903,7 @@ sock_connect(sock, addr) int fd; StringValue(addr); + addr = rb_str_new4(addr); GetOpenFile(sock, fptr); fd = fileno(fptr->f); if (ruby_connect(fd, (struct sockaddr*)RSTRING(addr)->ptr, RSTRING(addr)->len, 0) < 0) { @@ -1519,6 +1519,49 @@ rb_hash_eql(hash1, hash2) return hash_equal(hash1, hash2, Qtrue); } + +rb_hash_hash_i(key, value, hp) + VALUE key, value; + long *hp; +{ + long h = *hp; + VALUE n; + + h = (h << 1) | (h<0 ? 1 : 0); + n = rb_hash(key); + h ^= NUM2LONG(n); + h = (h << 1) | (h<0 ? 1 : 0); + n = rb_hash(value); + h ^= NUM2LONG(n); + + *hp = h; + return ST_CONTINUE; +} + +/* + * call-seq: + * hash.hash -> fixnum + * + * Compute a hash-code for this hash. Two hashes with the same content + * will have the same hash code (and will compare using <code>eql?</code>). + */ + +static VALUE +rb_hash_hash(hash) + VALUE hash; +{ + long h; + VALUE n; + + h = RHASH(hash)->tbl->num_entries; + rb_hash_foreach(hash, rb_hash_hash_i, (VALUE)&h); + h = (h << 1) | (h<0 ? 1 : 0); + n = rb_hash(RHASH(hash)->ifnone); + h ^= NUM2LONG(n); + + return LONG2FIX(h); +} + static int rb_hash_invert_i(key, value, hash) VALUE key, value; @@ -2454,6 +2497,7 @@ Init_Hash() rb_define_method(rb_cHash,"==", rb_hash_equal, 1); rb_define_method(rb_cHash,"eql?", rb_hash_eql, 1); + rb_define_method(rb_cHash,"hash", rb_hash_hash, 0); rb_define_method(rb_cHash,"[]", rb_hash_aref, 1); rb_define_method(rb_cHash,"fetch", rb_hash_fetch, -1); rb_define_method(rb_cHash,"[]=", rb_hash_aset, 2); @@ -2477,10 +2477,10 @@ proc_setgroups(VALUE obj, VALUE ary) groups[i] = NUM2INT(g); } else { - gr = getgrnam(RSTRING(g)->ptr); + gr = getgrnam(RSTRING(tmp)->ptr); if (gr == NULL) rb_raise(rb_eArgError, - "can't find group for %s", RSTRING(g)->ptr); + "can't find group for %s", RSTRING(tmp)->ptr); groups[i] = gr->gr_gid; } } @@ -1523,8 +1523,8 @@ rb_reg_match(re, str) * * a = "HELLO" * case a - * when /^a-z*$/; print "Lower case\n" - * when /^A-Z*$/; print "Upper case\n" + * when /^[a-z]*$/; print "Lower case\n" + * when /^[A-Z]*$/; print "Upper case\n" * else; print "Mixed case\n" * end * |