From: Dmitry V. Levin Date: Fri, 25 Apr 2014 23:04:13 +0000 (+0000) Subject: Enhance xlat generator X-Git-Tag: v4.9~69 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5153b5cd681a4091d378883d06291b5bcb963e69;p=strace Enhance xlat generator * xlat/gen.sh: Define all xlat structs not declared in defs.h as static. Some symbolic constants are not macros, extend #ifdef check to cover symbolic constants checked by AC_CHECK_DECLS. Handle complex symbolic constants in SYMBOL|... form. Handle symbolic constants in 1< /dev/null; then + prefix= + else + prefix='static ' + fi + + cat <<-EOF + /* Generated by $0 from $1; do not edit. */ + + ${prefix}const struct xlat ${name}[] = { + EOF + local unconditional= unterminated= line + while read line; do + LC_COLLATE=C case ${line} in - /*|\#*|'') - echo "${line}" + '#unconditional') + unconditional=1 + ;; + '#unterminated') + unterminated=1 ;; - *) - echo "#ifdef ${line}" + [A-Z_]*) # symbolic constants + local m="${line%%|*}" + [ -n "${unconditional}" ] || + echo "#if defined(${m}) || (defined(HAVE_DECL_${m}) && HAVE_DECL_${m})" echo " XLAT(${line})," - echo "#endif" + [ -n "${unconditional}" ] || + echo "#endif" + ;; + '1<<'[A-Z_]*) # symbolic constants with shift + local m="${line#1<<}" + [ -n "${unconditional}" ] || + echo "#if defined(${m}) || (defined(HAVE_DECL_${m}) && HAVE_DECL_${m})" + echo " { ${line}, \"${m}\" }," + [ -n "${unconditional}" ] || + echo "#endif" + ;; + [0-9]*) # numeric constants + echo " XLAT(${line})," + ;; + *) # verbatim lines + echo "${line}" ;; esac done < "${input}" - echo " XLAT_END" + if [ -n "${unterminated}" ]; then + echo " /* this array should remain not NULL-terminated */" + else + echo " XLAT_END" + fi echo "};" ) >"${output}" } @@ -76,8 +112,9 @@ main() { local name if [ -d "${input}" ]; then - local f name names + local f names= for f in "${input}"/*.in; do + [ -f "${f}" ] || continue name=${f##*/} name=${name%.in} gen_header "${f}" "${output}/${name}.h" "${name}" &