Coder Social home page Coder Social logo

Wrong fix for #72 about bison HOT 4 CLOSED

akimd avatar akimd commented on May 17, 2024 1
Wrong fix for #72

from bison.

Comments (4)

bazsi avatar bazsi commented on May 17, 2024

@akimd can you check if this patch is sufficient?
thanks

from bison.

akimd avatar akimd commented on May 17, 2024

Hi @bazsi
Sorry for the delays. Yes, you are right, my fix was wrong on several accounts... I will install the following patch. This deserves a new release.

commit b426de59c284cd512b1ec974ac39f4fdbd0d3f21
Author: Akim Demaille <[email protected]>
Date:   Sun Mar 7 08:19:36 2021 +0100

    tables: fix again the handling for useless tokens
    
    The right-shift added in c22902e360e0fbbe9fd5657dcf107e03166da309
    ("tables: fix handling for useless tokens") is incorrect.  In
    particular, we need to reset the "new" bits.
    
    Reported by Balázs Scheidler.
    https://github.com/akimd/bison/issues/74
    
    * src/tables.c (pos_set_set): Fix the right-shift.

diff --git a/src/tables.c b/src/tables.c
index 6c8fc1cc6..a0f7cb365 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 'bitset >> 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);
 }

from bison.

akimd avatar akimd commented on May 17, 2024

Fixed in 3.7.6. Thanks for the report Balázs, and sorry about this.

from bison.

bazsi avatar bazsi commented on May 17, 2024

from bison.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.