[PATCH] scripts/bash_aliases: Add man_lsvar(), similar to man_lsfunc() but lists variables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Alejandro Colomar <alx.manpages@xxxxxxxxx>
---
 scripts/bash_aliases | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/scripts/bash_aliases b/scripts/bash_aliases
index c50108a16..813c00960 100644
--- a/scripts/bash_aliases
+++ b/scripts/bash_aliases
@@ -131,6 +131,33 @@ function man_lsfunc()
 	|uniq;
 }
 
+#  man_lsvar()  prints the name of all C variables declared in the SYNOPSIS
+# of all manual pages in a directory (or in a single manual page file).
+# Each name is printed in a separate line
+# Usage example:  .../man-pages$ man_lsvar man3;
+
+function man_lsvar()
+{
+	if ! [ -v 1 ]; then
+		>&2 echo "Usage: ${FUNCNAME[0]} <dir>";
+		return ${EX_USAGE};
+	fi
+
+	for arg in "$@"; do
+		man_section "${arg}" 'SYNOPSIS';
+	done \
+	|sed_rm_ccomments \
+	|pcregrep -Mv '(?s)^ [\w ]+ \**\w+\([\w\s(,)[\]*]+?(...)?\s*\); *$' \
+	|pcregrep -Mn \
+	  -e '(?s)^ +extern [\w ]+ \**\(\*+[\w ]+\)\([\w\s(,)[\]*]+?\s*\); *$' \
+	  -e '^ +extern [\w ]+ \**[\w ]+; *$' \
+	|grep '^[0-9]' \
+	|grep -v 'typedef' \
+	|sed -E 's/^[0-9]+: +extern [^(]+ \**\(\*+(\w* )?(\w+)\)\(.*/\2/' \
+	|sed    's/^[0-9]\+: \+extern .* \**\(\w\+\); */\1/' \
+	|uniq;
+}
+
 #  pdfman()  renders a manual page in PDF
 # Usage example:  .../man-pages$ pdfman man2/membarrier.2;
 
-- 
2.31.1




[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux