diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-06-10 10:06:12 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-06-10 10:06:12 +0000 |
commit | 31de74167305fd4b3850d4cbc39c6e20b5468f4e (patch) | |
tree | da845161834c93006e9cc919b54e85cf892e3d92 | |
parent | abca067fb6d572ee45c585a43dbdfc153ce9f14f (diff) | |
download | ruby-31de74167305fd4b3850d4cbc39c6e20b5468f4e.tar.gz |
* numeric.c (fix_lshift): negative shift count means right shift.
* numeric.c (fix_rshift): return -1 when left side operand is
negative.
* parse.y (yylex): `0_' should be an error. (ruby-bugs-ja:PR#239)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2535 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | numeric.c | 9 | ||||
-rw-r--r-- | parse.y | 4 |
3 files changed, 20 insertions, 2 deletions
@@ -1,3 +1,12 @@ +Mon Jun 10 19:02:19 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net> + + * numeric.c (fix_lshift): negative shift count means right shift. + + * numeric.c (fix_rshift): return -1 when left side operand is + negative. + + * parse.y (yylex): `0_' should be an error. (ruby-bugs-ja:PR#239) + Sun Jun 9 17:40:41 2002 Takaaki Tateishi <ttate@kt.jaist.ac.jp> * ext/dl: change the callback mechanism. @@ -1422,6 +1422,8 @@ fix_xor(x, y) return rb_int2inum(val); } +static VALUE fix_rshift _((VALUE, VALUE)); + static VALUE fix_lshift(x, y) VALUE x, y; @@ -1430,6 +1432,8 @@ fix_lshift(x, y) val = NUM2LONG(x); width = NUM2LONG(y); + if (width < 0) + return fix_rshift(x, INT2FIX(-width)); if (width > (sizeof(VALUE)*CHAR_BIT-1) || ((unsigned long)val)>>(sizeof(VALUE)*CHAR_BIT-1-width) > 0) { return rb_big_lshift(rb_int2big(val), y); @@ -1448,11 +1452,12 @@ fix_rshift(x, y) if (i < 0) return fix_lshift(x, INT2FIX(-i)); if (i == 0) return x; + val = FIX2LONG(x); if (i >= sizeof(long)*CHAR_BIT-1) { - if (i < 0) return INT2FIX(-1); + if (val < 0) return INT2FIX(-1); return INT2FIX(0); } - val = RSHIFT(FIX2LONG(x), i); + val = RSHIFT(val, i); return INT2FIX(val); } @@ -3491,6 +3491,10 @@ yylex() yylval.val = rb_cstr_to_inum(tok(), 8, Qfalse); return tINTEGER; } + if (nondigit) { + pushback(c); + goto trailing_uc; + } } if (c > '7' && c <= '9') { yyerror("Illegal octal digit"); |