diff options
author | Andrew G. Morgan <morgan@kernel.org> | 2008-12-03 21:36:47 -0800 |
---|---|---|
committer | Jorge Lucangeli Obes <jorgelo@google.com> | 2015-09-03 14:13:03 -0700 |
commit | 60a0642c3175d9e5c798c9d7c37d91a22083ecd6 (patch) | |
tree | 3da4eaf191dc8448b031bc7cb2a0aa1ea4a6bec2 /libcap | |
parent | b6c694fef78b234e32c6cf65b4e1ae7edd20d93c (diff) | |
download | libcap-60a0642c3175d9e5c798c9d7c37d91a22083ecd6.tar.gz |
Stop using sed for parsing capability.h.
I've had a number of reports that some systems are using really
old versions of sed that don't honor the '\t' for tabs in rules.
Since perl does, we'll use that from here on.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
Diffstat (limited to 'libcap')
-rw-r--r-- | libcap/.gitignore | 2 | ||||
-rw-r--r-- | libcap/Makefile | 14 | ||||
-rw-r--r-- | libcap/_makenames.c | 2 |
3 files changed, 9 insertions, 9 deletions
diff --git a/libcap/.gitignore b/libcap/.gitignore index 9fc5e1d..34cc5d6 100644 --- a/libcap/.gitignore +++ b/libcap/.gitignore @@ -1,5 +1,5 @@ cap_names.h -cap_names.sed +cap_names.list.h _caps_output.gperf libcap.a libcap.so* diff --git a/libcap/Makefile b/libcap/Makefile index a47e672..8a61752 100644 --- a/libcap/Makefile +++ b/libcap/Makefile @@ -32,18 +32,18 @@ USE_GPERF_OUTPUT = $(GPERF_OUTPUT) INCLUDE_GPERF_OUTPUT = -include $(GPERF_OUTPUT) endif -_makenames: _makenames.c cap_names.sed +_makenames: _makenames.c cap_names.list.h $(BUILD_CC) $(BUILD_CFLAGS) $< -o $@ cap_names.h: _makenames ./_makenames > cap_names.h -$(GPERF_OUTPUT): cap_names.sed - sed -e 's/[\{\"]//g' -e 's/\}.*//' -e '1istruct __cap_token_s { const char *name; int index; };\n%{\nconst struct __cap_token_s *__cap_lookup_name(const char *, unsigned int);\n%}\n%%' $< | gperf --ignore-case --language=ANSI-C --readonly --null-strings --global-table --hash-function-name=__cap_hash_name --lookup-function-name="__cap_lookup_name" -c -t -m20 $(INDENT) > $@ +$(GPERF_OUTPUT): cap_names.list.h + perl -e 'print "struct __cap_token_s { const char *name; int index; };\n%{\nconst struct __cap_token_s *__cap_lookup_name(const char *, unsigned int);\n%}\n%%\n"; while ($$l = <>) { $$l =~ s/[\{\"]//g; $$l =~ s/\}.*// ; print $$l; }' < $< | gperf --ignore-case --language=ANSI-C --readonly --null-strings --global-table --hash-function-name=__cap_hash_name --lookup-function-name="__cap_lookup_name" -c -t -m20 $(INDENT) > $@ -cap_names.sed: Makefile $(KERNEL_HEADERS)/linux/capability.h - @echo "=> making cap_names.c from <linux/capability.h>" - sed -ne '/^#define[ \t]CAP[_A-Z]\+[ \t]\+[0-9]\+/{s/^#define \([^ \t]*\)[ \t]*\([^ \t]*\)/\{\"\1\",\2\},/;y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/;p;}' < $(KERNEL_HEADERS)/linux/capability.h | fgrep -v 0x > $@ +cap_names.list.h: Makefile $(KERNEL_HEADERS)/linux/capability.h + @echo "=> making $@ from $(KERNEL_HEADERS)/linux/capability.h" + perl -e 'while ($$l=<>) { if ($$l =~ /^\#define[ \t](CAP[_A-Z]+)[ \t]+([0-9]+)\s+$$/) { $$tok=$$1; $$val=$$2; $$tok =~ tr/A-Z/a-z/; print "{\"$$tok\",$$val},\n"; } }' $(KERNEL_HEADERS)/linux/capability.h | fgrep -v 0x > $@ $(STALIBNAME): $(OBJS) $(AR) rcs $@ $^ @@ -75,5 +75,5 @@ endif clean: $(LOCALCLEAN) rm -f $(OBJS) $(LIBNAME)* $(STALIBNAME) - rm -f cap_names.h cap_names.sed _makenames $(GPERF_OUTPUT) + rm -f cap_names.h cap_names.list.h _makenames $(GPERF_OUTPUT) cd include/sys && $(LOCALCLEAN) diff --git a/libcap/_makenames.c b/libcap/_makenames.c index 4e8939e..8cc819b 100644 --- a/libcap/_makenames.c +++ b/libcap/_makenames.c @@ -17,7 +17,7 @@ struct { const char *name; int index; } const list[] = { -#include "cap_names.sed" +#include "cap_names.list.h" {NULL, -1} }; |