From f33a61c28dadf8ff2bb86d36d6428f487b671708 Mon Sep 17 00:00:00 2001 From: matz Date: Mon, 6 Aug 2001 03:05:23 +0000 Subject: * string.c (rb_str_lstrip_bang): new method. * string.c (rb_str_rstrip_bang): new method. * string.c (rb_str_associate): should consider STR_ASSOC too. * eval.c (rb_undefined): do not recurse if method_missing is undefined. * process.c (proc_waitpid): now all arguments are optional. * process.c (Init_process): waitpid is now alias to wait. * process.c (Init_process): waitpid2 is now alias to wait2. * process.c (rb_waitpid): made public. * ext/pty/pty.c (pty_getpty): avoid disturbing SIGCHLD using thread and rb_waitpid. * process.c (proc_getpgrp): now takes no argument on all platforms. * process.c (proc_setpgrp): ditto. * ext/socket/socket.c (sock_s_pack_sockaddr_in): added Socket::pack_sockaddr_in(). [new] * ext/socket/socket.c (sock_s_pack_sockaddr_un): added Socket::pack_sockaddr_un(). [new] * ext/socket/socket.c (sock_s_pack_sockaddr_in): added Socket::unpack_sockaddr_in(). [new] * ext/socket/socket.c (sock_s_pack_sockaddr_un): added Socket::unpack_sockaddr_un(). [new] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1666 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- pack.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'pack.c') diff --git a/pack.c b/pack.c index 44a683a37f..caf829e22f 100644 --- a/pack.c +++ b/pack.c @@ -331,7 +331,7 @@ pack_pack(ary, fmt) static char *nul10 = "\0\0\0\0\0\0\0\0\0\0"; static char *spc10 = " "; char *p, *pend; - VALUE res, from, associates = 0; + VALUE res, from; char type; int items, len, idx; char *ptr; @@ -872,10 +872,7 @@ pack_pack(ary, fmt) StringValue(from); t = RSTRING(from)->ptr; } - if (!associates) { - associates = rb_ary_new(); - } - rb_ary_push(associates, from); + rb_str_associate(res, from); rb_str_buf_cat(res, (char*)&t, sizeof(char*)); } break; @@ -930,10 +927,6 @@ pack_pack(ary, fmt) break; } } - - if (associates) { - rb_str_associate(res, associates); - } return res; } @@ -1677,13 +1670,12 @@ pack_unpack(str, fmt) s += sizeof(char *); if (t) { - VALUE a, tmp; - VALUE *p, *pend; + VALUE a, *p, *pend; - p = RARRAY(a)->ptr; if (!(a = rb_str_associated(str))) { rb_raise(rb_eArgError, "no associated pointer"); } + p = RARRAY(a)->ptr; pend = p + RARRAY(a)->len; while (p < pend) { if (TYPE(*p) == T_STRING && RSTRING(*p)->ptr == t) { -- cgit v1.2.3