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

Submitted by Guo, Yejun on April 15, 2019, 1:23 p.m.

Details

Message ID 1555334611-18069-1-git-send-email-yejun.guo@intel.com
State New
Headers show

Commit Message

Guo, Yejun April 15, 2019, 1:23 p.m.
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.

Signed-off-by: Guo, Yejun <yejun.guo@intel.com>
---
 configure | 34 +++++++++++++++++++++++++---------
 1 file changed, 25 insertions(+), 9 deletions(-)

Patch hide | download patch | download mbox

diff --git a/configure b/configure
index c2580b3..45a9126 100755
--- a/configure
+++ b/configure
@@ -3830,14 +3830,30 @@  die_unknown(){
 }
 
 print_in_columns() {
-    cols=$(expr $ncols / 24)
-    cat | tr ' ' '\n' | sort | pr -r "-$cols" -w $ncols -t
+    width=24
+    cols=$(expr $ncols / $width)
+    rows=$(expr $(expr $# + $cols - 1) / $cols)
+    eval format="%-${width}s"
+    for row in $(seq 1 $rows); do
+        index=$row
+        line=""
+        lfmt=""
+        for col in $(seq 1 $cols); do
+            if [ $index -le $# ]; then
+                eval item=\$${index}
+                line=$line" "$item
+                lfmt=$lfmt$format
+            fi
+            index=$(expr $index + $rows)
+        done
+        printf "$lfmt\n" $line
+    done
 }
 
 show_list() {
     suffix=_$1
     shift
-    echo $* | sed s/$suffix//g | print_in_columns
+    print_in_columns $(echo $* | sed s/$suffix//g | tr ' ' '\n' | sort)
     exit 0
 }
 
@@ -7118,32 +7134,32 @@  test -n "$random_seed" &&
 echo
 
 echo "External libraries:"
-print_enabled '' $EXTERNAL_LIBRARY_LIST $EXTERNAL_AUTODETECT_LIBRARY_LIST | print_in_columns
+print_in_columns $(print_enabled '' $EXTERNAL_LIBRARY_LIST $EXTERNAL_AUTODETECT_LIBRARY_LIST | tr ' ' '\n' | sort)
 echo
 
 echo "External libraries providing hardware acceleration:"
-print_enabled '' $HWACCEL_LIBRARY_LIST $HWACCEL_AUTODETECT_LIBRARY_LIST | print_in_columns
+print_in_columns $(print_enabled '' $HWACCEL_LIBRARY_LIST $HWACCEL_AUTODETECT_LIBRARY_LIST | tr ' ' '\n' | sort)
 echo
 
 echo "Libraries:"
-print_enabled '' $LIBRARY_LIST | print_in_columns
+print_in_columns $(print_enabled '' $LIBRARY_LIST | tr ' ' '\n' | sort)
 echo
 
 echo "Programs:"
-print_enabled '' $PROGRAM_LIST | print_in_columns
+print_in_columns $(print_enabled '' $PROGRAM_LIST | tr ' ' '\n' | sort)
 echo
 
 for type in decoder encoder hwaccel parser demuxer muxer protocol filter bsf indev outdev; do
     echo "Enabled ${type}s:"
     eval list=\$$(toupper $type)_LIST
-    print_enabled '_*' $list | print_in_columns
+    print_in_columns $(print_enabled '_*' $list | tr ' ' '\n' | sort)
     echo
 done
 
 if test -n "$ignore_tests"; then
     ignore_tests=$(echo $ignore_tests | tr ',' ' ')
     echo "Ignored FATE tests:"
-    echo $ignore_tests | print_in_columns
+    print_in_columns $(echo $ignore_tests | tr ' ' '\n' | sort)
     echo
 fi