From 3c7daf29b12d5b7709030d4187172378e0d6e91b Mon Sep 17 00:00:00 2001 From: Hans Pabst Date: Fri, 22 Mar 2024 13:55:10 +0100 Subject: [PATCH] ocl: fixed script turning code into embedded resource * Check if include-guard is actually present. --- src/acc/opencl/acc_opencl.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/acc/opencl/acc_opencl.sh b/src/acc/opencl/acc_opencl.sh index a6f9739cf64..d4b793c8b41 100755 --- a/src/acc/opencl/acc_opencl.sh +++ b/src/acc/opencl/acc_opencl.sh @@ -37,7 +37,6 @@ trap_exit() { process_pre() { if [ "$1" ]; then - GUARD=$(${BASENAME} "$1" | ${TR} '[:lower:]' '[:upper:]' | ${TR} '.' '_') if [ "${CPP}" ] && \ [ "$(eval "${CPP} ${CPPBASEFLAGS} $1" 2>/dev/null >/dev/null && echo "YES")" ]; then @@ -51,8 +50,13 @@ process_pre() { else # fallback to sed ${SED} -r ':a;s%(.*)/\*.*\*/%\1%;ta;/\/\*/!b;N;ba' "$1" fi | \ - if [ "${GUARD}" ] && [[ (! "$2" || "0" = "$2") ]]; then # strip include guards - ${SED} "/${GUARD}/d;\${/\s*\#\s*endif/d}" + if [ ! "$2" ] || [ "0" = "$2" ]; then # strip include guards + GUARD=$(${BASENAME} "$1" | ${TR} '[:lower:]' '[:upper:]' | ${TR} '.' '_') + if [ "${GUARD}" ] && [ "$(${SED} -n "/${GUARD}/p" "$1")" ]; then + ${SED} "/${GUARD}/d;\${/\s*\#\s*endif/d}" + else + ${CAT} + fi else ${CAT} fi