From: Alejandro Colomar Date: Sat, 14 May 2022 23:20:39 +0000 (+0200) Subject: grepc, grepc.1: -tu: Search also within enum and type definitions X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d57c7c27f706e070b5e19ac3086472945a72ef3d;p=thirdparty%2Fman-pages.git grepc, grepc.1: -tu: Search also within enum and type definitions Signed-off-by: Alejandro Colomar --- diff --git a/bin/grepc b/bin/grepc index 173cf2b93..32b1dd3d5 100755 --- a/bin/grepc +++ b/bin/grepc @@ -268,6 +268,15 @@ grepc_type() } +grepc_use_enum() +{ + grepc_helper \ + '\benum\b' \ + "\b$1\b" \ + "(?s)^([\w[]+[\w\s]*)?\benum\b\s*([\w\s[\]]|::)*\s*{[^}]*^\s*\w+[\w\s[\]=]*\b$1\b.*?^}.*?;"; +} + + grepc_use_func_def() { grepc_helper \ @@ -308,10 +317,47 @@ grepc_use_macro() } +grepc_use_type_struct_union() +{ + grepc_helper \ + "\b(struct|union)\b" \ + "\b$1\b" \ + "(?s)^(?!^[ \t]*typedef\b)([\w[]([\w\s\(,\)[\]*]|::)*[\w\s\)*\]]\s+)?\b(struct|union)\s+\w+\s*[\w\s[\]]*{(?:(?!^}).)*?\b$1\b.*?^}.*?;"; +} + + +grepc_use_type_typedef_simple() +{ + grepc_helper \ + '^[ \t]*typedef\s' \ + "\b$1\b" \ + "(?s)^[ \t]*typedef\s+[^{};]*\b$1\b[^{};]+;"; +} + + +grepc_use_type_typedef_struct_union() +{ + grepc_helper \ + '^[ \t]*typedef\s+(struct|union)\b[^;]*$' \ + "\b$1\b" \ + "(?s)^[ \t]*typedef\s+(struct|union)\s+[\w\s[\]]*{(?:(?!^( )?}|^\s*typedef).)*\b$1\b(?:(?!^( )?}|^\s*typedef).)*^( )?}\s*\w+;"; +} + + +grepc_use_type() +{ + grepc_use_type_struct_union "$1"; + grepc_use_type_typedef_simple "$1"; + grepc_use_type_typedef_struct_union "$1"; +} + + grepc_use() { + grepc_use_enum "$1"; grepc_use_func "$1"; grepc_use_macro "$1"; + grepc_use_type "$1"; } diff --git a/share/man/man1/grepc.1 b/share/man/man1/grepc.1 index d860ce473..e504f5dc3 100644 --- a/share/man/man1/grepc.1 +++ b/share/man/man1/grepc.1 @@ -55,8 +55,11 @@ Type definitions. Uses. Searches occurences of .BI \eb identifier \eb -within function bodies and macro replacements, -and prints the whole functions and/or macros. +within enums (except as an enum constant), +function bodies, +macro replacements, +and type definitions, +and prints the whole enum, function, macro, and/or type definitions. .SH OPTIONS .TP .B \-g