summaryrefslogtreecommitdiff
path: root/pack.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-02-13 09:01:11 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-02-13 09:01:11 +0000
commitba8fc117c58e66672b4638450e76911e42a80f7b (patch)
treee744db6e8f1628411bd65782f6fd1c516aea47b7 /pack.c
parent1995213e4bb0b6411a4a4da60c53e37bec3ba4ec (diff)
* parse.y (stmt): local variable declaration order was changed
since 1.6 * parse.y (arg): ditto. * pack.c (pack_pack): add templates 'q' and 'Q'. * pack.c (pack_unpack): ditto. * bignum.c (rb_quad_pack): new utility function. * bignum.c (rb_quad_unpack): ditto. * parse.y (assignable): should emit CVASGN within the method body. * dir.c (dir_s_glob): should not warn even if no match found. * eval.c (rb_eval): clean up class variable behavior. * eval.c (assign): ditto. * eval.c (is_defined): ditto. * variable.c (rb_mod_class_variables): need not to call rb_cvar_singleton(). * variable.c (rb_cvar_singleton): removed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2063 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'pack.c')
-rw-r--r--pack.c59
1 files changed, 46 insertions, 13 deletions
diff --git a/pack.c b/pack.c
index 242a0c7041..316becea40 100644
--- a/pack.c
+++ b/pack.c
@@ -316,6 +316,11 @@ typedef unsigned int U32;
#define NUM2U32(x) NUM2UINT(x)
#endif
+#ifdef HAVE_LONG_LONG
+# define QUAD_SIZE sizeof(LONG_LONG)
+#else
+# define QUAD_SIZE 8
+#endif
static char *toofew = "too few arguments";
static void encodes _((VALUE,char*,int,int));
@@ -594,6 +599,18 @@ pack_pack(ary, fmt)
}
break;
+ case 'q':
+ case 'Q':
+ while (len-- > 0) {
+ char tmp[QUAD_SIZE];
+
+ from = NEXTFROM;
+ if (NIL_P(from)) from = INT2FIX(0);
+ rb_quad_pack(tmp, from);
+ rb_str_buf_cat(res, (char*)&tmp, QUAD_SIZE);
+ }
+ break;
+
case 'n':
while (len-- > 0) {
unsigned short s;
@@ -1007,26 +1024,24 @@ hex2num(c)
}
}
-#ifdef NATINT_PACK
-#define PACK_LENGTH_ADJUST(type,sz) do { \
- int t__len = NATINT_LEN(type,(sz)); \
+#define PACK_LENGTH_ADJUST_SIZE(sz) do { \
tmp = 0; \
- if (len > (send-s)/t__len) { \
+ if (len > (send-s)/sz) { \
if (!star) { \
- tmp = len-(send-s)/t__len; \
+ tmp = len-(send-s)/sz; \
} \
- len = (send-s)/t__len; \
+ len = (send-s)/sz; \
} \
} while (0)
+
+#ifdef NATINT_PACK
+#define PACK_LENGTH_ADJUST(type,sz) do { \
+ int t__len = NATINT_LEN(type,(sz)); \
+ PACK_LENGTH_ADJUST_SIZE(t__len); \
+} while (0)
#else
#define PACK_LENGTH_ADJUST(type,sz) do { \
- tmp = 0; \
- if (len > (send-s)/sizeof(type)) { \
- if (!star) { \
- tmp = len - (send-s)/sizeof(type); \
- } \
- len = (send-s)/sizeof(type); \
- } \
+ PACK_LENGTH_ADJUST_SIZE(sizeof(type)); \
} while (0)
#endif
@@ -1294,6 +1309,24 @@ pack_unpack(str, fmt)
PACK_ITEM_ADJUST();
break;
+ case 'q':
+ PACK_LENGTH_ADJUST_SIZE(QUAD_SIZE);
+ while (len-- > 0) {
+ char *tmp = (char*)s;
+ s += QUAD_SIZE;
+ rb_ary_push(ary, rb_quad_unpack(tmp, 1));
+ }
+ PACK_ITEM_ADJUST();
+ break;
+ case 'Q':
+ PACK_LENGTH_ADJUST_SIZE(QUAD_SIZE);
+ while (len-- > 0) {
+ char *tmp = (char*)s;
+ s += QUAD_SIZE;
+ rb_ary_push(ary, rb_quad_unpack(tmp, 0));
+ }
+ break;
+
case 'n':
PACK_LENGTH_ADJUST(unsigned short,2);
while (len-- > 0) {