public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
From: Oskari Pirhonen <xxc3ncoredxx@gmail.com>
To: Alejandro Colomar <alx@kernel.org>
Cc: linux-man@vger.kernel.org
Subject: [PATCH] bin/stdc: Improve output formatting
Date: Thu, 13 Apr 2023 22:19:46 -0500	[thread overview]
Message-ID: <ZDjGUp5t5Fefb+zW@dj3ntoo> (raw)

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


             reply	other threads:[~2023-04-14  3:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-14  3:19 Oskari Pirhonen [this message]
2023-04-14 11:26 ` [PATCH] bin/stdc: Improve output formatting Alejandro Colomar
2023-04-15  7:21   ` Oskari Pirhonen
2023-04-17 17:51     ` Alejandro Colomar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZDjGUp5t5Fefb+zW@dj3ntoo \
    --to=xxc3ncoredxx@gmail.com \
    --cc=alx@kernel.org \
    --cc=linux-man@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox