]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
src/bin/grepc_c: Split regex
authorAlejandro Colomar <alx@kernel.org>
Wed, 5 Nov 2025 13:22:36 +0000 (14:22 +0100)
committerAlejandro Colomar <alx@kernel.org>
Thu, 6 Nov 2025 00:43:03 +0000 (01:43 +0100)
The regex for a function declarator is too complex.  Split it into
helper functions that prints the parts of the regex, so that each one
is easier to understand.

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

index a28992a0f32230978ee645f3792ce720bea32e90..ca9e0581de50d01491c33b5182d8466d0dc29394 100755 (executable)
@@ -107,7 +107,11 @@ fi;
 
 
 grepc_c_e()             { echo '(?s)^([\w[]+[\w\s]*)?\benum\b[ \t]*([\w \t[\]]|::)*\n*([ \t]*){[^}]*^[ \t]*'"$1"'\b\s*[=,].*?^\3}.*?;'; }
-grepc_c_f_decl_()       { printf '%s' '(?s)^[\w[](?:[\w\s\(,\)[\]*]|::)+[\w\s\)*\]]\s+\**\(?'"$1"'\)?\s*(\((?:[\w\s,;[\]*]|::|(?1))*(?:\.\.\.)?\))'; }
+grepc_c_f_return_()     { printf '%s' '(?s)^[\w[](?:[\w\s\(,\)[\]*]|::)+[\w\s\)*\]]\s+\**'; }
+grepc_c_f_params_()     { printf '%s' '\s*(\((?:[\w\s,;[\]*]|::|(?1))*(?:\.\.\.)?\))'; }
+grepc_c_f_decl_()       { grepc_c_f_return_;
+                          printf '%s' '\(?'"$1"'\)?';
+                          grepc_c_f_params_; }
 grepc_c_fp()            { grepc_c_f_decl_ "$1";
                           echo '(?:[\w\s\(,\)[\]]|::)*;'; }
 grepc_c_fd()            { grepc_c_f_decl_ "$1";