mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* pack.c: parenthesize macro arguments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30285 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
182b614869
commit
379f68fe4f
2 changed files with 40 additions and 36 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
Tue Dec 21 07:39:12 2010 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* pack.c: parenthesize macro arguments.
|
||||||
|
|
||||||
Tue Dec 21 06:25:43 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Tue Dec 21 06:25:43 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* test/rexml/test_contrib.rb (ContribTester#test_pos): should not
|
* test/rexml/test_contrib.rb (ContribTester#test_pos): should not
|
||||||
|
|
72
pack.c
72
pack.c
|
@ -213,22 +213,22 @@ TOKEN_PASTE(swap,x)(xtype z) \
|
||||||
|
|
||||||
#ifdef FLOAT_SWAPPER
|
#ifdef FLOAT_SWAPPER
|
||||||
# define FLOAT_CONVWITH(y) FLOAT_SWAPPER y;
|
# define FLOAT_CONVWITH(y) FLOAT_SWAPPER y;
|
||||||
# define HTONF(x,y) (memcpy(&y,&x,sizeof(float)), \
|
# define HTONF(x,y) (memcpy(&(y),&(x),sizeof(float)), \
|
||||||
y = rb_htonf((FLOAT_SWAPPER)y), \
|
(y) = rb_htonf((FLOAT_SWAPPER)(y)), \
|
||||||
memcpy(&x,&y,sizeof(float)), \
|
memcpy(&(x),&(y),sizeof(float)), \
|
||||||
x)
|
(x))
|
||||||
# define HTOVF(x,y) (memcpy(&y,&x,sizeof(float)), \
|
# define HTOVF(x,y) (memcpy(&(y),&(x),sizeof(float)), \
|
||||||
y = rb_htovf((FLOAT_SWAPPER)y), \
|
(y) = rb_htovf((FLOAT_SWAPPER)(y)), \
|
||||||
memcpy(&x,&y,sizeof(float)), \
|
memcpy(&(x),&(y),sizeof(float)), \
|
||||||
x)
|
(x))
|
||||||
# define NTOHF(x,y) (memcpy(&y,&x,sizeof(float)), \
|
# define NTOHF(x,y) (memcpy(&(y),&(x),sizeof(float)), \
|
||||||
y = rb_ntohf((FLOAT_SWAPPER)y), \
|
(y) = rb_ntohf((FLOAT_SWAPPER)(y)), \
|
||||||
memcpy(&x,&y,sizeof(float)), \
|
memcpy(&(x),&(y),sizeof(float)), \
|
||||||
x)
|
(x))
|
||||||
# define VTOHF(x,y) (memcpy(&y,&x,sizeof(float)), \
|
# define VTOHF(x,y) (memcpy(&(y),&(x),sizeof(float)), \
|
||||||
y = rb_vtohf((FLOAT_SWAPPER)y), \
|
(y) = rb_vtohf((FLOAT_SWAPPER)(y)), \
|
||||||
memcpy(&x,&y,sizeof(float)), \
|
memcpy(&(x),&(y),sizeof(float)), \
|
||||||
x)
|
(x))
|
||||||
#else
|
#else
|
||||||
# define FLOAT_CONVWITH(y)
|
# define FLOAT_CONVWITH(y)
|
||||||
# define HTONF(x,y) rb_htonf(x)
|
# define HTONF(x,y) rb_htonf(x)
|
||||||
|
@ -239,22 +239,22 @@ TOKEN_PASTE(swap,x)(xtype z) \
|
||||||
|
|
||||||
#ifdef DOUBLE_SWAPPER
|
#ifdef DOUBLE_SWAPPER
|
||||||
# define DOUBLE_CONVWITH(y) DOUBLE_SWAPPER y;
|
# define DOUBLE_CONVWITH(y) DOUBLE_SWAPPER y;
|
||||||
# define HTOND(x,y) (memcpy(&y,&x,sizeof(double)), \
|
# define HTOND(x,y) (memcpy(&(y),&(x),sizeof(double)), \
|
||||||
y = rb_htond((DOUBLE_SWAPPER)y), \
|
(y) = rb_htond((DOUBLE_SWAPPER)(y)), \
|
||||||
memcpy(&x,&y,sizeof(double)), \
|
memcpy(&(x),&(y),sizeof(double)), \
|
||||||
x)
|
(x))
|
||||||
# define HTOVD(x,y) (memcpy(&y,&x,sizeof(double)), \
|
# define HTOVD(x,y) (memcpy(&(y),&(x),sizeof(double)), \
|
||||||
y = rb_htovd((DOUBLE_SWAPPER)y), \
|
(y) = rb_htovd((DOUBLE_SWAPPER)(y)), \
|
||||||
memcpy(&x,&y,sizeof(double)), \
|
memcpy(&(x),&(y),sizeof(double)), \
|
||||||
x)
|
(x))
|
||||||
# define NTOHD(x,y) (memcpy(&y,&x,sizeof(double)), \
|
# define NTOHD(x,y) (memcpy(&(y),&(x),sizeof(double)), \
|
||||||
y = rb_ntohd((DOUBLE_SWAPPER)y), \
|
(y) = rb_ntohd((DOUBLE_SWAPPER)(y)), \
|
||||||
memcpy(&x,&y,sizeof(double)), \
|
memcpy(&(x),&(y),sizeof(double)), \
|
||||||
x)
|
(x))
|
||||||
# define VTOHD(x,y) (memcpy(&y,&x,sizeof(double)), \
|
# define VTOHD(x,y) (memcpy(&(y),&(x),sizeof(double)), \
|
||||||
y = rb_vtohd((DOUBLE_SWAPPER)y), \
|
(y) = rb_vtohd((DOUBLE_SWAPPER)(y)), \
|
||||||
memcpy(&x,&y,sizeof(double)), \
|
memcpy(&(x),&(y),sizeof(double)), \
|
||||||
x)
|
(x))
|
||||||
#else
|
#else
|
||||||
# define DOUBLE_CONVWITH(y)
|
# define DOUBLE_CONVWITH(y)
|
||||||
# define HTOND(x,y) rb_htond(x)
|
# define HTOND(x,y) rb_htond(x)
|
||||||
|
@ -1212,11 +1212,11 @@ hex2num(char c)
|
||||||
|
|
||||||
#define PACK_LENGTH_ADJUST_SIZE(sz) do { \
|
#define PACK_LENGTH_ADJUST_SIZE(sz) do { \
|
||||||
tmp_len = 0; \
|
tmp_len = 0; \
|
||||||
if (len > (long)((send-s)/sz)) { \
|
if (len > (long)((send-s)/(sz))) { \
|
||||||
if (!star) { \
|
if (!star) { \
|
||||||
tmp_len = len-(send-s)/sz; \
|
tmp_len = len-(send-s)/(sz); \
|
||||||
} \
|
} \
|
||||||
len = (send-s)/sz; \
|
len = (send-s)/(sz); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
@ -1855,7 +1855,7 @@ pack_unpack(VALUE str, VALUE fmt)
|
||||||
PACK_LENGTH_ADJUST_SIZE(sizeof(float));
|
PACK_LENGTH_ADJUST_SIZE(sizeof(float));
|
||||||
while (len-- > 0) {
|
while (len-- > 0) {
|
||||||
float tmp;
|
float tmp;
|
||||||
FLOAT_CONVWITH(ftmp;)
|
FLOAT_CONVWITH(ftmp);
|
||||||
|
|
||||||
memcpy(&tmp, s, sizeof(float));
|
memcpy(&tmp, s, sizeof(float));
|
||||||
s += sizeof(float);
|
s += sizeof(float);
|
||||||
|
|
Loading…
Reference in a new issue