Artifacts Associated With Ticket 219122ffffffffffffffffffffffffffffffffff
Ticket change [818f118fc5] (rid 117061) by nobody on 2000-10-26 01:11:05:
- assignee initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
OriginalBugID: 6284 Bug Version: 8.4a1 SubmitDate: '2000-09-19' LastModified: '2000-09-19' Severity: MED Status: Released Submitter: techsupp ChangedBy: ericm OS: Linux-Red Hat OSVersion: Redhat 7.0beta FixedDate: '2000-09-19' FixedInVersion: 8.4a2 ClosedDate: '2000-10-25' Name: Mark Patton CustomShell: Moved a test to set a flag in the Comments: Since the regexp using "-start" works I checked the code and noticed that the TCL_REG_NOTBOL flag is only set when the "-start" flag is given and offset > 0. It should really be set any time when offset > 0 ie. when looping through a string with "-all". ReproducibleScript: % regexp -all -inline ^a aaaa a a a a % regexp -all -inline -start 1 ^a aaaa ObservedBehavior: I expected only one a to be matched in the first regexp because only one a is at the beginning of the string. Note that the second regexp correctly matches nothing. DesiredBehavior: The -all option should respect the "^" constraint and only match once. Patch: *** tclCmdMZ.c.origSun Sep 10 11:59:34 2000 --- tclCmdMZ.cMon Sep 11 20:50:55 2000 *************** *** 248,261 **** return TCL_OK; } - if (offset > 0) { - /* - * Add flag if using offset (string is part of a larger string), - * so that "^" won't match. - */ - eflags |= TCL_REG_NOTBOL; - } - objc -= 2; objv += 2; resultPtr = Tcl_GetObjResult(interp); --- 248,253 ---- *************** *** 289,294 **** --- 281,294 ---- */ while (1) { + if (offset > 0) { + /* + * Add flag if using offset (string is part of a larger string), + * so that "^" won't match. + */ + eflags |= TCL_REG_NOTBOL; + } + match = Tcl_RegExpExecObj(interp, regExpr, objPtr, offset /* offset */, numMatchesSaved, eflags); PatchFiles: tclCmdMZ.c Thanks for reporting this bug. I elected to fix it slightly differently than you did: *** tclCmdMZ.c 2000/09/06 18:31:36 1.29 --- tclCmdMZ.c 2000/09/20 01:32:56 *************** *** 433,438 **** --- 433,439 ---- } offset += info.matches[0].end; all++; + eflags |= TCL_REG_NOTBOL; if (offset >= stringLength) { break; } This fix avoids the additional "if" test each time through the while loop. We know that offset will be non-zero every time through the while loop after the first, so the "if (offset > 0)" test is redundant. Thanks for reporting and suggesting a fix! Eric Melski The Other Tcl Guy ericm at ajubasolutions.com Ajuba Solutions -- 09/19/2000 ericm - foundin initialized to: "obsolete: 8.4a1"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "nobody"
- subsystem initialized to: "69. Other"
- title initialized to: "regexp -all handles "^" incorrectly"
- type initialized to: "Bug"
Ticket change [ba9ceb3da0] (rid 129351) by welch on 2000-10-26 08:34:57:
- closedate changed to: "2000-10-26T01:34:57"
- closer changed to: "welch"
- priority changed to: "2"
- resolution changed to: "Fixed"
- status changed to: "Closed"
Ticket change [e9420c93da] (rid 104791) by dgp on 2001-04-20 02:50:55:
- closedate changed to: "2001-04-19T19:50:55"
- closer changed to: "dgp"
- subsystem changed to: "18. Commands M-Z"
- title changed to: "regexp -all handles "^" incorrectly"