[PATCH] bin/stdc: Improve output formatting

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

 



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

Signed-off-by: Oskari Pirhonen <xxc3ncoredxx@xxxxxxxxx>
---

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




[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