From 5755dfcb52a92b920683cf200f8716e17c613964 Mon Sep 17 00:00:00 2001 From: Eugene Syromyatnikov Date: Wed, 6 Feb 2019 00:49:47 +0100 Subject: [PATCH] xlat/gen.sh: speedup, part 4 * xlat/gen.sh (cond_xlat): Use read instead of sed for xlat entry parsing. Co-Authored-by: Dmitry V. Levin --- xlat/gen.sh | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/xlat/gen.sh b/xlat/gen.sh index 0a9c9736..9a9d6222 100755 --- a/xlat/gen.sh +++ b/xlat/gen.sh @@ -78,29 +78,29 @@ print_xlat_pair() cond_xlat() { - local line val m def xlat - line="$1"; shift - - val="$(printf %s "${line}" | sed -r -n 's/^([^[:space:]]+).*$/\1/p')" - m="${val%%|*}" - def="$(printf %s "${line}" | - sed -r -n 's/^[^[:space:]]+[[:space:]]+([^[:space:]].*)$/\1/p')" - - if [ "${m}" = "${m#1<<}" ]; then - xlat="$(print_xlat "${val}")" - else - xlat="$(print_xlat_pair "1ULL<<${val#1<<}" "${val}")" - m="${m#1<<}" - fi - - if [ -z "${def}" ]; then - printf "%s\n" \ - "#if defined(${m}) || (defined(HAVE_DECL_${m}) && HAVE_DECL_${m})" \ - " ${xlat}" \ - "#endif" - else - echo "$xlat" - fi + echo "$1" | { + local val def m xlat + + read val def + + m="${val%%|*}" + + if [ "${m}" = "${m#1<<}" ]; then + xlat="$(print_xlat "${val}")" + else + xlat="$(print_xlat_pair "1ULL<<${val#1<<}" "${val}")" + m="${m#1<<}" + fi + + if [ -z "${def}" ]; then + printf "%s\n" \ + "#if defined(${m}) || (defined(HAVE_DECL_${m}) && HAVE_DECL_${m})" \ + " ${xlat}" \ + "#endif" + else + echo "$xlat" + fi + } } gen_header() -- 2.40.0