]> granicus.if.org Git - strace/commitdiff
xlat/gen.sh: speedup, part 3
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_def): Use parameter substitution instead of sed
for xlat line parsing.

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

index 05527a93227779d4b14c519084002dd839db336f..0a9c97363cd4a6f3e1f7b8707a7835b3c3608c37 100755 (executable)
@@ -26,12 +26,16 @@ cond_def()
        line="$1"; shift
 
        local val
-       val="$(printf %s "$line" |
-               sed -r -n 's/^([[:alpha:]_][[:alnum:]_]*).*$/\1/p')"
-
-       local def
-       def="$(printf %s "${line}" |
-               sed -r -n 's/^[^[:space:]]+[[:space:]]+([^[:space:]].*)$/\1/p')"
+       val="${line%%[!A-Za-z0-9_]*}"
+
+       local t def=
+       t="${line#*[     ]}"
+       if [ "$line" != "$t" ]; then
+               while [ "$def" != "$t" ]; do
+                       def="$t"
+                       t="${t##[        ]}"
+               done
+       fi
 
        if [ -n "$def" ]; then
                printf "%s\n" \