]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
all_syscalls: use sed to extract defines from headers
authorThomas Weißschuh <thomas@t-8ch.de>
Tue, 16 Apr 2024 19:56:22 +0000 (21:56 +0200)
committerThomas Weißschuh <thomas@t-8ch.de>
Thu, 18 Apr 2024 08:00:49 +0000 (10:00 +0200)
Posix-compliant awk does not seem capable of matching lines and
extracting capture groups of them.
Use sed instead.

Reported-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Link: https://lore.kernel.org/util-linux/051624b9256db27a731d62c031cb627d9f5a256e.camel@physik.fu-berlin.de/
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
(cherry picked from commit 7e8bf34a2a54b639d95c51a4a0368b0c9578d612)

configure.ac
meson.build
misc-utils/Makemodule.am
tools/all_syscalls

index ef85a7ade68c93247f025e250f82e2579fe018db..0e51e7cad31bf4b181358c05c1989a065ca6e44b 100644 (file)
@@ -132,7 +132,7 @@ AC_PROG_CC
 AM_PROG_CC_C_O
 AC_PROG_MKDIR_P
 AC_PROG_YACC
-AC_PROG_AWK
+AC_PROG_SED
 
 # Don't use autotools integrated LEX/YACC support for libsmartcols
 AC_PATH_PROG([FLEX], [flex])
index 844cde141d56c5e778b82e054176660b076dc28e..24dbe7514556ac0c5913e1f72b3355f9fab6d5fc 100644 (file)
@@ -895,7 +895,7 @@ conf.set('USE_TTY_GROUP', have ? 1 : false)
 
 bison = find_program('bison')
 flex = find_program('flex')
-awk = find_program('gawk', 'mawk', 'nawk', 'awk')
+sed = find_program('sed')
 
 build_hwclock = not get_option('build-hwclock').disabled()
 bison_gen = generator(
@@ -3035,7 +3035,7 @@ endif
 syscalls_h = custom_target('syscalls.h',
   input : 'tools/all_syscalls',
   output : 'syscalls.h',
-  command : ['tools/all_syscalls', awk.full_path(),
+  command : ['tools/all_syscalls', sed.full_path(),
              cc.cmd_array(), get_option('c_args')],
 )
 
index 3763fa9c266a91ae84841969ff78912bd6cd3dc9..6104c648aea4fb8aea3efe4ea95f3f7c48fb40db 100644 (file)
@@ -326,7 +326,7 @@ misc-utils/enosys.c: syscalls.h
 
 syscalls.h: $(top_srcdir)/tools/all_syscalls
        @echo '  GEN      $@'
-       @$(top_srcdir)/tools/all_syscalls "$(AWK)" $(CC) $(CFLAGS)
+       @$(top_srcdir)/tools/all_syscalls "$(SED)" $(CC) $(CFLAGS)
 
 -include syscalls.h.deps
 CLEANFILES += syscalls.h syscalls.h.deps
index 15984e52878f090cf1dd0cdf23864f87dfc52f89..eccb0d0555d15bf0a6772891cb3b921fc79cfa9e 100755 (executable)
@@ -3,7 +3,7 @@
 set -e
 set -o pipefail
 
-AWK="$1"
+SED="$1"
 shift
 OUTPUT=syscalls.h
 SYSCALL_INCLUDES="
@@ -13,6 +13,6 @@ SYSCALL_INCLUDES="
 trap 'rm -f $OUTPUT $OUTPUT.deps' ERR
 
 "$@" -MD -MF "$OUTPUT.deps" <<< "$SYSCALL_INCLUDES" -dM -E - \
-       | "$AWK" 'match($0, /^#define __NR_([^ ]+)/, res) { print "UL_SYSCALL(\"" res[1] "\", __NR_" res[1] ")" }' \
+       | "$SED" -n -e 's/^#define __NR_\([^ ]*\).*$/UL_SYSCALL("\1", __NR_\1)/p' \
        | sort \
        > "$OUTPUT"