[FFmpeg-devel] [PATCH 1/2] configure: print_in_columns: Replace pr with awk

Alexander Strasser eclipse7 at gmx.net
Wed May 1 19:07:52 EEST 2019


Get rid of pr dependency and write the columns strictly
alphabetical for the given rows.

Before pr would attempt to write pages, thus if a page
boundary was reached, the output looked confusing as one
couldn't see there was a new page and the alphabetical
order was disrupted when scanning down one of the columns.

Fixes output for sizes with width < column width, too.

Fixes part of ticket #5680

Signed-off-by: Alexander Strasser <eclipse7 at gmx.net>
---
 configure | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index b122b27268..81e3776060 100755
--- a/configure
+++ b/configure
@@ -3831,8 +3831,22 @@ die_unknown(){
 }

 print_in_columns() {
-    cols=$(expr $ncols / 24)
-    cat | tr ' ' '\n' | sort | pr -r "-$cols" -w $ncols -t
+    tr ' ' '\n' | sort | tr '\r\n' '  ' | awk -v col_width=24 -v width="$ncols" '
+    {
+        num_cols = width > col_width ? int(width / col_width) : 1;
+        num_rows = int((NF + num_cols-1) / num_cols);
+        y = x = 1;
+        for (y = 1; y <= num_rows; y++) {
+            i = y;
+            for (x = 1; x <= num_cols; x++) {
+                if (i <= NF) {
+                  line = sprintf("%s%-24s", line, $i);
+                }
+                i = i + num_rows;
+            }
+            print line; line = "";
+        }
+    }' | sed 's/ *$//'
 }

 show_list() {
--


More information about the ffmpeg-devel mailing list