aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2017-10-08 19:35:08 -0400
committerGitHub <noreply@github.com>2017-10-08 19:35:08 -0400
commitedafc021bc516c20df43c2b783dc9e52f79687a9 (patch)
tree0997d66c51389fb19fbbe08d0e1eb266baeac8df
parent39fd218443dae6d6c81713b2f85ead3e9e1c3ea1 (diff)
parentbb10f21601d0ae76642c31196efae4514e85ce03 (diff)
Merge pull request #247 from ascent12/dash-fix
Fix glgen to be more POSIX corformant
-rwxr-xr-xglgen.sh35
1 files changed, 23 insertions, 12 deletions
diff --git a/glgen.sh b/glgen.sh
index d9de6f9f..75d93c3b 100755
--- a/glgen.sh
+++ b/glgen.sh
@@ -30,28 +30,36 @@ CHECK_FMT='if (!%s) {
}'
while read -r COMMAND; do
- [ ${COMMAND::1} = "-" ]
- OPTIONAL=$?
+ OPTIONAL=0
+ FUNC_PTR_FMT='PFN%sPROC'
- COMMAND=${COMMAND#-}
- if [ ${COMMAND: -2} = "WL" ]; then
+ case $COMMAND in
+ -*)
+ OPTIONAL=1
+ ;;
+ esac
+
+ case $COMMAND in
+ *WL)
FUNC_PTR_FMT='PFN%s'
- else
- FUNC_PTR_FMT='PFN%sPROC'
- fi
+ ;;
+ esac
+ COMMAND=${COMMAND#-}
FUNC_PTR=$(printf "$FUNC_PTR_FMT" "$COMMAND" | tr [:lower:] [:upper:])
DECL="$DECL$(printf "\n$DECL_FMT" "$FUNC_PTR" "$COMMAND")"
DEFN="$DEFN$(printf "\n$DEFN_FMT" "$FUNC_PTR" "$COMMAND")"
LOADER="$LOADER$(printf "\n$LOADER_FMT" "$COMMAND" "$FUNC_PTR" "$COMMAND")"
- if [ $OPTIONAL -ne 0 ]; then
+ if [ $OPTIONAL -eq 0 ]; then
LOADER="$LOADER$(printf "\n$CHECK_FMT" "$COMMAND" "$COMMAND")"
fi
done < $SPEC
-if [ ${OUT: -2} = '.h' ]; then
+
+case $OUT in
+*.h)
cat > $OUT << EOF
#ifndef $INCLUDE_GUARD
#define $INCLUDE_GUARD
@@ -69,7 +77,8 @@ if [ ${OUT: -2} = '.h' ]; then
#endif
EOF
-elif [ ${OUT: -2} = '.c' ]; then
+ ;;
+*.c)
cat > $OUT << EOF
#include <wlr/util/log.h>
#include "$BASE.h"
@@ -86,6 +95,8 @@ elif [ ${OUT: -2} = '.c' ]; then
return true;
}
EOF
-else
+ ;;
+*)
exit 1
-fi
+ ;;
+esac