diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-12-23 19:53:45 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-12-23 19:53:45 +0000 |
commit | 0a4fc3d71ba383af2eb2da62509d3c5537eebb68 (patch) | |
tree | b9353d3b26f0ff6144fc628574d90bec093b90d4 /pack.c | |
parent | a3ecd5c83d57fb1556a40113f1b0c69c87261e33 (diff) |
* io.c (read_all): do not return nil at the end of file.
[ruby-dev:22334]
* io.c (argf_read): do not depend on nil at eof behavior of
IO#read().
* eval.c (rb_thread_join): dup exception before re-raising it.
* io.c (rb_io_eof): call clearerr() to prevent side effect. this
patch is supplied by Masahiro Sakai <sakai@tom.sfc.keio.ac.jp>.
[ruby-dev:22234]
* pack.c (OFF16): get offset for big endian machines.
* pack.c (pack_pack): use OFF16 instead of OFF16B.
[ruby-dev:22344]
* pack.c (pack_unpack): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5266 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'pack.c')
-rw-r--r-- | pack.c | 19 |
1 files changed, 6 insertions, 13 deletions
@@ -22,14 +22,12 @@ #endif #ifdef NATINT_PACK -# define OFF16B(p) ((char*)(p) + (natint?0:(sizeof(short) - SIZE16))) -# define OFF32B(p) ((char*)(p) + (natint?0:(sizeof(long) - SIZE32))) # define NATINT_I32(x) (natint?NUM2LONG(x):(NUM2I32(x))) # define NATINT_U32(x) (natint?NUM2ULONG(x):(NUM2U32(x))) # define NATINT_LEN(type,len) (natint?sizeof(type):(len)) # ifdef WORDS_BIGENDIAN -# define OFF16(p) OFF16B(p) -# define OFF32(p) OFF32B(p) +# define OFF16(p) ((char*)(p) + (natint?0:(sizeof(short) - SIZE16))) +# define OFF32(p) ((char*)(p) + (natint?0:(sizeof(long) - SIZE32))) # endif # define NATINT_HTOVS(x) (natint?htovs(x):htov16(x)) # define NATINT_HTOVL(x) (natint?htovl(x):htov32(x)) @@ -50,11 +48,6 @@ # define OFF32(p) (char*)(p) #endif -#ifndef OFF16B -# define OFF16B(p) (char*)(p) -# define OFF32B(p) (char*)(p) -#endif - #define define_swapx(x, xtype) \ static xtype \ TOKEN_PASTE(swap,x)(z) \ @@ -775,7 +768,7 @@ pack_pack(ary, fmt) s = NUM2INT(from); } s = NATINT_HTONS(s); - rb_str_buf_cat(res, OFF16B(&s), NATINT_LEN(short,2)); + rb_str_buf_cat(res, OFF16(&s), NATINT_LEN(short,2)); } break; @@ -789,7 +782,7 @@ pack_pack(ary, fmt) l = NATINT_U32(from); } l = NATINT_HTONL(l); - rb_str_buf_cat(res, OFF32B(&l), NATINT_LEN(long,4)); + rb_str_buf_cat(res, OFF32(&l), NATINT_LEN(long,4)); } break; @@ -1654,7 +1647,7 @@ pack_unpack(str, fmt) PACK_LENGTH_ADJUST(unsigned short,2); while (len-- > 0) { unsigned short tmp = 0; - memcpy(OFF16B(&tmp), s, NATINT_LEN(unsigned short,2)); + memcpy(OFF16(&tmp), s, NATINT_LEN(unsigned short,2)); s += NATINT_LEN(unsigned short,2); rb_ary_push(ary, UINT2NUM(ntohs(tmp))); } @@ -1665,7 +1658,7 @@ pack_unpack(str, fmt) PACK_LENGTH_ADJUST(unsigned long,4); while (len-- > 0) { unsigned long tmp = 0; - memcpy(OFF32B(&tmp), s, NATINT_LEN(unsigned long,4)); + memcpy(OFF32(&tmp), s, NATINT_LEN(unsigned long,4)); s += NATINT_LEN(unsigned long,4); rb_ary_push(ary, ULONG2NUM(ntohl(tmp))); } |