https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84381
--- Comment #6 from Thomas Koenig <tkoenig at gcc dot gnu.org> --- (In reply to Neil Carlson from comment #5) > Thomas, I saw you generated a patch with "stop n". I'd love to see how you > did it -- the regexp and counting magic. At first, I tried to find the all-inclusive regexp to do this, but that didn't work fast enough, so I settled for running different scripts for different cases. I didn't actually save all the scripts. The first one was #! /usr/bin/perl $n = 1; $abort = "call *abort *([(] *[)])?"; while (<>) { if (/$abort/) { s/$abort/STOP $n/; $n++; } print; } and another one $n = 1; while (<>) { if (/call\s*abort$/i) { s/call\s*abort/STOP $n/i; $n++; } print; } and invoked them with find . -type f -name '*.[fF]*' -exec perl -i ./c2.pl '{}' ';' Not the most general solution, but it got me there :-)