diff options
author | Mattias Andrée <maandree@kth.se> | 2022-07-27 09:57:18 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2022-07-27 09:57:18 +0200 |
commit | d3e8e1963741c5f0596db9a571969f169b88e427 (patch) | |
tree | 0d3c4d1fcbe281affa34586de96358d044c38660 /names.sh | |
parent | Fix button and axis names (diff) | |
download | libgamepad-d3e8e1963741c5f0596db9a571969f169b88e427.tar.gz libgamepad-d3e8e1963741c5f0596db9a571969f169b88e427.tar.bz2 libgamepad-d3e8e1963741c5f0596db9a571969f169b88e427.tar.xz |
names.sh: improve readability
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'names.sh')
-rwxr-xr-x | names.sh | 31 |
1 files changed, 26 insertions, 5 deletions
@@ -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 |