summaryrefslogtreecommitdiff
path: root/pack.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-11-14 16:01:45 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-11-14 16:01:45 +0000
commitfa521485718447e8a936ae9bddb6df2e9aa60705 (patch)
treef5a47d2772beea7e30bd43117c33df7832c41f14 /pack.c
parentaee1d3d56ccc29cfbf03d9aed9b32fe810cc0b76 (diff)
* ext/gdbm/gdbm.c (fgdbm_store): StringValue() may alter string
pointer. [ruby-dev:24783] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7268 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'pack.c')
-rw-r--r--pack.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/pack.c b/pack.c
index 47262f5d9f..7bbb1743f3 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");
}