Further shift operator regression fixes

This commit is contained in:
William S Fulton 2014-04-08 19:15:47 +01:00
commit 7bec7c1b60
2 changed files with 11 additions and 8 deletions

View file

@ -48,4 +48,6 @@ public:
// Test shifts are still working // Test shifts are still working
%inline %{ %inline %{
int shift_init1 = 4 << 2 >> 1; int shift_init1 = 4 << 2 >> 1;
int shift_init2 = 4 >> 2 << 1 << 1 >> 2;
%} %}

View file

@ -297,7 +297,7 @@ static void brackets_clear(Scanner *s) {
* brackets_increment() * brackets_increment()
* *
* Increases the number of brackets at the current depth. * Increases the number of brackets at the current depth.
* Usually called when '<' was found. * Usually called when a single '<' is found.
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */
static void brackets_increment(Scanner *s) { static void brackets_increment(Scanner *s) {
int *count = brackets_count(s); int *count = brackets_count(s);
@ -309,7 +309,7 @@ static void brackets_increment(Scanner *s) {
* brackets_decrement() * brackets_decrement()
* *
* Decreases the number of brackets at the current depth. * Decreases the number of brackets at the current depth.
* Usually called when '>' was found. * Usually called when a single '>' is found.
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */
static void brackets_decrement(Scanner *s) { static void brackets_decrement(Scanner *s) {
int *count = brackets_count(s); int *count = brackets_count(s);
@ -333,7 +333,7 @@ static void brackets_reset(Scanner *s) {
* brackets_push() * brackets_push()
* *
* Increases the depth of brackets. * Increases the depth of brackets.
* Usually called when '(' was found. * Usually called when '(' is found.
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */
static void brackets_push(Scanner *s) { static void brackets_push(Scanner *s) {
int *newInt = malloc(sizeof(int)); int *newInt = malloc(sizeof(int));
@ -345,7 +345,7 @@ static void brackets_push(Scanner *s) {
* brackets_pop() * brackets_pop()
* *
* Decreases the depth of brackets. * Decreases the depth of brackets.
* Usually called when ')' was found. * Usually called when ')' is found.
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */
static void brackets_pop(Scanner *s) { static void brackets_pop(Scanner *s) {
if (Len(s->brackets) > 0) /* protect against unbalanced ')' brackets */ if (Len(s->brackets) > 0) /* protect against unbalanced ')' brackets */
@ -360,7 +360,7 @@ static void brackets_pop(Scanner *s) {
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */
static int brackets_allow_shift(Scanner *s) { static int brackets_allow_shift(Scanner *s) {
int *count = brackets_count(s); int *count = brackets_count(s);
return !count || (*count < 0); return !count || (*count <= 0);
} }
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
@ -892,15 +892,17 @@ static int look(Scanner *s) {
} }
break; break;
case 61: case 61:
brackets_decrement(s); if ((c = nextchar(s)) == 0) {
if ((c = nextchar(s)) == 0) brackets_decrement(s);
return SWIG_TOKEN_GREATERTHAN; return SWIG_TOKEN_GREATERTHAN;
}
if (c == '>' && brackets_allow_shift(s)) if (c == '>' && brackets_allow_shift(s))
state = 250; state = 250;
else if (c == '=') else if (c == '=')
return SWIG_TOKEN_GTEQUAL; return SWIG_TOKEN_GTEQUAL;
else { else {
retract(s, 1); retract(s, 1);
brackets_decrement(s);
return SWIG_TOKEN_GREATERTHAN; return SWIG_TOKEN_GREATERTHAN;
} }
break; break;
@ -1353,7 +1355,6 @@ static int look(Scanner *s) {
break; break;
case 250: /* RSHIFT, RSEQUAL */ case 250: /* RSHIFT, RSEQUAL */
brackets_decrement(s);
if ((c = nextchar(s)) == 0) if ((c = nextchar(s)) == 0)
return SWIG_TOKEN_RSHIFT; return SWIG_TOKEN_RSHIFT;
else if (c == '=') else if (c == '=')