From: Eugene Syromyatnikov Date: Tue, 5 Feb 2019 23:49:47 +0000 (+0100) Subject: xlat/gen.sh: speedup, part 3 X-Git-Tag: v5.0~39 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=85848755aa409ab9dd6f63f1772e21371ec45e18;p=strace xlat/gen.sh: speedup, part 3 * xlat/gen.sh (cond_def): Use parameter substitution instead of sed for xlat line parsing. Co-Authored-by: Dmitry V. Levin --- diff --git a/xlat/gen.sh b/xlat/gen.sh index 05527a93..0a9c9736 100755 --- a/xlat/gen.sh +++ b/xlat/gen.sh @@ -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" \