Linux Manual Pages development
 help / color / mirror / Atom feed
* [PATCH v2 1/3] scripts/bash_aliases: man_lsfunc(), man_lsvar(): Use mansect(1)
       [not found] <cover.1730596445.git.alx@kernel.org>
@ 2024-11-03  1:16 ` Alejandro Colomar
  2024-11-03  1:26   ` Alejandro Colomar
  2024-11-03  1:17 ` [PATCH v2 2/3] scripts/bash_aliases: man_lsfunc(), man_lsvar(): Use pcre2grep(1) instead of pcregrep(1) Alejandro Colomar
  2024-11-03  1:17 ` [PATCH v2 3/3] src/bin/mansect: Preprocess with preconv(1) Alejandro Colomar
  2 siblings, 1 reply; 4+ messages in thread
From: Alejandro Colomar @ 2024-11-03  1:16 UTC (permalink / raw)
  To: linux-man; +Cc: Alejandro Colomar, groff, cjwatson, branden

[-- Attachment #1: Type: text/plain, Size: 2232 bytes --]

Remove the man_section() function, and call the mansect(1) program
instead.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
---
 scripts/bash_aliases | 45 ++++++--------------------------------------
 1 file changed, 6 insertions(+), 39 deletions(-)

diff --git a/scripts/bash_aliases b/scripts/bash_aliases
index e461707c8..25425c389 100644
--- a/scripts/bash_aliases
+++ b/scripts/bash_aliases
@@ -38,39 +38,6 @@ sed_rm_ccomments()
 ########################################################################
 #	Linux man-pages
 
-#  man_section()  prints specific manual page sections (DESCRIPTION, SYNOPSIS,
-# ...) of all manual pages in a directory (or in a single manual page file).
-# Usage example:  .../man-pages$ man_section man2 SYNOPSIS 'SEE ALSO';
-
-man_section()
-{
-	if [ $# -lt 2 ]; then
-		>&2 echo "Usage: ${FUNCNAME[0]} <dir> <section>...";
-		return $EX_USAGE;
-	fi
-
-	local page="$1";
-	shift;
-	local sect="$*";
-
-	find "$page" -type f \
-	|xargs wc -l \
-	|grep -v -e '\b1 ' -e '\btotal\b' \
-	|awk '{ print $2 }' \
-	|sort \
-	|while read -r manpage; do
-		(sed -n '/^\.TH/,/^\.SH/{/^\.SH/!p}' <"$manpage";
-		 for s in $sect; do
-			<"$manpage" \
-			sed -n \
-				-e "/^\.SH $s/p" \
-				-e "/^\.SH $s/,/^\.SH/{/^\.SH/!p}";
-		 done;) \
-		|mandoc -Tutf8 2>/dev/null \
-		|col -pbx;
-	done;
-}
-
 #  man_lsfunc()  prints the name of all C functions 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
@@ -83,9 +50,9 @@ man_lsfunc()
 		return $EX_USAGE;
 	fi
 
-	for arg in "$@"; do
-		man_section "$arg" 'SYNOPSIS';
-	done \
+	mansect 'SYNOPSIS' "$@" \
+	|mandoc -Tutf8 2>/dev/null \
+	|col -pbx \
 	|sed_rm_ccomments \
 	|pcregrep -Mn '(?s)^ [\w ]+ \**\w+\([\w\s(,)[\]*]*?(...)?\s*\); *$' \
 	|grep '^[0-9]' \
@@ -106,9 +73,9 @@ man_lsvar()
 		return $EX_USAGE;
 	fi
 
-	for arg in "$@"; do
-		man_section "$arg" 'SYNOPSIS';
-	done \
+	mansect 'SYNOPSIS' "$@" \
+	|mandoc -Tutf8 2>/dev/null \
+	|col -pbx \
 	|sed_rm_ccomments \
 	|pcregrep -Mv '(?s)^ [\w ]+ \**\w+\([\w\s(,)[\]*]+?(...)?\s*\); *$' \
 	|pcregrep -Mn \
-- 
2.39.5


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 2/3] scripts/bash_aliases: man_lsfunc(), man_lsvar(): Use pcre2grep(1) instead of pcregrep(1)
       [not found] <cover.1730596445.git.alx@kernel.org>
  2024-11-03  1:16 ` [PATCH v2 1/3] scripts/bash_aliases: man_lsfunc(), man_lsvar(): Use mansect(1) Alejandro Colomar
@ 2024-11-03  1:17 ` Alejandro Colomar
  2024-11-03  1:17 ` [PATCH v2 3/3] src/bin/mansect: Preprocess with preconv(1) Alejandro Colomar
  2 siblings, 0 replies; 4+ messages in thread
From: Alejandro Colomar @ 2024-11-03  1:17 UTC (permalink / raw)
  To: linux-man; +Cc: Alejandro Colomar, groff, cjwatson, branden

[-- Attachment #1: Type: text/plain, Size: 1113 bytes --]

pcregrep(1) is obsolete.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
---
 scripts/bash_aliases | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/scripts/bash_aliases b/scripts/bash_aliases
index 25425c389..98b466410 100644
--- a/scripts/bash_aliases
+++ b/scripts/bash_aliases
@@ -54,7 +54,7 @@ man_lsfunc()
 	|mandoc -Tutf8 2>/dev/null \
 	|col -pbx \
 	|sed_rm_ccomments \
-	|pcregrep -Mn '(?s)^ [\w ]+ \**\w+\([\w\s(,)[\]*]*?(...)?\s*\); *$' \
+	|pcre2grep -Mn '(?s)^ [\w ]+ \**\w+\([\w\s(,)[\]*]*?(...)?\s*\); *$' \
 	|grep '^[0-9]' \
 	|sed -E 's/syscall\(SYS_(\w*),?/\1(/' \
 	|sed -E 's/^[^(]+ \**(\w+)\(.*/\1/' \
@@ -77,8 +77,8 @@ man_lsvar()
 	|mandoc -Tutf8 2>/dev/null \
 	|col -pbx \
 	|sed_rm_ccomments \
-	|pcregrep -Mv '(?s)^ [\w ]+ \**\w+\([\w\s(,)[\]*]+?(...)?\s*\); *$' \
-	|pcregrep -Mn \
+	|pcre2grep -Mv '(?s)^ [\w ]+ \**\w+\([\w\s(,)[\]*]+?(...)?\s*\); *$' \
+	|pcre2grep -Mn \
 	  -e '(?s)^ +extern [\w ]+ \**\(\*+[\w ]+\)\([\w\s(,)[\]*]+?\s*\); *$' \
 	  -e '^ +extern [\w ]+ \**[\w ]+; *$' \
 	|grep '^[0-9]' \
-- 
2.39.5


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 3/3] src/bin/mansect: Preprocess with preconv(1)
       [not found] <cover.1730596445.git.alx@kernel.org>
  2024-11-03  1:16 ` [PATCH v2 1/3] scripts/bash_aliases: man_lsfunc(), man_lsvar(): Use mansect(1) Alejandro Colomar
  2024-11-03  1:17 ` [PATCH v2 2/3] scripts/bash_aliases: man_lsfunc(), man_lsvar(): Use pcre2grep(1) instead of pcregrep(1) Alejandro Colomar
@ 2024-11-03  1:17 ` Alejandro Colomar
  2 siblings, 0 replies; 4+ messages in thread
From: Alejandro Colomar @ 2024-11-03  1:17 UTC (permalink / raw)
  To: linux-man; +Cc: Alejandro Colomar, groff, cjwatson, branden

[-- Attachment #1: Type: text/plain, Size: 736 bytes --]

This doesn't process the pages in a significant way, and has the benefit
that it writes the name of the pages in the output.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
---
 src/bin/mansect | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/bin/mansect b/src/bin/mansect
index a13a6b534..e1e83a8d8 100755
--- a/src/bin/mansect
+++ b/src/bin/mansect
@@ -14,13 +14,14 @@ shift;
 
 
 if test $# -lt 1; then
-	cat;
+	preconv;
 else
 	find -L "$@" -not -type d \
 	| xargs grep -l '^\.TH ' \
-	| xargs cat;
+	| xargs preconv;
 fi \
 | sed -En \
+	-e '/^\.lf 1 /p' \
 	-e '/^\.TH /p' \
 	-e '/^\.SH '"$s"'$/p' \
 	-e '/^\.SH '"$s"'$/,/^\.(TH|SH)/{/^\.(TH|SH)/!p}';
-- 
2.39.5


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/3] scripts/bash_aliases: man_lsfunc(), man_lsvar(): Use mansect(1)
  2024-11-03  1:16 ` [PATCH v2 1/3] scripts/bash_aliases: man_lsfunc(), man_lsvar(): Use mansect(1) Alejandro Colomar
@ 2024-11-03  1:26   ` Alejandro Colomar
  0 siblings, 0 replies; 4+ messages in thread
From: Alejandro Colomar @ 2024-11-03  1:26 UTC (permalink / raw)
  To: linux-man; +Cc: groff, cjwatson, branden

[-- Attachment #1: Type: text/plain, Size: 2600 bytes --]

D'oh.  Ignore this thread, please.  I'm a bit rusty with
git-send-email(1), it seems.

On Sun, Nov 03, 2024 at 02:16:47AM +0100, Alejandro Colomar wrote:
> Remove the man_section() function, and call the mansect(1) program
> instead.
> 
> Signed-off-by: Alejandro Colomar <alx@kernel.org>
> ---
>  scripts/bash_aliases | 45 ++++++--------------------------------------
>  1 file changed, 6 insertions(+), 39 deletions(-)
> 
> diff --git a/scripts/bash_aliases b/scripts/bash_aliases
> index e461707c8..25425c389 100644
> --- a/scripts/bash_aliases
> +++ b/scripts/bash_aliases
> @@ -38,39 +38,6 @@ sed_rm_ccomments()
>  ########################################################################
>  #	Linux man-pages
>  
> -#  man_section()  prints specific manual page sections (DESCRIPTION, SYNOPSIS,
> -# ...) of all manual pages in a directory (or in a single manual page file).
> -# Usage example:  .../man-pages$ man_section man2 SYNOPSIS 'SEE ALSO';
> -
> -man_section()
> -{
> -	if [ $# -lt 2 ]; then
> -		>&2 echo "Usage: ${FUNCNAME[0]} <dir> <section>...";
> -		return $EX_USAGE;
> -	fi
> -
> -	local page="$1";
> -	shift;
> -	local sect="$*";
> -
> -	find "$page" -type f \
> -	|xargs wc -l \
> -	|grep -v -e '\b1 ' -e '\btotal\b' \
> -	|awk '{ print $2 }' \
> -	|sort \
> -	|while read -r manpage; do
> -		(sed -n '/^\.TH/,/^\.SH/{/^\.SH/!p}' <"$manpage";
> -		 for s in $sect; do
> -			<"$manpage" \
> -			sed -n \
> -				-e "/^\.SH $s/p" \
> -				-e "/^\.SH $s/,/^\.SH/{/^\.SH/!p}";
> -		 done;) \
> -		|mandoc -Tutf8 2>/dev/null \
> -		|col -pbx;
> -	done;
> -}
> -
>  #  man_lsfunc()  prints the name of all C functions 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
> @@ -83,9 +50,9 @@ man_lsfunc()
>  		return $EX_USAGE;
>  	fi
>  
> -	for arg in "$@"; do
> -		man_section "$arg" 'SYNOPSIS';
> -	done \
> +	mansect 'SYNOPSIS' "$@" \
> +	|mandoc -Tutf8 2>/dev/null \
> +	|col -pbx \
>  	|sed_rm_ccomments \
>  	|pcregrep -Mn '(?s)^ [\w ]+ \**\w+\([\w\s(,)[\]*]*?(...)?\s*\); *$' \
>  	|grep '^[0-9]' \
> @@ -106,9 +73,9 @@ man_lsvar()
>  		return $EX_USAGE;
>  	fi
>  
> -	for arg in "$@"; do
> -		man_section "$arg" 'SYNOPSIS';
> -	done \
> +	mansect 'SYNOPSIS' "$@" \
> +	|mandoc -Tutf8 2>/dev/null \
> +	|col -pbx \
>  	|sed_rm_ccomments \
>  	|pcregrep -Mv '(?s)^ [\w ]+ \**\w+\([\w\s(,)[\]*]+?(...)?\s*\); *$' \
>  	|pcregrep -Mn \
> -- 
> 2.39.5
> 



-- 
<https://www.alejandro-colomar.es/>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-11-03  1:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <cover.1730596445.git.alx@kernel.org>
2024-11-03  1:16 ` [PATCH v2 1/3] scripts/bash_aliases: man_lsfunc(), man_lsvar(): Use mansect(1) Alejandro Colomar
2024-11-03  1:26   ` Alejandro Colomar
2024-11-03  1:17 ` [PATCH v2 2/3] scripts/bash_aliases: man_lsfunc(), man_lsvar(): Use pcre2grep(1) instead of pcregrep(1) Alejandro Colomar
2024-11-03  1:17 ` [PATCH v2 3/3] src/bin/mansect: Preprocess with preconv(1) Alejandro Colomar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox