From patchwork Wed Apr 24 13:27:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Guo, Yejun" X-Patchwork-Id: 12883 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 DE3BA44948F for ; Wed, 24 Apr 2019 08:38:43 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B5A3F680352; Wed, 24 Apr 2019 08:38:43 +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 2A0D46802D7 for ; Wed, 24 Apr 2019 08:38:35 +0300 (EEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Apr 2019 22:38:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,388,1549958400"; d="scan'208";a="340275501" Received: from yguo18-skl-u1604.sh.intel.com ([10.239.13.25]) by fmsmga006.fm.intel.com with ESMTP; 23 Apr 2019 22:38:33 -0700 From: "Guo, Yejun" To: ffmpeg-devel@ffmpeg.org Date: Wed, 24 Apr 2019 21:27:33 +0800 Message-Id: <1556112453-20386-1-git-send-email-yejun.guo@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [FFmpeg-devel] [PATCH V4 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 | 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() {