Opened 10 years ago

Closed 9 years ago

#686 closed defect (fixed)

irregex-replace/all doesn't grok `bos'

Reported by: Moritz Heidkamp Owned by: sjamaan
Priority: major Milestone:
Component: core libraries Version: 4.7.x
Keywords: irregex Cc: Alex Shinn
Estimated difficulty:

Description (last modified by Moritz Heidkamp)

When irregex-replace/all is given a pattern containing a bos anchor it will not behave as expected. For example this call:

  (irregex-replace/all '(seq bos #\space) "   x   " "*")

returns "***x " rather than the expected "* x ".

Change History (9)

comment:1 Changed 10 years ago by sjamaan

Cc: foof added

The problem is that it uses irregex-fold which walks the string; it starts at the given starting point, matches and then starts again with the new starting point in the string being the place where the previous match ended.

The problem is basically that the beginning of string should only match when the substring starts at wherever you initially started to match. I'm not sure if/how this can be solved easily.

comment:2 Changed 10 years ago by sjamaan

Cc: Alex Shinn added; foof removed

comment:3 Changed 10 years ago by felix winkelmann

Milestone: 4.8.0

comment:4 Changed 10 years ago by sjamaan

I can't reproduce this (anymore?), not even with a clean 4.7.0; what happened?!

comment:5 Changed 10 years ago by Moritz Heidkamp

Description: modified (diff)

comment:6 Changed 10 years ago by Moritz Heidkamp

I think this was caused by a markup fail in the ticket: the code wasn't marked up properly leading to the (in this case important) whitespace getting folded. Fixed now.

comment:7 Changed 10 years ago by Moritz Heidkamp

(Peter's problem to reproduce the issue is fixed, not the bug itself)

comment:8 Changed 9 years ago by sjamaan

We're making progress on this one. I sent a partial fix to chicken-hackers, while working out a more complete fix with Alex.

comment:9 Changed 9 years ago by sjamaan

Resolution: fixed
Status: newclosed

This was fixed partially by 9d905e1acd87b32b744fc308891bd968bf97f10a and then entirely by 0425b20986a049217c599870f7eed70c45cb3071

Note: See TracTickets for help on using tickets.