[FFmpeg-devel] configure: sort decoder/encoder/filter/... names in alphabet order, row by row

Submitted by Guo, Yejun on April 12, 2019, 1:24 p.m.

Details

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

Commit Message

Guo, Yejun April 12, 2019, 1:24 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, row by row.

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

Comments

Guo, Yejun April 15, 2019, 4:09 a.m.
> -----Original Message-----
> From: Guo, Yejun
> Sent: Friday, April 12, 2019 9:24 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Guo, Yejun <yejun.guo@intel.com>
> Subject: [PATCH] configure: sort decoder/encoder/filter/... names in
> alphabet order, row by row
> 
> 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, row by row.

I got an idea to print the names with printf, still column by column, very similar with 'pr -l',
will send out the new patch soon.

Patch hide | download patch | download mbox

diff --git a/configure b/configure
index f6123f5..2666b4d 100755
--- a/configure
+++ b/configure
@@ -3828,8 +3828,13 @@  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)
+    eval format="%-${width}s"
+    content=$(cat | tr ' ' '\n' | sort)
+    count=$(echo $content | wc -w)
+    pfmt=$(for c in $(seq 1 $count); do printf '%s' $format; [ $(($c % $cols)) -eq 0 -o $c -eq $count ] && printf '\\n'; done)
+    printf "$pfmt" $(echo $content)
 }
 
 show_list() {