aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2022-07-27 09:57:18 +0200
committerMattias Andrée <maandree@kth.se>2022-07-27 09:57:18 +0200
commitd3e8e1963741c5f0596db9a571969f169b88e427 (patch)
tree0d3c4d1fcbe281affa34586de96358d044c38660
parentFix button and axis names (diff)
downloadlibgamepad-d3e8e1963741c5f0596db9a571969f169b88e427.tar.gz
libgamepad-d3e8e1963741c5f0596db9a571969f169b88e427.tar.bz2
libgamepad-d3e8e1963741c5f0596db9a571969f169b88e427.tar.xz
names.sh: improve readability
Signed-off-by: Mattias Andrée <maandree@kth.se>
-rwxr-xr-xnames.sh31
1 files changed, 26 insertions, 5 deletions
diff --git a/names.sh b/names.sh
index a4d1eed..75bf885 100755
--- a/names.sh
+++ b/names.sh
@@ -3,14 +3,35 @@
format="$1"
shift 1
-prefix="$(printf '%s\\|' "$@" | sed 's/..$//')"
+prefix="$(
+ printf '%s\\|' "$@" |
+ sed 's/..$//'
+)"
-definitions_with_max="$(sed -n 's/^\s*#\s*define\s\+\(\('"$prefix"'\)_[A-Za-z0-9_]*\)\s\+\(0[xX][0-9A-Fa-f]\+\|[0-9]\+\)\(.*\)$/\3 \1/p')"
+definitions_with_max="$(
+ sed -n 's/^\s*#\s*define\s\+\(\('"$prefix"'\)_[A-Za-z0-9_]*\)\s\+\(0[xX][0-9A-Fa-f]\+\|[0-9]\+\)\(.*\)$/\3 \1/p'
+)"
-definitions="$(printf '%s\n' "$definitions_with_max" | sed '/ \('"$prefix"'\)_MAX$/d')"
-max=$(printf '%u\n' $(printf '%s\n' "$definitions_with_max" | sed -n 's/^\(.*\) \('"$prefix"'\)_MAX$/\1/p'))
+definitions="$(
+ printf '%s\n' "$definitions_with_max" |
+ sed '/ \('"$prefix"'\)_MAX$/d'
+)"
-nonunique="$(printf '%s\n' "$definitions" | while read num name; do printf '0x%08X\n' $num; done | sort | uniq -d)"
+max=$(
+ printf '%u\n' $(
+ printf '%s\n' "$definitions_with_max" |
+ sed -n 's/^\(.*\) \('"$prefix"'\)_MAX$/\1/p'
+ )
+)
+
+nonunique="$(
+ printf '%s\n' "$definitions" |
+ while read num name; do
+ printf '0x%08X\n' $num
+ done |
+ sort |
+ uniq -d
+)"
printf '%s\n' "$definitions" |
while read line; do