Listing C/C++ functions (Code analysis in Unix)

后端 未结 5 1466
栀梦
栀梦 2021-01-04 09:42

Whether we\'re maintaining unfamiliar code or checking out the implementation details of an Apache module it can help if we can quickly traverse the code and build up an ove

5条回答
  •  孤城傲影
    2021-01-04 10:24

    grep '^[a-zA-Z0-9][ *]+ {[a-zA-Z0-9_]+}\([a-zA-Z0-9\,\.\-\>]\*\)$'

    Is roughly what you want. It may take some playing with, but match a valid C++ return type, give the option of it being a pointer, then a function name (which will be \1), open parentheses, parameters, close.

    That general form (return, name, (param)) should work unless you may have line-breaks within a function declaration.

    I'd use Doxygen or another tool to parse it, but if you need to do it quickly and once, regex might be easier (or might not, with regex you never know).

提交回复
热议问题