home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / gnu / utils / bug / 1446 < prev    next >
Encoding:
Text File  |  1992-08-31  |  5.7 KB  |  136 lines

  1. Newsgroups: gnu.utils.bug
  2. Path: sparky!uunet!sun-barr!cs.utexas.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!qld.tne.oz.AU!pclink
  3. From: pclink@qld.tne.oz.AU (Rick)
  4. Subject: Broken intervals in regex.c: bugfix
  5. Message-ID: <9208310555.AA00938@qld.tne.oz.au>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: GNUs Not Usenet
  8. Distribution: gnu
  9. Date: Tue, 1 Sep 1992 01:55:27 GMT
  10. Approved: bug-gnu-utils@prep.ai.mit.edu
  11. Lines: 123
  12.  
  13. regex.c doesn't work correctly with intervals.  The compiled regex
  14. contains counters to track how many times if has gone through
  15. a min/max loop, and code to initialize these counters.  However,
  16. if the pattern that is being matched fails, the code that
  17. re-initializes the max counter is not executed, leaving the
  18. old value for the next time the regex is run.  The solution is
  19. to have the compiler move the max counter initializer to the
  20. start of the min/max loop rather than the end.
  21.  
  22. There are two patches in the message.  One is for the regex.c
  23. used in sed-1.08, diff-1.15 and whatever other programs use
  24. regex.  The other patch is for regex.c as supplied with sed-1.09.
  25.  
  26. Rick.
  27.  
  28. *** sed-1.08/regex.c.orig    Mon Aug 31 14:50:36 1992
  29. --- sed-1.08/regex.c    Mon Aug 31 14:59:22 1992
  30. ***************
  31. *** 1011,1031 ****
  32.                        to this jump when matching, we'll have matched once
  33.                        already, so jump back only upper_bound - 1 times.  */
  34.   
  35.                      if (upper_bound > 1)
  36.                        {
  37. !                        store_jump_n (b, jump_n, laststart, upper_bound - 1);
  38.                          b += 5;
  39.                          /* When hit this when matching, reset the
  40.                             preceding jump_n's n to upper_bound - 1.  */
  41. !                        BUFPUSH (set_number_at);
  42. !                GET_BUFFER_SPACE (2);
  43. !                        STORE_NUMBER_AND_INCR (b, -5);
  44. !                        STORE_NUMBER_AND_INCR (b, upper_bound - 1);
  45.                        }
  46. -            /* When hit this when matching, set the succeed_n's n.  */
  47. -                    GET_BUFFER_SPACE (5);
  48. -            insert_op_2 (set_number_at, laststart, b, 5, lower_bound);
  49. -                    b += 5;
  50.                    }
  51.                 pending_exact = 0;
  52.             beg_interval = 0;
  53. --- 1011,1031 ----
  54.                        to this jump when matching, we'll have matched once
  55.                        already, so jump back only upper_bound - 1 times.  */
  56.   
  57. +            /* When hit this when matching, set the succeed_n's n.  */
  58. +                    GET_BUFFER_SPACE (5);
  59. +            insert_op_2 (set_number_at, laststart, b, 5, lower_bound);
  60. +                    b += 5;
  61.                      if (upper_bound > 1)
  62.                        {
  63. !                        store_jump_n (b, jump_n, laststart + 5, upper_bound - 1);
  64.                          b += 5;
  65.                          /* When hit this when matching, reset the
  66.                             preceding jump_n's n to upper_bound - 1.  */
  67. !                GET_BUFFER_SPACE (5);
  68. !                insert_op_2 (set_number_at, laststart, b, b - laststart,
  69. !                             upper_bound - 1);
  70. !                b += 5;
  71.                        }
  72.                    }
  73.                 pending_exact = 0;
  74.             beg_interval = 0;
  75. *** sed-1.09/regex.c.orig    Mon Aug 31 15:05:38 1992
  76. --- sed-1.09/regex.c    Mon Aug 31 15:07:40 1992
  77. ***************
  78. *** 1754,1759 ****
  79. --- 1754,1764 ----
  80.                        b += 5;     /* Just increment for the succeed_n here.  */
  81.   
  82.   
  83. +                      /* When hit this when matching, set the succeed_n's n.  */
  84. +                      GET_BUFFER_SPACE (5);
  85. +                      insert_op_2 (set_number_at, laststart, b, 5, lower_bound);
  86. +                      b += 5;
  87.                       /* More than one repetition is allowed, so put in at
  88.                          the end of the buffer a backward jump from b to the
  89.                          succeed_n we put in above.  By the time we've gotten
  90. ***************
  91. *** 1761,1784 ****
  92.                          already, so jump back only upper_bound - 1 times.  */
  93.                        if (upper_bound > 1)
  94.                          {
  95. !                          store_jump_n (b, no_pop_jump_n, laststart, 
  96.                                          upper_bound - 1);
  97.                            b += 5;
  98.   
  99.                            /* When hit this when matching, reset the
  100.                               preceding no_pop_jump_n's n to upper_bound - 1.  */
  101. !                          PAT_PUSH (set_number_at);
  102. !                          /* Only need to get space for the numbers.  */
  103. !                          GET_BUFFER_SPACE (4);
  104. !                          STORE_NUMBER_AND_INCR (b, -5);
  105. !                          STORE_NUMBER_AND_INCR (b, upper_bound - 1);
  106.                          }
  107. -                      /* When hit this when matching, set the succeed_n's n.  */
  108. -                      GET_BUFFER_SPACE (5);
  109. -                      insert_op_2 (set_number_at, laststart, b, 5, lower_bound);
  110. -                      b += 5;
  111.                      }
  112.                   pending_exact = 0;
  113.                   beg_interval = NULL;
  114. --- 1766,1782 ----
  115.                          already, so jump back only upper_bound - 1 times.  */
  116.                        if (upper_bound > 1)
  117.                          {
  118. !                          store_jump_n (b, no_pop_jump_n, laststart + 5, 
  119.                                          upper_bound - 1);
  120.                            b += 5;
  121.   
  122.                            /* When hit this when matching, reset the
  123.                               preceding no_pop_jump_n's n to upper_bound - 1.  */
  124. !              GET_BUFFER_SPACE (5);
  125. !              insert_op_2 (set_number_at, laststart, b, b - laststart,
  126. !                     upper_bound - 1);
  127. !              b += 5;
  128.                          }
  129.                      }
  130.                   pending_exact = 0;
  131.                   beg_interval = NULL;
  132.  
  133.