News for hackers. Stuff that matters.
Re:Greppability is an underrated code metric by alienchow on Tuesday September 03, 2024 @09:09PM (#41440899)
I am actually unaware of downsides of PCRE. Could you explain? I hardly ever use literal grep nowadays.
Re:Greppability is an underrated code metric by kragen on Wednesday September 04, 2024 @02:47AM (#41442588)
oh, i mean that instead of

    grep -P '^func [^)]+\) methodName\('
you could say

    grep 'func [^)]*) methodName('
which is a bit less typing

however, i have to admit that i sort of ensnared myself in my own noose here by being too clever! i forgot that grep's regexp dialect only supports + if you \ it, and it took me six tries to figure out why i wasn't getting any grep hits. there's a lot to be said for the predictability and consistency of pcre!

Re:Greppability is an underrated code metric by kiitos on Wednesday September 04, 2024 @04:08PM (#41450176)
No need for any func, you can just

    grep '\) methodName\('
Re:Greppability is an underrated code metric by kragen on Wednesday September 04, 2024 @05:17PM (#41450940)

    grep: Unmatched ) or \)
but your main point might be right; the few non-method matches to (pcre) '\)\s*\w+\s*\(' in /usr/share/go-1.19 seem to be uncommon things like this:

    static void __attribute__ ((constructor)) sigsetup(void) {
    void poison() __attribute__ ((weak));
    C3 = -(R + I) // ADD(5,6) NEG(-5,-6)