mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
1995213e4b
commit
ba8fc117c5
12 changed files with 291 additions and 108 deletions
61
pack.c
61
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)
|
|||
}
|
||||
}
|
||||
|
||||
#define PACK_LENGTH_ADJUST_SIZE(sz) do { \
|
||||
tmp = 0; \
|
||||
if (len > (send-s)/sz) { \
|
||||
if (!star) { \
|
||||
tmp = len-(send-s)/sz; \
|
||||
} \
|
||||
len = (send-s)/sz; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#ifdef NATINT_PACK
|
||||
#define PACK_LENGTH_ADJUST(type,sz) do { \
|
||||
int t__len = NATINT_LEN(type,(sz)); \
|
||||
tmp = 0; \
|
||||
if (len > (send-s)/t__len) { \
|
||||
if (!star) { \
|
||||
tmp = len-(send-s)/t__len; \
|
||||
} \
|
||||
len = (send-s)/t__len; \
|
||||
} \
|
||||
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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue