From 15d27690475aaa461a8302bdf3fc5901e7b5710d Mon Sep 17 00:00:00 2001 From: matz Date: Sun, 14 Nov 2004 16:01:45 +0000 Subject: * ext/gdbm/gdbm.c (fgdbm_store): StringValue() may alter string pointer. [ruby-dev:24783] git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@7268 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- pack.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'pack.c') diff --git a/pack.c b/pack.c index 47262f5d9..7bbb1743f 100644 --- a/pack.c +++ b/pack.c @@ -253,11 +253,11 @@ endian() #undef ntohl #undef htons #undef htonl +#endif #define ntohs(x) swaps(x) #define ntohl(x) swapl(x) #define htons(x) swaps(x) #define htonl(x) swapl(x) -#endif #define ntohf(x) swapf(x) #define ntohd(x) swapd(x) #define htonf(x) swapf(x) @@ -732,7 +732,6 @@ pack_pack(ary, fmt) break; case 'l': /* signed long */ - case 'L': /* unsigned long */ while (len-- > 0) { long l; @@ -741,6 +740,15 @@ pack_pack(ary, fmt) rb_str_buf_cat(res, OFF32(&l), NATINT_LEN(long,4)); } break; + case 'L': /* unsigned long */ + while (len-- > 0) { + long l; + + from = NEXTFROM; + l = NUM2U32(from); + rb_str_buf_cat(res, OFF32(&l), NATINT_LEN(long,4)); + } + break; case 'q': /* signed quad (64bit) int */ case 'Q': /* unsigned quad (64bit) int */ @@ -769,7 +777,7 @@ pack_pack(ary, fmt) unsigned long l; from = NEXTFROM; - l = NUM2I32(from); + l = NUM2U32(from); l = NATINT_HTONL(l); rb_str_buf_cat(res, OFF32(&l), NATINT_LEN(long,4)); } @@ -791,7 +799,7 @@ pack_pack(ary, fmt) unsigned long l; from = NEXTFROM; - l = NUM2I32(from); + l = NUM2U32(from); l = NATINT_HTOVL(l); rb_str_buf_cat(res, OFF32(&l), NATINT_LEN(long,4)); } @@ -904,7 +912,7 @@ pack_pack(ary, fmt) from = NEXTFROM; from = rb_to_int(from); - l = NUM2INT(from); + l = NUM2UINT(from); if (l < 0) { rb_raise(rb_eRangeError, "pack(U): value out of range"); } -- cgit