aboutsummaryrefslogtreecommitdiff
path: root/utils/add_include_guard.sh
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2026-09-17 21:43:45 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2026-09-17 21:43:45 +0200
commitaa306fa0a2047f30d585da7923f963e8d321aa0b (patch)
tree1e847ac8ef87202de83a3578c48c564c188129df /utils/add_include_guard.sh
parent3cb60bcbf4ab9af4e9452a43681f1e7176b0c88f (diff)
downloadnissy-core-aa306fa0a2047f30d585da7923f963e8d321aa0b.tar.gz
nissy-core-aa306fa0a2047f30d585da7923f963e8d321aa0b.zip
Add script for include guards
Diffstat (limited to '')
-rwxr-xr-xutils/add_include_guard.sh15
1 files changed, 15 insertions, 0 deletions
diff --git a/utils/add_include_guard.sh b/utils/add_include_guard.sh
new file mode 100755
index 0000000..7ca10db
--- /dev/null
+++ b/utils/add_include_guard.sh
@@ -0,0 +1,15 @@
1#!/bin/sh
2
3if [ -z "$1" ]; then
4 echo "Usage: $0 [file]"
5 exit 1
6fi
7
8guard="$(echo "$1" | sed 's/^\.\///' | tr 'a-z/.' 'A-Z__')"
9
10new_file="$1.adding_include_guard"
11printf '#ifndef %s\n#define %s\n\n' "$guard" "$guard" > "$new_file"
12cat "$1" >> "$new_file"
13printf '\n#endif /* %s */\n' "$guard" >> "$new_file"
14
15mv "$new_file" "$1"

Generated with cgit - Back to sebastiano.tronto.net