From: Dmitry V. Levin Date: Fri, 16 Jan 2015 19:59:21 +0000 (+0000) Subject: ioctlent.sh: sync lookup regexps that are used in grep and sed X-Git-Tag: v4.10~187 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3d633bd30288e0b8c1032b0a7db528d3f94fb533;p=strace ioctlent.sh: sync lookup regexps that are used in grep and sed ioctlent.sh looks for ioctl command names using grep, and fetches them with their definitions using sed. Historically, lookup regexps used in grep and sed are slightly different, which makes the script more complicated than necessary. --- diff --git a/linux/ioctlent.sh b/linux/ioctlent.sh index e2830698..10b7fb9e 100755 --- a/linux/ioctlent.sh +++ b/linux/ioctlent.sh @@ -46,10 +46,10 @@ lookup_ioctls() shift # Build the list of all ioctls - regexp='^[[:space:]]*#[[:space:]]*define[[:space:]]\+[A-Z][A-Z0-9_]*[[:space:]]\+0x'"$type"'..\>' - (cd "$dir" && for f; do grep "$regexp" "$f" "uapi/$f" 2>/dev/null; done) | - sed -ne "s,$asm/,asm/,g"' -s/^\(.*\):[[:space:]]*#[[:space:]]*define[[:space:]]*\([A-Z0-9_]*\)[[:space:]]*\(0x'"$type"'..\).*/ { "\1", "\2", \3 },/p' \ + regexp='[[:space:]]*#[[:space:]]*define[[:space:]]\+\([A-Z][A-Z0-9_]*\)[[:space:]]\+\(0x'"$type"'..\)\>' + (cd "$dir" && for f; do grep "^$regexp" "$f" "uapi/$f" 2>/dev/null; done) | + sed -n -e "s,$asm/,asm/,g" \ + -e 's/^\([^:]*\):'"$regexp"'.*/ { "\1", "\2", \3 },/p' \ >> ioctls.h } @@ -87,11 +87,10 @@ fi # Example output: # { "asm/ioctls.h", "TIOCSWINSZ", 0x5414 }, # { "asm/mce.h", "MCE_GETCLEAR_FLAGS", _IOC(_IOC_NONE,'M',3,0) }, -regexp='^[[:space:]]*#[[:space:]]*define[[:space:]]\+[A-Z][A-Z0-9_]*[[:space:]]\+_S\?\(IO\|IOW\|IOR\|IOWR\)\>' -(cd $dir && grep $regexp $files 2>/dev/null) | \ - sed -n \ - -e "s,$asm/,asm/,g" \ - -e 's/^\(.*\):[[:space:]]*#[[:space:]]*define[[:space:]]*\([A-Z0-9_]*\)[[:space:]]*_S\?I.*(\([^[,]*\)[[:space:]]*,[[:space:]]*\([^,)]*\).*/ { "\1", "\2", _IOC(_IOC_NONE,\3,\4,0) },/p' \ +regexp='[[:space:]]*#[[:space:]]*define[[:space:]]\+\([A-Z][A-Z0-9_]*\)[[:space:]]\+_S\?\(IO\|IOW\|IOR\|IOWR\)[[:space:]]*(\([^,()]*\)[[:space:]]*,[[:space:]]*\([^,()]*\)[[:space:]]*[,)]' +(cd $dir && grep "^$regexp" $files 2>/dev/null) | \ + sed -n -e "s,$asm/,asm/,g" \ + -e 's/^\([^:]*\):'"$regexp"'.*/ { "\1", "\2", _IOC(_IOC_NONE,\4,\5,0) },/p' \ >> ioctls.h # Strip uapi/ prefix