* [PATCH] scripts/bash_aliases: Make man_lsfunc() more robust; Add sed_rm_ccomments().
@ 2021-03-07 19:56 Alejandro Colomar
2021-03-07 20:21 ` Alejandro Colomar (man-pages)
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Alejandro Colomar @ 2021-03-07 19:56 UTC (permalink / raw)
To: mtk.manpages; +Cc: Alejandro Colomar, linux-man, Stefan Puiu, Walter Harms
This patch makes man_lsfunc() search for the function prototypes,
instead of relying on the current manual page formatting,
which might change in the future, and break this function.
It also simplifies the code, by reusing man_section().
As a side effect, this change fixed some corner cases, where this
function failed to find a function, or listed a wrong function.
Create a new function sed_rm_ccomments(), which is needed by
man_lsfunc(), and may also be useful in other cases.
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
---
scripts/bash_aliases | 40 ++++++++++++++++++++++------------------
1 file changed, 22 insertions(+), 18 deletions(-)
diff --git a/scripts/bash_aliases b/scripts/bash_aliases
index d9b6047d1..12fb203e1 100644
--- a/scripts/bash_aliases
+++ b/scripts/bash_aliases
@@ -20,6 +20,21 @@
EX_OK=0;
EX_USAGE=64;
+########################################################################
+# C
+
+# sed_rm_ccomments() removes C comments.
+# It can't handle multiple comments in a sinlge line correctly,
+# nor mixed or embedded //... and /*...*/ comments.
+# Use as a filter (see man_lsfunc() in this file).
+
+function sed_rm_ccomments()
+{
+ sed 's%/\*.*\*/%%' \
+ |sed -r '\%/\*%,\%\*/%{\%(\*/|/\*)%!d; s%/\*.*%%; s%.*\*/%%;}' \
+ |sed 's%//.*%%';
+}
+
########################################################################
# Linux kernel
@@ -106,25 +121,14 @@ function man_lsfunc()
return ${EX_USAGE};
fi
- find "${@}" -type f \
- |xargs grep -l "\.SH SYNOPSIS" \
- |sort -V \
- |while read -r manpage; do
- <${manpage} \
- sed -n \
- -e '/^\.TH/,/^\.SH/{/^\.SH/!p}' \
- -e "/^\.SH SYNOPSIS/p" \
- -e "/^\.SH SYNOPSIS/,/^\.SH/{/^\.SH/!p}" \
- |sed \
- -e '/Feature/,$d' \
- -e '/{/,/}/d' \
- |man -P cat -l - 2>/dev/null;
+ for arg in "$@"; do
+ man_section "${arg}" "SYNOPSIS";
done \
- |sed -n "/^SYNOPSIS/,/^\w/p" \
- |grep '^ \w' \
- |grep -v ':' \
- |sed 's/^[^(]* \**\(\w*\)(.*/\1/' \
- |grep '^\w' \
+ |sed_rm_ccomments \
+ |pcregrep -Mn \
+ "(?s)^ [\w ]+ \**\w+\([\w\s(,)[\]*]+?(...)?\s*\); *$" \
+ |grep '^[0-9]' \
+ |sed -r 's/^[^(]+ +\**(\w+)\(.*/\1/' \
|uniq;
}
--
2.30.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] scripts/bash_aliases: Make man_lsfunc() more robust; Add sed_rm_ccomments().
2021-03-07 19:56 [PATCH] scripts/bash_aliases: Make man_lsfunc() more robust; Add sed_rm_ccomments() Alejandro Colomar
@ 2021-03-07 20:21 ` Alejandro Colomar (man-pages)
2021-03-07 20:26 ` [PATCH v2] " Alejandro Colomar
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Alejandro Colomar (man-pages) @ 2021-03-07 20:21 UTC (permalink / raw)
To: mtk.manpages; +Cc: linux-man, Stefan Puiu, Walter Harms
Hi Michael,
Please fix some minor things for me (see below).
Thanks,
Alex
On 3/7/21 8:56 PM, Alejandro Colomar wrote:
> This patch makes man_lsfunc() search for the function prototypes,
> instead of relying on the current manual page formatting,
> which might change in the future, and break this function.
> It also simplifies the code, by reusing man_section().
>
> As a side effect, this change fixed some corner cases, where this
> function failed to find a function, or listed a wrong function.
>
> Create a new function sed_rm_ccomments(), which is needed by
> man_lsfunc(), and may also be useful in other cases.
>
> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
> ---
> scripts/bash_aliases | 40 ++++++++++++++++++++++------------------
> 1 file changed, 22 insertions(+), 18 deletions(-)
>
> diff --git a/scripts/bash_aliases b/scripts/bash_aliases
> index d9b6047d1..12fb203e1 100644
> --- a/scripts/bash_aliases
> +++ b/scripts/bash_aliases
> @@ -20,6 +20,21 @@
> EX_OK=0;
> EX_USAGE=64;
>
> +########################################################################
> +# C
> +
> +# sed_rm_ccomments() removes C comments.
> +# It can't handle multiple comments in a sinlge line correctly,
> +# nor mixed or embedded //... and /*...*/ comments.
> +# Use as a filter (see man_lsfunc() in this file).
> +
> +function sed_rm_ccomments()
> +{
> + sed 's%/\*.*\*/%%' \
> + |sed -r '\%/\*%,\%\*/%{\%(\*/|/\*)%!d; s%/\*.*%%; s%.*\*/%%;}' \
> + |sed 's%//.*%%';
> +}
> +
> ########################################################################
> # Linux kernel
>
> @@ -106,25 +121,14 @@ function man_lsfunc()
> return ${EX_USAGE};
> fi
>
> - find "${@}" -type f \
> - |xargs grep -l "\.SH SYNOPSIS" \
> - |sort -V \
> - |while read -r manpage; do
> - <${manpage} \
> - sed -n \
> - -e '/^\.TH/,/^\.SH/{/^\.SH/!p}' \
> - -e "/^\.SH SYNOPSIS/p" \
> - -e "/^\.SH SYNOPSIS/,/^\.SH/{/^\.SH/!p}" \
> - |sed \
> - -e '/Feature/,$d' \
> - -e '/{/,/}/d' \
> - |man -P cat -l - 2>/dev/null;
> + for arg in "$@"; do
> + man_section "${arg}" "SYNOPSIS";
s/"SYNOPSIS"/'SYNOPSIS'/
> done \
> - |sed -n "/^SYNOPSIS/,/^\w/p" \
> - |grep '^ \w' \
> - |grep -v ':' \
> - |sed 's/^[^(]* \**\(\w*\)(.*/\1/' \
> - |grep '^\w' \
> + |sed_rm_ccomments \
> + |pcregrep -Mn \
> + "(?s)^ [\w ]+ \**\w+\([\w\s(,)[\]*]+?(...)?\s*\); *$" \
s/"/'/
> + |grep '^[0-9]' \
> + |sed -r 's/^[^(]+ +\**(\w+)\(.*/\1/' \
> |uniq;
> }
>
>
--
Alejandro Colomar
Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/
http://www.alejandro-colomar.es/
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2] scripts/bash_aliases: Make man_lsfunc() more robust; Add sed_rm_ccomments().
2021-03-07 19:56 [PATCH] scripts/bash_aliases: Make man_lsfunc() more robust; Add sed_rm_ccomments() Alejandro Colomar
2021-03-07 20:21 ` Alejandro Colomar (man-pages)
@ 2021-03-07 20:26 ` Alejandro Colomar
2021-03-07 20:55 ` [PATCH v3] " Alejandro Colomar
2021-03-07 23:32 ` [PATCH v4] " Alejandro Colomar
3 siblings, 0 replies; 7+ messages in thread
From: Alejandro Colomar @ 2021-03-07 20:26 UTC (permalink / raw)
To: mtk.manpages; +Cc: Alejandro Colomar, linux-man, Stefan Puiu, Walter Harms
This patch makes man_lsfunc() search for the function prototypes,
instead of relying on the current manual page formatting,
which might change in the future, and break this function.
It also simplifies the code, by reusing man_section().
Create a new function sed_rm_ccomments(), which is needed by
man_lsfunc(), and may also be useful in other cases.
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
---
Hi Michael,
Never mind the previous email. I fixed it and merged two lines that
could be merged.
Regards,
Alex
scripts/bash_aliases | 39 +++++++++++++++++++++------------------
1 file changed, 21 insertions(+), 18 deletions(-)
diff --git a/scripts/bash_aliases b/scripts/bash_aliases
index d9b6047d1..ba6544a97 100644
--- a/scripts/bash_aliases
+++ b/scripts/bash_aliases
@@ -20,6 +20,21 @@
EX_OK=0;
EX_USAGE=64;
+########################################################################
+# C
+
+# sed_rm_ccomments() removes C comments.
+# It can't handle multiple comments in a sinlge line correctly,
+# nor mixed or embedded //... and /*...*/ comments.
+# Use as a filter (see man_lsfunc() in this file).
+
+function sed_rm_ccomments()
+{
+ sed 's%/\*.*\*/%%' \
+ |sed -r '\%/\*%,\%\*/%{\%(\*/|/\*)%!d; s%/\*.*%%; s%.*\*/%%;}' \
+ |sed 's%//.*%%';
+}
+
########################################################################
# Linux kernel
@@ -106,25 +121,13 @@ function man_lsfunc()
return ${EX_USAGE};
fi
- find "${@}" -type f \
- |xargs grep -l "\.SH SYNOPSIS" \
- |sort -V \
- |while read -r manpage; do
- <${manpage} \
- sed -n \
- -e '/^\.TH/,/^\.SH/{/^\.SH/!p}' \
- -e "/^\.SH SYNOPSIS/p" \
- -e "/^\.SH SYNOPSIS/,/^\.SH/{/^\.SH/!p}" \
- |sed \
- -e '/Feature/,$d' \
- -e '/{/,/}/d' \
- |man -P cat -l - 2>/dev/null;
+ for arg in "$@"; do
+ man_section "${arg}" 'SYNOPSIS';
done \
- |sed -n "/^SYNOPSIS/,/^\w/p" \
- |grep '^ \w' \
- |grep -v ':' \
- |sed 's/^[^(]* \**\(\w*\)(.*/\1/' \
- |grep '^\w' \
+ |sed_rm_ccomments \
+ |pcregrep -Mn '(?s)^ [\w ]+ \**\w+\([\w\s(,)[\]*]+?(...)?\s*\); *$' \
+ |grep '^[0-9]' \
+ |sed -r 's/^[^(]+ +\**(\w+)\(.*/\1/' \
|uniq;
}
--
2.30.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3] scripts/bash_aliases: Make man_lsfunc() more robust; Add sed_rm_ccomments().
2021-03-07 19:56 [PATCH] scripts/bash_aliases: Make man_lsfunc() more robust; Add sed_rm_ccomments() Alejandro Colomar
2021-03-07 20:21 ` Alejandro Colomar (man-pages)
2021-03-07 20:26 ` [PATCH v2] " Alejandro Colomar
@ 2021-03-07 20:55 ` Alejandro Colomar
2021-03-07 23:32 ` [PATCH v4] " Alejandro Colomar
3 siblings, 0 replies; 7+ messages in thread
From: Alejandro Colomar @ 2021-03-07 20:55 UTC (permalink / raw)
To: mtk.manpages; +Cc: Alejandro Colomar, linux-man, Stefan Puiu, Walter Harms
This patch makes man_lsfunc() search for the function prototypes,
instead of relying on the current manual page formatting,
which might change in the future, and break this function.
It also simplifies the code, by reusing man_section().
Create a new function sed_rm_ccomments(), which is needed by
man_lsfunc(), and may also be useful in other cases.
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
---
v3: Simplify regex
scripts/bash_aliases | 39 +++++++++++++++++++++------------------
1 file changed, 21 insertions(+), 18 deletions(-)
diff --git a/scripts/bash_aliases b/scripts/bash_aliases
index d9b6047d1..ba6544a97 100644
--- a/scripts/bash_aliases
+++ b/scripts/bash_aliases
@@ -20,6 +20,21 @@
EX_OK=0;
EX_USAGE=64;
+########################################################################
+# C
+
+# sed_rm_ccomments() removes C comments.
+# It can't handle multiple comments in a sinlge line correctly,
+# nor mixed or embedded //... and /*...*/ comments.
+# Use as a filter (see man_lsfunc() in this file).
+
+function sed_rm_ccomments()
+{
+ sed 's%/\*.*\*/%%' \
+ |sed -r '\%/\*%,\%\*/%{\%(\*/|/\*)%!d; s%/\*.*%%; s%.*\*/%%;}' \
+ |sed 's%//.*%%';
+}
+
########################################################################
# Linux kernel
@@ -106,25 +121,13 @@ function man_lsfunc()
return ${EX_USAGE};
fi
- find "${@}" -type f \
- |xargs grep -l "\.SH SYNOPSIS" \
- |sort -V \
- |while read -r manpage; do
- <${manpage} \
- sed -n \
- -e '/^\.TH/,/^\.SH/{/^\.SH/!p}' \
- -e "/^\.SH SYNOPSIS/p" \
- -e "/^\.SH SYNOPSIS/,/^\.SH/{/^\.SH/!p}" \
- |sed \
- -e '/Feature/,$d' \
- -e '/{/,/}/d' \
- |man -P cat -l - 2>/dev/null;
+ for arg in "$@"; do
+ man_section "${arg}" 'SYNOPSIS';
done \
- |sed -n "/^SYNOPSIS/,/^\w/p" \
- |grep '^ \w' \
- |grep -v ':' \
- |sed 's/^[^(]* \**\(\w*\)(.*/\1/' \
- |grep '^\w' \
+ |sed_rm_ccomments \
+ |pcregrep -Mn '(?s)^ [\w ]+ \**\w+\([\w\s(,)[\]*]+?(...)?\s*\); *$' \
+ |grep '^[0-9]' \
+ |sed -r 's/^[^(]+ \**(\w+)\(.*/\1/' \
|uniq;
}
--
2.30.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v4] scripts/bash_aliases: Make man_lsfunc() more robust; Add sed_rm_ccomments().
2021-03-07 19:56 [PATCH] scripts/bash_aliases: Make man_lsfunc() more robust; Add sed_rm_ccomments() Alejandro Colomar
` (2 preceding siblings ...)
2021-03-07 20:55 ` [PATCH v3] " Alejandro Colomar
@ 2021-03-07 23:32 ` Alejandro Colomar
3 siblings, 0 replies; 7+ messages in thread
From: Alejandro Colomar @ 2021-03-07 23:32 UTC (permalink / raw)
To: mtk.manpages; +Cc: Alejandro Colomar, linux-man, Stefan Puiu, Walter Harms
This patch makes man_lsfunc() search for the function prototypes,
instead of relying on the current manual page formatting,
which might change in the future, and break this function.
It also simplifies the code, by reusing man_section().
Create a new function sed_rm_ccomments(), which is needed by
man_lsfunc(), and may also be useful in other cases.
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
---
v3: Simplify regex
v4: Use POSIX -E instead of -r for sed
scripts/bash_aliases | 39 +++++++++++++++++++++------------------
1 file changed, 21 insertions(+), 18 deletions(-)
diff --git a/scripts/bash_aliases b/scripts/bash_aliases
index d9b6047d1..ba6544a97 100644
--- a/scripts/bash_aliases
+++ b/scripts/bash_aliases
@@ -20,6 +20,21 @@
EX_OK=0;
EX_USAGE=64;
+########################################################################
+# C
+
+# sed_rm_ccomments() removes C comments.
+# It can't handle multiple comments in a sinlge line correctly,
+# nor mixed or embedded //... and /*...*/ comments.
+# Use as a filter (see man_lsfunc() in this file).
+
+function sed_rm_ccomments()
+{
+ sed 's%/\*.*\*/%%' \
+ |sed -E '\%/\*%,\%\*/%{\%(\*/|/\*)%!d; s%/\*.*%%; s%.*\*/%%;}' \
+ |sed 's%//.*%%';
+}
+
########################################################################
# Linux kernel
@@ -106,25 +121,13 @@ function man_lsfunc()
return ${EX_USAGE};
fi
- find "${@}" -type f \
- |xargs grep -l "\.SH SYNOPSIS" \
- |sort -V \
- |while read -r manpage; do
- <${manpage} \
- sed -n \
- -e '/^\.TH/,/^\.SH/{/^\.SH/!p}' \
- -e "/^\.SH SYNOPSIS/p" \
- -e "/^\.SH SYNOPSIS/,/^\.SH/{/^\.SH/!p}" \
- |sed \
- -e '/Feature/,$d' \
- -e '/{/,/}/d' \
- |man -P cat -l - 2>/dev/null;
+ for arg in "$@"; do
+ man_section "${arg}" 'SYNOPSIS';
done \
- |sed -n "/^SYNOPSIS/,/^\w/p" \
- |grep '^ \w' \
- |grep -v ':' \
- |sed 's/^[^(]* \**\(\w*\)(.*/\1/' \
- |grep '^\w' \
+ |sed_rm_ccomments \
+ |pcregrep -Mn '(?s)^ [\w ]+ \**\w+\([\w\s(,)[\]*]+?(...)?\s*\); *$' \
+ |grep '^[0-9]' \
+ |sed -E 's/^[^(]+ \**(\w+)\(.*/\1/' \
|uniq;
}
--
2.30.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH] fflush.3: SEE ALSO: Add fpurge(3)
@ 2021-05-09 21:38 Alejandro Colomar
2021-05-09 21:39 ` [PATCH] scripts/bash_aliases: Make man_lsfunc() more robust; Add sed_rm_ccomments() Alejandro Colomar
0 siblings, 1 reply; 7+ messages in thread
From: Alejandro Colomar @ 2021-05-09 21:38 UTC (permalink / raw)
To: mtk.manpages; +Cc: Alejandro Colomar, linux-man
fpurge(i_stream) does the same as fflush(i_stream), AFAIK.
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
---
Hi Michael,
This is the first of many separate patches that I had pending for you.
Some of them I already sent you, and you should ignore the old versions.
Some of them are new.
Please review them thoroughly, as I may have sent some patch that wasn't
ready. In theory I have reviewed them enough, but there are a lot, and
I might have overlooked something.
When you review this "set", I'll send you another one about the SYNOPSIS.
Thanks,
Alex
man3/fflush.3 | 1 +
1 file changed, 1 insertion(+)
diff --git a/man3/fflush.3 b/man3/fflush.3
index 138c9bcfe..a600da2ae 100644
--- a/man3/fflush.3
+++ b/man3/fflush.3
@@ -133,6 +133,7 @@ or
.BR sync (2),
.BR write (2),
.BR fclose (3),
+.BR fpurge (3),
.BR fileno (3),
.BR fopen (3),
.BR setbuf (3),
--
2.31.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH] scripts/bash_aliases: Make man_lsfunc() more robust; Add sed_rm_ccomments().
2021-05-09 21:38 [PATCH] fflush.3: SEE ALSO: Add fpurge(3) Alejandro Colomar
@ 2021-05-09 21:39 ` Alejandro Colomar
2021-05-09 23:32 ` Michael Kerrisk (man-pages)
0 siblings, 1 reply; 7+ messages in thread
From: Alejandro Colomar @ 2021-05-09 21:39 UTC (permalink / raw)
To: mtk.manpages; +Cc: Alejandro Colomar, linux-man
This patch makes man_lsfunc() search for the function prototypes,
instead of relying on the current manual page formatting,
which might change in the future, and break this function.
It also simplifies the code, by reusing man_section().
Create a new function sed_rm_ccomments(), which is needed by
man_lsfunc(), and may also be useful in other cases.
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
---
scripts/bash_aliases | 39 +++++++++++++++++++++------------------
1 file changed, 21 insertions(+), 18 deletions(-)
diff --git a/scripts/bash_aliases b/scripts/bash_aliases
index d9b6047d1..c50108a16 100644
--- a/scripts/bash_aliases
+++ b/scripts/bash_aliases
@@ -20,6 +20,21 @@
EX_OK=0;
EX_USAGE=64;
+########################################################################
+# C
+
+# sed_rm_ccomments() removes C comments.
+# It can't handle multiple comments in a sinlge line correctly,
+# nor mixed or embedded //... and /*...*/ comments.
+# Use as a filter (see man_lsfunc() in this file).
+
+function sed_rm_ccomments()
+{
+ sed 's%/\*.*\*/%%' \
+ |sed -E '\%/\*%,\%\*/%{\%(\*/|/\*)%!d; s%/\*.*%%; s%.*\*/%%;}' \
+ |sed 's%//.*%%';
+}
+
########################################################################
# Linux kernel
@@ -106,25 +121,13 @@ function man_lsfunc()
return ${EX_USAGE};
fi
- find "${@}" -type f \
- |xargs grep -l "\.SH SYNOPSIS" \
- |sort -V \
- |while read -r manpage; do
- <${manpage} \
- sed -n \
- -e '/^\.TH/,/^\.SH/{/^\.SH/!p}' \
- -e "/^\.SH SYNOPSIS/p" \
- -e "/^\.SH SYNOPSIS/,/^\.SH/{/^\.SH/!p}" \
- |sed \
- -e '/Feature/,$d' \
- -e '/{/,/}/d' \
- |man -P cat -l - 2>/dev/null;
+ for arg in "$@"; do
+ man_section "${arg}" 'SYNOPSIS';
done \
- |sed -n "/^SYNOPSIS/,/^\w/p" \
- |grep '^ \w' \
- |grep -v ':' \
- |sed 's/^[^(]* \**\(\w*\)(.*/\1/' \
- |grep '^\w' \
+ |sed_rm_ccomments \
+ |pcregrep -Mn '(?s)^ [\w ]+ \**\w+\([\w\s(,)[\]*]+?(...)?\s*\); *$' \
+ |grep '^[0-9]' \
+ |sed -E 's/^[^(]+ \**(\w+)\(.*/\1/' \
|uniq;
}
--
2.31.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] scripts/bash_aliases: Make man_lsfunc() more robust; Add sed_rm_ccomments().
2021-05-09 21:39 ` [PATCH] scripts/bash_aliases: Make man_lsfunc() more robust; Add sed_rm_ccomments() Alejandro Colomar
@ 2021-05-09 23:32 ` Michael Kerrisk (man-pages)
0 siblings, 0 replies; 7+ messages in thread
From: Michael Kerrisk (man-pages) @ 2021-05-09 23:32 UTC (permalink / raw)
To: Alejandro Colomar; +Cc: mtk.manpages, linux-man
Hi Alex,
On 5/10/21 9:39 AM, Alejandro Colomar wrote:
> This patch makes man_lsfunc() search for the function prototypes,
> instead of relying on the current manual page formatting,
> which might change in the future, and break this function.
>
> It also simplifies the code, by reusing man_section().
>
> Create a new function sed_rm_ccomments(), which is needed by
> man_lsfunc(), and may also be useful in other cases.
>
> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
Applied.
Thanks,
Michael
> ---
> scripts/bash_aliases | 39 +++++++++++++++++++++------------------
> 1 file changed, 21 insertions(+), 18 deletions(-)
>
> diff --git a/scripts/bash_aliases b/scripts/bash_aliases
> index d9b6047d1..c50108a16 100644
> --- a/scripts/bash_aliases
> +++ b/scripts/bash_aliases
> @@ -20,6 +20,21 @@
> EX_OK=0;
> EX_USAGE=64;
>
> +########################################################################
> +# C
> +
> +# sed_rm_ccomments() removes C comments.
> +# It can't handle multiple comments in a sinlge line correctly,
> +# nor mixed or embedded //... and /*...*/ comments.
> +# Use as a filter (see man_lsfunc() in this file).
> +
> +function sed_rm_ccomments()
> +{
> + sed 's%/\*.*\*/%%' \
> + |sed -E '\%/\*%,\%\*/%{\%(\*/|/\*)%!d; s%/\*.*%%; s%.*\*/%%;}' \
> + |sed 's%//.*%%';
> +}
> +
> ########################################################################
> # Linux kernel
>
> @@ -106,25 +121,13 @@ function man_lsfunc()
> return ${EX_USAGE};
> fi
>
> - find "${@}" -type f \
> - |xargs grep -l "\.SH SYNOPSIS" \
> - |sort -V \
> - |while read -r manpage; do
> - <${manpage} \
> - sed -n \
> - -e '/^\.TH/,/^\.SH/{/^\.SH/!p}' \
> - -e "/^\.SH SYNOPSIS/p" \
> - -e "/^\.SH SYNOPSIS/,/^\.SH/{/^\.SH/!p}" \
> - |sed \
> - -e '/Feature/,$d' \
> - -e '/{/,/}/d' \
> - |man -P cat -l - 2>/dev/null;
> + for arg in "$@"; do
> + man_section "${arg}" 'SYNOPSIS';
> done \
> - |sed -n "/^SYNOPSIS/,/^\w/p" \
> - |grep '^ \w' \
> - |grep -v ':' \
> - |sed 's/^[^(]* \**\(\w*\)(.*/\1/' \
> - |grep '^\w' \
> + |sed_rm_ccomments \
> + |pcregrep -Mn '(?s)^ [\w ]+ \**\w+\([\w\s(,)[\]*]+?(...)?\s*\); *$' \
> + |grep '^[0-9]' \
> + |sed -E 's/^[^(]+ \**(\w+)\(.*/\1/' \
> |uniq;
> }
>
>
--
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-05-09 23:32 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-07 19:56 [PATCH] scripts/bash_aliases: Make man_lsfunc() more robust; Add sed_rm_ccomments() Alejandro Colomar
2021-03-07 20:21 ` Alejandro Colomar (man-pages)
2021-03-07 20:26 ` [PATCH v2] " Alejandro Colomar
2021-03-07 20:55 ` [PATCH v3] " Alejandro Colomar
2021-03-07 23:32 ` [PATCH v4] " Alejandro Colomar
2021-05-09 21:38 [PATCH] fflush.3: SEE ALSO: Add fpurge(3) Alejandro Colomar
2021-05-09 21:39 ` [PATCH] scripts/bash_aliases: Make man_lsfunc() more robust; Add sed_rm_ccomments() Alejandro Colomar
2021-05-09 23:32 ` Michael Kerrisk (man-pages)
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.