diff options
author | Mattias Andrée <maandree@kth.se> | 2023-12-07 22:51:52 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2023-12-07 22:51:52 +0100 |
commit | 9f449569df9c94670f51fd8cd5558b66884cd877 (patch) | |
tree | 21d3c31e22b2cd0544351584c8614e70b66826e4 /util | |
parent | Fourth commit (diff) | |
download | libsyscalls-9f449569df9c94670f51fd8cd5558b66884cd877.tar.gz libsyscalls-9f449569df9c94670f51fd8cd5558b66884cd877.tar.bz2 libsyscalls-9f449569df9c94670f51fd8cd5558b66884cd877.tar.xz |
Improve portability
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'util')
-rwxr-xr-x | util/getdefs | 12 | ||||
-rwxr-xr-x | util/getenum | 4 |
2 files changed, 8 insertions, 8 deletions
diff --git a/util/getdefs b/util/getdefs index 43c0d0d..aa06947 100755 --- a/util/getdefs +++ b/util/getdefs @@ -5,20 +5,20 @@ set -e text="$(cat)" -expr='\(0x[0-9a-fA-F]\+\|[0-9]\+\)[Ll]*[Uu]*[Ll]*' -expr='\(\*\|\/\|[+~-]\|<<\|>>\)\?\s*'"$expr" +expr='\(0x[0-9a-fA-F]\{1,\}\|[0-9]\{1,\}\)[Ll]*[Uu]*[Ll]*' +expr='\(\*\|\/\|[+~-]\|<<\|>>\)\{0,1\}[[:space:]]*'"$expr" expr='\('"$expr"'\|(\|)\)' -expr='\s*\('"$expr"'\s*\)\+' +expr='[[:space:]]*\('"$expr"'[[:space:]]*\)\{1,\}' filter () { - sed -n 's/^\s*#\s*define\s\+\('"$1"'\)\s\+\('"$expr"'\)\s*\(\/.*\)\?$/\1 \2/p' + sed -n 's/^[[:space:]]*#[[:space:]]*define[[:space:]]\{1,\}\('"$1"'\)[[:space:]]\{1,\}\('"$expr"'\)[[:space:]]*\(\/.*\)\{0,1\}$/\1 \2/p' } if test $# = 0; then - printf '%s\n' "$text" | filter '[A-Z0-9_]\+' + printf '%s\n' "$text" | filter '[A-Z0-9_]\{1,\}' else for prefix; do - printf '%s\n' "$text" | filter "$prefix"'_[A-Z0-9_]\+' + printf '%s\n' "$text" | filter "$prefix"'_[A-Z0-9_]\{1,\}' done fi | \ while read name value; do diff --git a/util/getenum b/util/getenum index 343ce76..b28236a 100755 --- a/util/getenum +++ b/util/getenum @@ -3,9 +3,9 @@ set -e -sed '1,/^\s*enum\s\+'"$1"'\b/d' | \ +sed '1,/^[[:space:]]*enum[[:space:]]\{1,\}'"$1"'\([^A-Za-z0-9_]\|$\)/d' | \ tr '\n' '\0' | cut -d \; -f 1 | tr '\0' '\n' | \ -sed -n 's/^\s*\([A-Z0-9_]\+\)\(\s*=[^,]*\)\?\s*,\?\s*\(\/.*\)\?/\1\2/p' | \ +sed -n 's/^[[:space:]]*\([A-Z0-9_]\{1,\}\)\([[:space:]]*=[^,]*\)\{0,1\}[[:space:]]*,\{0,1\}[[:space:]]*\(\/.*\)\{0,1\}/\1\2/p' | \ sed 's/=/ /g' | \ ( prev=-1 |