diff options
author | rusty-snake <41237666+rusty-snake@users.noreply.github.com> | 2020-09-03 10:17:52 +0200 |
---|---|---|
committer | rusty-snake <41237666+rusty-snake@users.noreply.github.com> | 2020-09-03 10:17:52 +0200 |
commit | 6ac40a597939989a55ab5465f548489e1ea4937d (patch) | |
tree | f198684f7427a0fccafe5b1e120a3db7db99b924 /src | |
parent | Add profile for twitch,youtube,youtube-music; fix git-cola ,add cola (#3577) (diff) | |
download | firejail-6ac40a597939989a55ab5465f548489e1ea4937d.tar.gz firejail-6ac40a597939989a55ab5465f548489e1ea4937d.tar.zst firejail-6ac40a597939989a55ab5465f548489e1ea4937d.zip |
various
* README.md & RELNOTES
* Allow gnome-build do read and write .bash_history, it has a build-in
terminal
* D-Bus filter for gnome-passwordsafe
* wruc for supertuxkart
* wruc+wusc for totem
* dbus-system none for totem
* remove src/man/preproc.c it is replaced by preproc.awk
* remove dead-code form preproc.awk
Diffstat (limited to 'src')
-rwxr-xr-x | src/man/preproc.awk | 9 | ||||
-rw-r--r-- | src/man/preproc.c | 166 |
2 files changed, 0 insertions, 175 deletions
diff --git a/src/man/preproc.awk b/src/man/preproc.awk index d5cee8c44..20081b551 100755 --- a/src/man/preproc.awk +++ b/src/man/preproc.awk | |||
@@ -20,20 +20,11 @@ | |||
20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
21 | # SOFTWARE. | 21 | # SOFTWARE. |
22 | 22 | ||
23 | function errexit(msg) { | ||
24 | print msg > "/dev/stderr" | ||
25 | exit 1 | ||
26 | } | ||
27 | |||
28 | BEGIN { | 23 | BEGIN { |
29 | macros[0] = 0 | 24 | macros[0] = 0 |
30 | for (arg in ARGV) { | 25 | for (arg in ARGV) { |
31 | if (ARGV[arg] ~ /^-D[A-Z_]+$/) { | 26 | if (ARGV[arg] ~ /^-D[A-Z_]+$/) { |
32 | macros[length(macros) + 1] = substr(ARGV[arg], 3) | 27 | 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 | } | 28 | } |
38 | ARGV[arg] = "" | 29 | ARGV[arg] = "" |
39 | } | 30 | } |
diff --git a/src/man/preproc.c b/src/man/preproc.c deleted file mode 100644 index eefa45278..000000000 --- a/src/man/preproc.c +++ /dev/null | |||
@@ -1,166 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2014-2020 Firejail Authors | ||
3 | * | ||
4 | * This file is part of firejail project | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License along | ||
17 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
19 | */ | ||
20 | |||
21 | #include <stdio.h> | ||
22 | #include <stdlib.h> | ||
23 | #include <string.h> | ||
24 | #include <assert.h> | ||
25 | |||
26 | #define MAXBUF 4096 | ||
27 | #define MAXMACROS 64 | ||
28 | static char *macro[MAXMACROS] = {NULL}; | ||
29 | |||
30 | static void add_macro(char *m) { | ||
31 | assert(m); | ||
32 | int i; | ||
33 | for (i = 0; i < MAXMACROS && macro[i]; i++); | ||
34 | if (i == MAXMACROS) { | ||
35 | fprintf(stderr, "Error: maximum number of marcros (%d) exceeded\n", MAXMACROS); | ||
36 | exit(1); | ||
37 | } | ||
38 | |||
39 | macro[i] = m; | ||
40 | } | ||
41 | |||
42 | static char *find_macro(char *m) { | ||
43 | assert(m); | ||
44 | int i = 0; | ||
45 | while (i < MAXMACROS && macro[i]) { | ||
46 | if (strcmp(macro[i], m) == 0) | ||
47 | return m; | ||
48 | i++; | ||
49 | } | ||
50 | |||
51 | return NULL; | ||
52 | } | ||
53 | |||
54 | static void usage(void) { | ||
55 | printf("Simple preprocessor for man pages. It supports:\n"); | ||
56 | printf("\t#if 0 ... #endif\n"); | ||
57 | printf("\t#ifdef macro ... #endif\n"); | ||
58 | printf("Usage: preproc [--help] [-Dmacro] manpage.txt\n"); | ||
59 | return; | ||
60 | } | ||
61 | |||
62 | |||
63 | int main(int argc, char **argv) { | ||
64 | if (argc == 1) { | ||
65 | fprintf(stderr, "Error: no files/arguments provided\n"); | ||
66 | usage(); | ||
67 | exit(1); | ||
68 | } | ||
69 | |||
70 | int i; | ||
71 | for (i = 1; i < argc; i++) { | ||
72 | if (strncmp(argv[i], "-D", 2) == 0) | ||
73 | add_macro(argv[i] + 2); | ||
74 | else if (strcmp(argv[i], "--help") == 0) { | ||
75 | usage(); | ||
76 | return 0; | ||
77 | } | ||
78 | else if (*argv[i] == '-') { | ||
79 | fprintf(stderr, "Error: invalid argument %s\n", argv[i]); | ||
80 | exit(1); | ||
81 | } | ||
82 | else | ||
83 | break; | ||
84 | } | ||
85 | |||
86 | char *ptr = strstr(argv[i], ".txt"); | ||
87 | if (!ptr || strlen(ptr) != 4) { | ||
88 | fprintf(stderr, "Error: input file needs to have a .txt extension\n"), | ||
89 | exit(1); | ||
90 | } | ||
91 | |||
92 | FILE *fp = fopen(argv[i], "r"); | ||
93 | if (!fp) { | ||
94 | fprintf(stderr, "Error: cannot open %s\n", argv[i]); | ||
95 | exit(1); | ||
96 | } | ||
97 | char *outfile = strdup(argv[i]); | ||
98 | if (!outfile) | ||
99 | goto errout; | ||
100 | ptr = strstr(outfile, ".txt"); | ||
101 | assert(ptr); | ||
102 | strcpy(ptr, ".man"); | ||
103 | FILE *fpout = fopen(outfile, "w"); | ||
104 | if (!fpout) | ||
105 | goto errout; | ||
106 | |||
107 | char buf[MAXBUF]; | ||
108 | int disabled = 0; | ||
109 | int enabled = 0; | ||
110 | int line = 0;; | ||
111 | while (fgets(buf, MAXBUF, fp)) { | ||
112 | line++; | ||
113 | if (disabled && strncmp(buf, "#if", 3) == 0) { | ||
114 | fprintf(stderr, "Error %d: already in a #if block on line %d\n", __LINE__, line); | ||
115 | exit(1); | ||
116 | } | ||
117 | if ((!disabled && !enabled) && strncmp(buf, "#endif", 6) == 0) { | ||
118 | fprintf(stderr, "Error %d: unmatched #endif on line %d\n", __LINE__, line); | ||
119 | exit(1); | ||
120 | } | ||
121 | |||
122 | char *ptr = strchr(buf, '\n'); | ||
123 | if (ptr) | ||
124 | *ptr = '\0'; | ||
125 | |||
126 | if (strncmp(buf, "#if 0", 5) == 0) { | ||
127 | disabled = 1; | ||
128 | continue; | ||
129 | } | ||
130 | if (strncmp(buf, "#ifdef", 6) == 0) { | ||
131 | char *ptr = buf + 6; | ||
132 | if (*ptr != ' ' && *ptr != '\t') { | ||
133 | fprintf(stderr, "Error %d: invalid macro on line %d\n", __LINE__, line); | ||
134 | exit(1); | ||
135 | } | ||
136 | |||
137 | while (*ptr == ' ' || *ptr == '\t') | ||
138 | ptr++; | ||
139 | |||
140 | if (!find_macro(ptr)) | ||
141 | disabled = 1; | ||
142 | else | ||
143 | enabled = 1; | ||
144 | continue; | ||
145 | } | ||
146 | |||
147 | if (strncmp(buf, "#endif", 6) == 0) { | ||
148 | disabled = 0; | ||
149 | enabled = 1; | ||
150 | continue; | ||
151 | } | ||
152 | |||
153 | if (!disabled) { | ||
154 | // printf("%s\n", buf); | ||
155 | fprintf(fpout, "%s\n", buf); | ||
156 | } | ||
157 | } | ||
158 | fclose(fp); | ||
159 | |||
160 | return 0; | ||
161 | |||
162 | errout: | ||
163 | fclose(fp); | ||
164 | fprintf(stderr, "Error: cannot open output file\n"); | ||
165 | exit(1); | ||
166 | } | ||