aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Weißschuh <thomas@t-8ch.de>2024-04-16 21:56:22 +0200
committerThomas Weißschuh <thomas@t-8ch.de>2024-04-16 21:56:22 +0200
commit7e8bf34a2a54b639d95c51a4a0368b0c9578d612 (patch)
treee18c268319b52f98a4841bc7d7e7f4eeaad16e7a
parentb51014a854134ef026de6049a331fa2cf9453015 (diff)
downloadutil-linux-7e8bf34a2a54b639d95c51a4a0368b0c9578d612.tar.gz
all_errnos/all_syscalls: use sed to extract defines from headers
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>
-rw-r--r--configure.ac2
-rw-r--r--meson.build6
-rw-r--r--misc-utils/Makemodule.am4
-rwxr-xr-xtools/all_errnos4
-rwxr-xr-xtools/all_syscalls4
5 files changed, 10 insertions, 10 deletions
diff --git a/configure.ac b/configure.ac
index 6293eb8528..1d7a9cf70a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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])
diff --git a/meson.build b/meson.build
index 9476ec2dee..6a3fe48819 100644
--- a/meson.build
+++ b/meson.build
@@ -904,7 +904,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(
@@ -2777,7 +2777,7 @@ endif
errnos_h = custom_target('errnos.h',
input : 'tools/all_errnos',
output : 'errnos.h',
- command : ['tools/all_errnos', awk.full_path(),
+ command : ['tools/all_errnos', sed.full_path(),
cc.cmd_array(), get_option('c_args')],
)
@@ -3095,7 +3095,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')],
)
diff --git a/misc-utils/Makemodule.am b/misc-utils/Makemodule.am
index 841275eb6e..b3dbd58959 100644
--- a/misc-utils/Makemodule.am
+++ b/misc-utils/Makemodule.am
@@ -1,6 +1,6 @@
errnos.h: $(top_srcdir)/tools/all_errnos
@echo ' GEN $@'
- @$(top_srcdir)/tools/all_errnos "$(AWK)" $(CC) $(CFLAGS)
+ @$(top_srcdir)/tools/all_errnos "$(SED)" $(CC) $(CFLAGS)
-include errnos.h.deps
CLEANFILES += errnos.h errnos.h.deps
@@ -338,7 +338,7 @@ misc-utils/enosys.c: syscalls.h errnos.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
diff --git a/tools/all_errnos b/tools/all_errnos
index 137713d401..a009cfc0ef 100755
--- a/tools/all_errnos
+++ b/tools/all_errnos
@@ -5,7 +5,7 @@
set -e
set -o pipefail
-AWK="$1"
+SED="$1"
shift
OUTPUT=errnos.h
ERRNO_INCLUDES="
@@ -15,6 +15,6 @@ ERRNO_INCLUDES="
trap 'rm -f $OUTPUT $OUTPUT.deps' ERR
"$@" -MD -MF "$OUTPUT.deps" <<< "$ERRNO_INCLUDES" -dM -E - \
- | "$AWK" 'match($0, /^#[ \t]*define[ \t]*E([^ ]+)/, res) { print "UL_ERRNO(\"E" res[1] "\", E" res[1] ")" }' \
+ | "$SED" -n -e 's/^[ \t]*#define[ \t]*E\([^ ]*\).*$/UL_ERRNO("E\1", E\1)/p' \
| sort \
> "$OUTPUT"
diff --git a/tools/all_syscalls b/tools/all_syscalls
index 15984e5287..eccb0d0555 100755
--- a/tools/all_syscalls
+++ b/tools/all_syscalls
@@ -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"