Overview
| Artifact ID: | ecd56ab4d3f2fba808f5a56df90017f554c59e2a |
|---|---|
| Ticket: | 219073ffffffffffffffffffffffffffffffffff
[regexp -all {a*} a] loops infinitely |
| User & Date: | nobody on 2000-10-26 01:10:19 |
Changes
- assignee changed to: "nobody"
- cmimetype changed to: "text/plain"
- comment changed to:
OriginalBugID: 4981 Bug Version: 8.3 SubmitDate: '2000-04-10' LastModified: '2000-04-10' Severity: CRIT Status: Released Submitter: ericm ChangedBy: ericm OS: All FixedDate: '2000-04-10' FixedInVersion: 8.3.1 ClosedDate: '2000-10-25' Because of the implementation of regexp -all, this command: regexp -all {a*} a will loop indefinately. The problem is traced to the regexp command, in which the following (essentially) occurs: while (1) { matchRegexp(...offset...); ... offset += matchLength; } In the case of {a*} and the string a, the regexp will match the {} at the end of the string. Of course, the length of {} is 0, so the offset never gets incremented, so the next pass through the loop matches against the same chunk of the string. And so on, ad infinitum. The fix requires two changes: 1. offset should always be incremented by min(1, matchLength) 2. after offset has been incremented, it should be tested to see if it is past the end of the string; if so, the loop should terminate. the regexp matching engine has the invarient that starting indices past the end of the string get confined to the range of the string, so specifying an offset of stringLength+1 will not cause it to fail to match -- it will just interpret that as stringLength. - eric Fixed for 8.3.1., with tests. - eric - foundin changed to: "obsolete: 8.3"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "nobody"
- subsystem changed to: "43. Regexp"
- title changed to: "[regexp -all {a*} a] loops infinitely"
- type changed to: "Bug"