diff options
author | netblue30 <netblue30@yahoo.com> | 2020-09-02 16:11:04 -0400 |
---|---|---|
committer | netblue30 <netblue30@yahoo.com> | 2020-09-02 16:11:04 -0400 |
commit | a68725f13c8a28e64d053936eaaa4dd5f5f3922d (patch) | |
tree | fbd1ce9726c225395039a49762168c229d253a31 | |
parent | fix private-bin in smplayer.profile (diff) | |
download | firejail-a68725f13c8a28e64d053936eaaa4dd5f5f3922d.tar.gz firejail-a68725f13c8a28e64d053936eaaa4dd5f5f3922d.tar.zst firejail-a68725f13c8a28e64d053936eaaa4dd5f5f3922d.zip |
bringing in awk preprocessor from rusty-snake
-rw-r--r-- | src/man/Makefile.in | 13 | ||||
-rwxr-xr-x | src/man/preproc.awk | 64 |
2 files changed, 67 insertions, 10 deletions
diff --git a/src/man/Makefile.in b/src/man/Makefile.in index 9d1c12fbc..343aa97bf 100644 --- a/src/man/Makefile.in +++ b/src/man/Makefile.in | |||
@@ -1,17 +1,10 @@ | |||
1 | all: firecfg.man firejail.man firejail-login.man firejail-users.man firejail-profile.man firemon.man | 1 | all: firecfg.man firejail.man firejail-login.man firejail-users.man firejail-profile.man firemon.man |
2 | |||
3 | include ../common.mk | 2 | include ../common.mk |
4 | 3 | ||
5 | %.o : %.c $(H_FILE_LIST) | 4 | %.man: %.txt |
6 | $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(INCLUDE) -c $< -o $@ | 5 | ./preproc.awk $(MANFLAGS) < $< > $@ |
7 | |||
8 | preproc: $(OBJS) | ||
9 | $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) $(EXTRA_LDFLAGS) | ||
10 | |||
11 | %.man: %.txt preproc | ||
12 | ./preproc $(MANFLAGS) $< | ||
13 | 6 | ||
14 | clean:; rm -fr *.o preproc *.gcov *.gcda *.gcno *.plist *.man | 7 | clean:; rm -fr *.man |
15 | 8 | ||
16 | distclean: clean | 9 | distclean: clean |
17 | rm -fr Makefile | 10 | rm -fr Makefile |
diff --git a/src/man/preproc.awk b/src/man/preproc.awk new file mode 100755 index 000000000..d5cee8c44 --- /dev/null +++ b/src/man/preproc.awk | |||
@@ -0,0 +1,64 @@ | |||
1 | #!/usr/bin/gawk -E | ||
2 | |||
3 | # Copyright (c) 2019,2020 rusty-snake | ||
4 | # | ||
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy | ||
6 | # of this software and associated documentation files (the "Software"), to deal | ||
7 | # in the Software without restriction, including without limitation the rights | ||
8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
9 | # copies of the Software, and to permit persons to whom the Software is | ||
10 | # furnished to do so, subject to the following conditions: | ||
11 | # | ||
12 | # The above copyright notice and this permission notice shall be included in all | ||
13 | # copies or substantial portions of the Software. | ||
14 | # | ||
15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
21 | # SOFTWARE. | ||
22 | |||
23 | function errexit(msg) { | ||
24 | print msg > "/dev/stderr" | ||
25 | exit 1 | ||
26 | } | ||
27 | |||
28 | BEGIN { | ||
29 | macros[0] = 0 | ||
30 | for (arg in ARGV) { | ||
31 | if (ARGV[arg] ~ /^-D[A-Z_]+$/) { | ||
32 | macros[length(macros) + 1] = substr(ARGV[arg], 3) | ||
33 | } else { | ||
34 | if (ARGV[arg] == "gawk" || ARGV[arg] == "awk") | ||
35 | continue | ||
36 | # errexit("Invalid commandline argument" ARGV[arg]) | ||
37 | } | ||
38 | ARGV[arg] = "" | ||
39 | } | ||
40 | |||
41 | include = 1 | ||
42 | } | ||
43 | /^#ifdef [A-Z_]+$/ { | ||
44 | macro = substr($0, 8) | ||
45 | for (i in macros) { | ||
46 | if (macros[i] == macro) { | ||
47 | include = 1 | ||
48 | next | ||
49 | } | ||
50 | } | ||
51 | include = 0 | ||
52 | } | ||
53 | /^#if 0$/ { | ||
54 | include = 0 | ||
55 | next | ||
56 | } | ||
57 | /^#endif$/ { | ||
58 | include = 1 | ||
59 | next | ||
60 | } | ||
61 | { | ||
62 | if (include) | ||
63 | |||
64 | } | ||