public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] bin/stdc: Improve output formatting
@ 2023-04-14  3:19 Oskari Pirhonen
  2023-04-14 11:26 ` Alejandro Colomar
  0 siblings, 1 reply; 4+ messages in thread
From: Oskari Pirhonen @ 2023-04-14  3:19 UTC (permalink / raw)
  To: Alejandro Colomar; +Cc: linux-man

Remove leading whitespace and collapse multi-line declarations into a
single line using (g)awk.

Signed-off-by: Oskari Pirhonen <xxc3ncoredxx@gmail.com>
---

Here's a snippet for comparison. I've manually removed some of the
formatting repeats from C99 and C11 output for the sake of making this
message shorter.

Original:

    $ ./stdc c89 '[[:alpha:]]*scanf'
             int fscanf(FILE *stream, const char *format, ...);
             int scanf(const char *format, ...);
             int sscanf(const char *s, const char *format, ...);

    $ ./stdc c99 '[[:alpha:]]*scanf'
          int fscanf(FILE * restrict stream,
               const char * restrict format, ...);
          int scanf(const char * restrict format, ...);
            int fwscanf(FILE * restrict stream,
                 const wchar_t * restrict format, ...);
            int wscanf(const wchar_t * restrict format, ...);

    $ ./stdc c11 '[[:alpha:]]*scanf'
          int fscanf(FILE * restrict stream,
               const char * restrict format, ...);
          int scanf(const char * restrict format, ...);
            int vsscanf(const char * restrict s,
                 const char * restrict format, va_list arg);

New:

    $ ./stdc c89 '[[:alpha:]]*scanf'
    int fscanf(FILE *stream, const char *format, ...);
    int scanf(const char *format, ...);
    int sscanf(const char *s, const char *format, ...);

    $ ./stdc c99 '[[:alpha:]]*scanf'
    int fscanf(FILE * restrict stream, const char * restrict format, ...);
    int scanf(const char * restrict format, ...);
    int fwscanf(FILE * restrict stream, const wchar_t * restrict format, ...);
    int wscanf(const wchar_t * restrict format, ...);

    $ ./stdc c11 '[[:alpha:]]*scanf'
    int fscanf(FILE * restrict stream, const char * restrict format, ...);
    int scanf(const char * restrict format, ...);
    int vsscanf(const char * restrict s, const char * restrict format, va_list arg);

 bin/stdc | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/bin/stdc b/bin/stdc
index b685df8..8c07956 100755
--- a/bin/stdc
+++ b/bin/stdc
@@ -14,7 +14,14 @@ err()
 
 grep_proto()
 {
-	pcre2grep -M "(?s)\b$1 *\([[:alnum:]*,._\s\(\)-]*\);$";
+	pcre2grep -M "(?s)\b$1 *\([[:alnum:]*,._\s\(\)-]*\);$" \
+	| awk -e 'BEGIN { RS=";\n"; ORS=RS; }
+		{
+			gsub(/\n/, " ");
+			sub(/^ +/, "");
+			gsub(/ +/, " ");
+			print;
+		}';
 }
 
 libc_summ_c89()
-- 
2.39.2


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

end of thread, other threads:[~2023-04-17 17:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-14  3:19 [PATCH] bin/stdc: Improve output formatting Oskari Pirhonen
2023-04-14 11:26 ` Alejandro Colomar
2023-04-15  7:21   ` Oskari Pirhonen
2023-04-17 17:51     ` Alejandro Colomar

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