From 50b320952e99ea20f9b77c6c501280fe37fd2598 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Wed, 15 Apr 2020 14:10:08 +0900 Subject: [PATCH] regexp: Fix generation of _unicode_mapping.c. * configure.ac (AWK_HEX_NUMBER_OPTION): Detect GNU Awk. * regexp/Makefile.am: Use AWK_HEX_NUMBER_OPTION. * regexp/parse-unidata.awk: Don't use strtonum. GnuPG-bug-id: 4915 Signed-off-by: NIIBE Yutaka --- configure.ac | 10 ++++++++++ regexp/Makefile.am | 3 ++- regexp/parse-unidata.awk | 6 +++--- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index 917420e35..9eb25bd02 100644 --- a/configure.ac +++ b/configure.ac @@ -633,6 +633,16 @@ AC_ISC_POSIX AC_SYS_LARGEFILE +# GNU AWK requires -n option to interpret "0xHH" as a number +if $AWK 'BEGIN { if (PROCINFO@<:@"version"@:>@) exit 1 }'; then + AWK_HEX_NUMBER_OPTION='' + AC_MSG_NOTICE([awk with no option for hexadecimal]) +else + AWK_HEX_NUMBER_OPTION='-n' + AC_MSG_NOTICE([awk with an option -n for hexadecimal]) +fi +AC_SUBST(AWK_HEX_NUMBER_OPTION) + # We need to compile and run a program on the build machine. A # comment in libgpg-error says that the AC_PROG_CC_FOR_BUILD macro in # the AC archive is broken for autoconf 2.57. Given that there is no diff --git a/regexp/Makefile.am b/regexp/Makefile.am index a4e9fce0b..307aacf9d 100644 --- a/regexp/Makefile.am +++ b/regexp/Makefile.am @@ -34,5 +34,6 @@ BUILT_SOURCES = _unicode_mapping.c MAINTAINERCLEANFILES = _unicode_mapping.c _unicode_mapping.c: parse-unidata.awk UnicodeData.txt - $(AWK) -f $(srcdir)/parse-unidata.awk $(srcdir)/UnicodeData.txt >$@ + $(AWK) $(AWK_HEX_NUMBER_OPTION) -f $(srcdir)/parse-unidata.awk \ + $(srcdir)/UnicodeData.txt >$@ endif diff --git a/regexp/parse-unidata.awk b/regexp/parse-unidata.awk index 8bdc0bf8b..b9ed351ee 100644 --- a/regexp/parse-unidata.awk +++ b/regexp/parse-unidata.awk @@ -32,17 +32,17 @@ BEGIN { } { - code = strtonum(("0x" $1)) + code = int("0x" $1) name = $2 class = $3 upper = $13 lower = $14 title = $15 - if (code <= 0x7f) { + if (code <= 127) { next } - if (code > 0xffff) { + if (code > 65535) { next } if ($3 !~ /^L.*/) {