xlat/gen.sh: prepare for adding #val_type directive support
This is essentially a no-op change that makes the following change easier to read. * xlat/gen.sh (print_xlat, print_xlat_pair): New functions. (cond_xlat, gen_header): Use them.
This commit is contained in:
parent
0f4982691e
commit
6b040fc505
36
xlat/gen.sh
36
xlat/gen.sh
@ -59,21 +59,39 @@ cond_def()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print_xlat()
|
||||||
|
{
|
||||||
|
local val
|
||||||
|
val="$1"; shift
|
||||||
|
|
||||||
|
echo " XLAT(${val}),"
|
||||||
|
}
|
||||||
|
|
||||||
|
print_xlat_pair()
|
||||||
|
{
|
||||||
|
local val str
|
||||||
|
val="$1"; shift
|
||||||
|
str="$1"; shift
|
||||||
|
|
||||||
|
echo " XLAT_PAIR(${val}, \"${str}\"),"
|
||||||
|
}
|
||||||
|
|
||||||
cond_xlat()
|
cond_xlat()
|
||||||
{
|
{
|
||||||
local line val m def xlat
|
local line val m def xlat str
|
||||||
line="$1"; shift
|
line="$1"; shift
|
||||||
|
str="$1"; shift
|
||||||
|
|
||||||
val="$(printf %s "${line}" | sed -n 's/^\([^[:space:]]\+\).*$/\1/p')"
|
val="$(printf %s "${line}" | sed -n 's/^\([^[:space:]]\+\).*$/\1/p')"
|
||||||
m="${val%%|*}"
|
m="${val%%|*}"
|
||||||
def="$(printf %s "${line}" |
|
def="$(printf %s "${line}" |
|
||||||
sed -n 's/^[^[:space:]]\+[[:space:]]\+\([^[:space:]].*\)$/\1/p')"
|
sed -n 's/^[^[:space:]]\+[[:space:]]\+\([^[:space:]].*\)$/\1/p')"
|
||||||
|
|
||||||
if [ "${m}" = "${m#1<<}" ]; then
|
if [ -z "${str}" ]; then
|
||||||
xlat=" XLAT(${val}),"
|
xlat="$(print_xlat "${val}")"
|
||||||
else
|
else
|
||||||
m="${m#1<<}"
|
m="${m#1<<}"
|
||||||
xlat=" XLAT_PAIR(${val}, \"${m}\"),"
|
xlat="$(print_xlat_pair "${val}" "${str}")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "${def}" ]; then
|
if [ -z "${def}" ]; then
|
||||||
@ -170,20 +188,20 @@ gen_header()
|
|||||||
;;
|
;;
|
||||||
[A-Z_]*) # symbolic constants
|
[A-Z_]*) # symbolic constants
|
||||||
if [ -n "${unconditional}" ]; then
|
if [ -n "${unconditional}" ]; then
|
||||||
echo " XLAT(${line}),"
|
print_xlat "${line}"
|
||||||
else
|
else
|
||||||
cond_xlat "${line}"
|
cond_xlat "${line}" ''
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
'1<<'[A-Z_]*) # symbolic constants with shift
|
'1<<'[A-Z_]*) # symbolic constants with shift
|
||||||
if [ -n "${unconditional}" ]; then
|
if [ -n "${unconditional}" ]; then
|
||||||
echo " XLAT_PAIR(${line}, \"${line#1<<}\"),"
|
print_xlat_pair "${line}" "${line#1<<}"
|
||||||
else
|
else
|
||||||
cond_xlat "${line}"
|
cond_xlat "${line}" "${line#1<<}"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
[0-9]*) # numeric constants
|
[0-9]*) # numeric constants
|
||||||
echo " XLAT(${line}),"
|
print_xlat "${line}"
|
||||||
;;
|
;;
|
||||||
*) # verbatim lines
|
*) # verbatim lines
|
||||||
echo "${line}"
|
echo "${line}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user