aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott James Remnant <keybuk@google.com>2015-10-12 15:14:06 -0700
committerScott James Remnant <keybuk@google.com>2015-10-12 15:14:06 -0700
commit33df0e342c7d49bb917157cb939cf0ab4a3b7d66 (patch)
treeb9447726bcbb0c814ab030319ed9d19e48ac2619
parent68db15cc2ea5b8314b4c8f7f3920423aeb5e25eb (diff)
downloadminijail-33df0e342c7d49bb917157cb939cf0ab4a3b7d66.tar.gz
minijail: fix gen_constants to be portable
Move the sed expression outside of the inline shell expression and replace \n with newlines so that newlines appear in the result; also replace non-portable use of \+ with * using the same match expression as is used in the command sequence for 'grep' anyway. BUG=24873059 Change-Id: I45e0f2252a3a91e6c8e18643a68aab8e78e0fcdd
-rwxr-xr-xgen_constants.sh12
1 files changed, 11 insertions, 1 deletions
diff --git a/gen_constants.sh b/gen_constants.sh
index 0ad29ba..5175d15 100755
--- a/gen_constants.sh
+++ b/gen_constants.sh
@@ -33,6 +33,16 @@ INCLUDES='
#include <sys/stat.h>
#include <sys/types.h>'
+# sed expression which extracts constants and converts them from:
+# #define AT_FDWCD foo
+# to:
+# #ifdef AT_FDCWD
+# { "AT_FDWCD", AT_FDCWD },
+# endif
+SED_MULTILINE='s/#define \([A-Z][A-Z0-9_]*\).*/#ifdef \1\
+ { "\1", \1 },\
+#endif \/\/ \1/'
+
# Passes the previous list of #includes to the C preprocessor and prints out
# all #defines whose name is all-caps. Excludes a few symbols that are known
# macro functions that don't evaluate to a constant.
@@ -48,7 +58,7 @@ $(echo "$INCLUDES" | \
grep -v '\(SIGRTMAX\|SIGRTMIN\|SIG_\|NULL\)' | \
sort | \
uniq | \
- sed -e 's/#define \([A-Z0-9_]\+\).*$/#ifdef \1\n { "\1", \1 },\n#endif \/\/ \1/')
+ sed -e "${SED_MULTILINE}")
{ NULL, 0 },
};
EOF