[FFmpeg-devel] [PATCH V4 1/2] configure: sort decoder/encoder/filter/... names in alphabet order

Guo, Yejun yejun.guo at intel.com
Wed Apr 24 16:27:33 EEST 2019


take decoder names an example, with the default page length, shell command
'pr' needs two pages for all the decoder names. The names are firstly printed
in the first page, then in the second page. So, as a whole, the names are
sorted neither in column order nor in row order. It's a little confused.

One method is to calculate the proper page length, so all the names are printed
in one page by 'pr -l', and so strictly in alphabet order, column by column.

Another method is to use command printf instead of pr, because buybox doesn't
have pr. This patch refines print_in_columns to print the names with printf
in alphabet order, very similar with 'pr -l', except the case when the last
column is not fully filled with names.

contributor: Alexander Strasser <eclipse7 at gmx.net>
contributor: avih <avihpit-at-yahoo.com at ffmpeg.org>
Signed-off-by: Guo, Yejun <yejun.guo at intel.com>
---
 configure | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 3b11ffe..8941063 100755
--- a/configure
+++ b/configure
@@ -3832,8 +3832,25 @@ die_unknown(){
 }
 
 print_in_columns() {
-    cols=$(expr $ncols / 24)
-    cat | tr ' ' '\n' | sort | pr -r "-$cols" -w $ncols -t
+    set -- $(cat | tr ' ' '\n' | sort)
+    col_width=24
+    cols=$(($ncols / $col_width))
+    rows=$(($(($# + $cols - 1)) / $cols))
+    cols_seq=$(seq $cols)
+    rows_seq=$(seq $rows)
+    for row in $rows_seq; do
+        index=$row
+        line=""
+        fmt=""
+        for col in $cols_seq; do
+            if [ $index -le $# ]; then
+                eval line='"$line "${'$index'}'
+                fmt="$fmt%-${col_width}s"
+            fi
+            index=$(($index + $rows))
+        done
+        printf "$fmt\n" $line
+    done | sed 's/ *$//'
 }
 
 show_list() {
-- 
2.7.4



More information about the ffmpeg-devel mailing list