aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-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