From patchwork Wed Apr 24 13:12:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Guo, Yejun" X-Patchwork-Id: 12890 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 9A74B44872C for ; Wed, 24 Apr 2019 16:13:04 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7A193689741; Wed, 24 Apr 2019 16:13:04 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9C1956882B3 for ; Wed, 24 Apr 2019 16:12:58 +0300 (EEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Apr 2019 06:12:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,389,1549958400"; d="scan'208";a="143222766" Received: from yguo18-skl-u1604.sh.intel.com ([10.239.13.25]) by fmsmga008.fm.intel.com with ESMTP; 24 Apr 2019 06:12:55 -0700 From: "Guo, Yejun" To: ffmpeg-devel@ffmpeg.org Date: Wed, 24 Apr 2019 21:12:53 +0800 Message-Id: <1556111573-3100-1-git-send-email-yejun.guo@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [FFmpeg-devel] [PATCH V5 1/2] configure: sort decoder/encoder/filter/... names in alphabet order X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: yejun.guo@intel.com MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 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 contributor: avih Signed-off-by: Guo, Yejun --- configure | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 3b11ffe..ad1b183 100755 --- a/configure +++ b/configure @@ -3832,8 +3832,30 @@ die_unknown(){ } print_in_columns() { - cols=$(expr $ncols / 24) - cat | tr ' ' '\n' | sort | pr -r "-$cols" -w $ncols -t + # the input should not contain chars such as '*', + # otherwise, '*' will be expanded to be all files in the current + # working directory which don't begin with a dot (`.`) + set -- $(tr ' ' '\n' | sort) + col_width=24 + if [ $ncols -lt $col_width ]; then + col_width=$ncols + fi + cols=$(($ncols / $col_width)) + rows=$(($(($# + $cols - 1)) / $cols)) + cols_seq=$(seq $cols) + rows_seq=$(seq $rows) + for row in $rows_seq; do + print_index=$row + print_line="" + for col in $cols_seq; do + if [ $print_index -le $# ]; then + eval print_line='"$print_line "${'$print_index'}' + fi + print_index=$(($print_index + $rows)) + done + printf "%-${col_width}s" $print_line + printf "\n" + done | sed 's/ *$//' } show_list() {