Since comint-prompt-regexp almost always starts with "^", this change
seems to be fundamentally wrong: it will give a regexp of the form
\(^^...\) which interprets the second ^ as an actual ^ char rather than
as a `bolp` check.
So if it avoids a problem, it's likely not the right fix but rather
because it just deactivates this loop.
As the original author of this code, I must admit that I don't fully
understand why this loop is here (it seems redundant with the
immediately preceding loop, which was introduced by the same commit).
>> * lisp/comint.el (comint-output-filter): Revert last tweak because
>> it can hang gdb indefinitely.
> Hmm... it would be worthwhile to investigate what's really going on here.
>> - (while (string-match (concat "\\(" comint-prompt-regexp
>> + (while (string-match (concat "\\(^" comint-prompt-regexp
> As the original author of this code, I must admit that I don't fully
> understand why this loop is here (it seems redundant with the
> immediately preceding loop, which was introduced by the same commit).
It looks to me that the first loop only removes prompts that match the
previous prompt found in the buffer text. The second loop removes any
prompts that match the regexp (which may not be the same as the previous
prompt if `comint-prompt-regexp' contains alternatives).
I presume it was done this way to be slightly faster ?