mirror of
https://codeberg.org/kiss-community/repo
synced 2024-12-25 16:50:07 -07:00
76 lines
2.7 KiB
Diff
76 lines
2.7 KiB
Diff
From: Alexander Strasser <eclipse7@gmx.net>
|
|
Date: Sat, 27 Apr 2019 21:15:08 +0000 (+0200)
|
|
Subject: configure: print_in_columns: Replace pr with awk
|
|
X-Git-Url: http://git.videolan.org/?p=ffmpeg.git;a=commitdiff_plain;h=99147312ce6ffd3a3b70e10aacc9b64a63b6aefe
|
|
|
|
configure: print_in_columns: Replace pr with awk
|
|
|
|
Get rid of pr dependency and write the columns strictly
|
|
alphabetical without page size considerations (POSIX
|
|
specifies 66 lines as default).
|
|
|
|
Setting the page size via pr's -l option was considered,
|
|
but as there is issue #5680 which wants to avoid pr
|
|
mainly because it's not in busybox, we chose to replace
|
|
pr instead.
|
|
|
|
Before pr would attempt to write pages, thus if a page
|
|
boundary was reached, the output looked confusing as one
|
|
couldn't see there was a new page and the alphabetical
|
|
order was disrupted when scanning down one of the columns.
|
|
|
|
This change is based on a shell implementation submitted
|
|
before by Yejun.
|
|
|
|
Possible differences to the current version using pr:
|
|
1. pr implementations should truncate items to not overflow columns;
|
|
depending on how it's done not truncating shall be better IMHO.
|
|
2. pr implementations might balance columns differently;
|
|
we use minimum number of lines and might end up not
|
|
using all columns or might have lesser entries in the
|
|
last column(s)
|
|
3. we use spaces only for padding the columns; at least the GNU pr
|
|
version on my system also by default stuffs in tabs in addition
|
|
to a single space in between columns. I don't see that this
|
|
behaviour is demanded by POSIX, though I might be very well
|
|
overlooking things. Anyway for our use case I can't see a need
|
|
for having the additional tabs, or why it would be better compared
|
|
to padding with spaces only.
|
|
|
|
Fixes output for sizes with width < column width, too.
|
|
|
|
Fixes remaining part of ticket #5680
|
|
|
|
Contributor: Guo, Yejun <yejun.guo@intel.com>
|
|
---
|
|
|
|
diff --git a/configure b/configure
|
|
index d885690369..7cea9d4d73 100755
|
|
--- a/configure
|
|
+++ b/configure
|
|
@@ -3843,8 +3843,22 @@ die_unknown(){
|
|
}
|
|
|
|
print_in_columns() {
|
|
- cols=$(expr $ncols / 24)
|
|
- cat | tr ' ' '\n' | sort | pr -r "-$cols" -w $ncols -t
|
|
+ tr ' ' '\n' | sort | tr '\r\n' ' ' | awk -v col_width=24 -v width="$ncols" '
|
|
+ {
|
|
+ num_cols = width > col_width ? int(width / col_width) : 1;
|
|
+ num_rows = int((NF + num_cols-1) / num_cols);
|
|
+ y = x = 1;
|
|
+ for (y = 1; y <= num_rows; y++) {
|
|
+ i = y;
|
|
+ for (x = 1; x <= num_cols; x++) {
|
|
+ if (i <= NF) {
|
|
+ line = sprintf("%s%-" col_width "s", line, $i);
|
|
+ }
|
|
+ i = i + num_rows;
|
|
+ }
|
|
+ print line; line = "";
|
|
+ }
|
|
+ }' | sed 's/ *$//'
|
|
}
|
|
|
|
show_list() {
|