summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog49
-rw-r--r--ext/socket/socket.c17
-rw-r--r--hash.c44
-rw-r--r--process.c4
-rw-r--r--re.c4
5 files changed, 106 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 079f47fbd0..6ed4ec8306 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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) {
diff --git a/hash.c b/hash.c
index b51cbdddce..57357269c4 100644
--- a/hash.c
+++ b/hash.c
@@ -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);
diff --git a/process.c b/process.c
index cb77275ccc..67c4d3816b 100644
--- a/process.c
+++ b/process.c
@@ -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;
}
}
diff --git a/re.c b/re.c
index f676b203d7..26d1ee956d 100644
--- a/re.c
+++ b/re.c
@@ -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
*