]> granicus.if.org Git - strace/commitdiff
ioctlent.sh: sync lookup regexps that are used in grep and sed
authorDmitry V. Levin <ldv@altlinux.org>
Fri, 16 Jan 2015 19:59:21 +0000 (19:59 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 16 Jan 2015 20:20:38 +0000 (20:20 +0000)
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.

linux/ioctlent.sh

index e2830698d3781e4d46010a85aed9a56577e7e434..10b7fb9e18cc17cf452e58b60ebd43c8281bbc65 100755 (executable)
@@ -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