diff options
author | Akim Demaille <akim.demaille@gmail.com> | 2021-03-10 06:41:59 +0100 |
---|---|---|
committer | Akim Demaille <akim.demaille@gmail.com> | 2021-03-10 06:41:59 +0100 |
commit | e1caae6b488c3bc9e6c1d327ccb302ed2cbf716c (patch) | |
tree | a3f8097717a8e96acd4514544409a1dabb68f945 /src | |
parent | 15c61fb7124766b1ec46cc3c98f2502fc602e092 (diff) | |
parent | c4cf4cc2f5772571a9d97893694ba2993c7152ec (diff) | |
download | bison-e1caae6b488c3bc9e6c1d327ccb302ed2cbf716c.tar.gz |
Merge 3.7.6 into master
* maint:
maint: post-release administrivia
version 3.7.6
yacc: fix push parser
tables: fix again the handling of useless tokens
Diffstat (limited to 'src')
-rw-r--r-- | src/tables.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/tables.c b/src/tables.c index 6c8fc1cc..23a879ca 100644 --- a/src/tables.c +++ b/src/tables.c @@ -180,21 +180,26 @@ pos_set_set (int pos) int bitno = pos - pos_set_base; if (bitno < 0) { + // Need more room on the left. + // DELTA is positive. Run 'pos_set >> delta'. const int delta = pos_set_base - pos; const int old_size = bitset_size (pos_set); const int new_size = old_size + delta; bitset_resize (pos_set, new_size); - // Shift all the bits by DELTA. + // Right-shift all the bits by DELTA. Be sure to reset the new + // bits on the left. + // // FIXME: add bitset_assign, and bitset_shift? - for (int i = new_size - 1; delta <= i ; --i) - if (bitset_test (pos_set, i)) - bitset_set (pos_set, i + delta); + for (int i = new_size - 1; 0 <= i ; --i) + if (delta <= i && bitset_test (pos_set, i - delta)) + bitset_set (pos_set, i); else - bitset_reset (pos_set, i + delta); + bitset_reset (pos_set, i); pos_set_base = pos; bitno = 0; } else if (bitset_size (pos_set) <= bitno) + // Need more room on the right. bitset_resize (pos_set, bitno + 1); bitset_set (pos_set, bitno); } |