]> granicus.if.org Git - strace/commitdiff
xlat/gen.sh: speedup, part 4
authorEugene Syromyatnikov <evgsyr@gmail.com>
Tue, 5 Feb 2019 23:49:47 +0000 (00:49 +0100)
committerDmitry V. Levin <ldv@altlinux.org>
Sun, 24 Feb 2019 23:37:00 +0000 (23:37 +0000)
* xlat/gen.sh (cond_xlat): Use read instead of sed for xlat entry
parsing.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
xlat/gen.sh

index 0a9c97363cd4a6f3e1f7b8707a7835b3c3608c37..9a9d6222445ae42bbeb66a48ca35945213e009c8 100755 (executable)
@@ -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()