Hi Folks,
The mg command 'regexp-replace "^.*$" ""' enters an endless loop (until
memory exhausted). This behaviour also occurs in query-replace-regexp
with the "!" option.
This is due to a change I suggested to re_forwsrch, that is, not moving
dot when the line is empty (re_search.c 1.35). The reason for this
change was to ensure the replacement took effect on the starting line of
a replace-regexp, even if the line was empty.
Here's a patch to fix the issue, which is much simpler than my
previous suggestion. It merely reverses the change in re_search:
--- re_search.c.orig Mon Mar 11 16:05:29 2024
+++ re_search.c Tue Mar 26 14:20:37 2024
@@ -342,10 +342,9 @@
if (tbo == clp->l_used)
/*
* Don't start matching past end of line -- must move to
- * beginning of next line, unless line is empty or at
- * end of file.
+ * beginning of next line, unless at end of file.
*/
- if (clp != curbp->b_headp && llength(clp) != 0) {
+ if (clp != curbp->b_headp) {
clp = lforw(clp);
tdotline++;
tbo = 0;
As noted, this leave a small defect, but I think that's a better
outcome than an endless loop.
Best Regards,
Mark
--
Mark Willson | Email: [email protected]