]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
src/bin/grepc_c: -tt, -tut: Reuse grepc_c_body_()
authorAlejandro Colomar <alx@kernel.org>
Wed, 5 Nov 2025 21:42:29 +0000 (22:42 +0100)
committerAlejandro Colomar <alx@kernel.org>
Thu, 6 Nov 2025 00:43:10 +0000 (01:43 +0100)
In the last case, it removes part of the regex, but I believe that
wasn't necessary.

Also, while at this, make the trailing of the regexes to be consistently
'[^;];', which is simpler, and seems to work just fine.  If we ever see
some false positives or negatives with this regex, we should fix them
all at once, and maybe put them in a helper function.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
src/bin/grepc_c

index c7659cef585f1befd1e2b4aa8f0a4f581b4a5a6b..2bda6978eefd79eeedb26fffd514d4b8c4615aa6 100755 (executable)
@@ -147,11 +147,11 @@ grepc_c_mo()            { grepc_c_mo_decl_ "$1";
                           grepc_c_m_repl_ '';
                           echo; }
 grepc_c_t_braced()      { printf '%s' '(?s)^([\w[]([\w\s\(,\)[\]*]|::)*[\w\s\)*\]]\s+)?\b(struct|union|enum)\b([\w \t[\]]|::)+\b'"$1"'\b';
-                          printf '%s' '[ \t]*\n*([ \t]*){.*?^\5}';
-                          echo '.*?;'; }
+                          grepc_c_body_ '';
+                          echo '[^;]*;'; }
 grepc_c_t_td_simple()   { echo '(?s)^[ \t]*typedef\s+[^{};]+\b'"$1"';'; }
 grepc_c_t_td_braced()   { printf '%s' '(?s)^[ \t]*typedef\s+(struct|union|enum)\b(?:(?!\W'"$1"'\W)([\w \t[\]]|::))*';
-                          printf '%s' '\n*([ \t]*){(?:(?!^\3?}).)*?^\3}';
+                          grepc_c_body_ '';
                           echo '\s*'"$1"'(\[[\w\(,\)]\])*;'; }
 grepc_c_t_td_func()     { echo '(?s)^[ \t]*typedef\s+[^{};]+\(\**'"$1"'\)\s*\([^{};]+;'; }
 grepc_c_ue()            { grepc_c_e_decl_;
@@ -170,12 +170,12 @@ grepc_c_umo()           { grepc_c_mo_decl_ '\w+'
                           grepc_c_m_repl_ "$1";
                           echo; }
 grepc_c_ut_su()         { printf '%s' '(?s)^(?!^[ \t]*typedef\b)([\w[]([\w\s\(,\)[\]*]|::)*[\w\s\)*\]]\s+)?\b(struct|union)\b([\w \t[\]]|::)*\w+';
-                          printf '%s' '[ \t]*\n*([ \t]*){(?:(?!^\5?}).)*?'"$1"'.*?^\5}';
-                          echo '.*?;'; }
+                          grepc_c_body_ "$1";
+                          echo '[^;]*;'; }
 grepc_c_ut_td_simple()  { echo '(?s)^[ \t]*typedef\s+[^{};]*'"$1"'[^{};]+;'; }
 grepc_c_ut_td_su()      { printf '%s' '(?s)^[ \t]*typedef\s+(struct|union)\b([\w \t[\]]|::)*';
-                          printf '%s' '\n*([ \t]*){(?:(?!^\3?}|^\s*typedef).)*'"$1"'(?:(?!^\3?}|^\s*typedef).)*^\3}';
-                          echo '\s*\w+;'; }
+                          grepc_c_body_ "$1";
+                          echo '[^;]*;'; }
 
 
 if test "$t_e" = yes;             then grepc_c_e "$identifier";             fi;