diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-03-04 21:44:25 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-03-04 21:44:25 +0200 |
commit | a75760ff7d9bedcb1377fc3441f5e38178da1d6a (patch) | |
tree | 39413a06ee259848dfc2cb585a357ddac5d2d4ca /gram.y | |
parent | 860ec4960ff61cf3b2e98e0d020e7f8a93a56008 (diff) | |
download | alck-a75760ff7d9bedcb1377fc3441f5e38178da1d6a.tar.gz alck-a75760ff7d9bedcb1377fc3441f5e38178da1d6a.tar.bz2 |
Switch to a "right" style.
Diffstat (limited to 'gram.y')
-rw-r--r-- | gram.y | 330 |
1 files changed, 161 insertions, 169 deletions
@@ -27,4 +27,4 @@ int error_count; /* Number of errors detected so far */ | |||
27 | %union { | 27 | %union { |
28 | char *string; | 28 | char *string; |
29 | SLIST *slist; | 29 | SLIST *slist; |
30 | }; | 30 | }; |
@@ -48,4 +48,4 @@ list : alias | |||
48 | { | 48 | { |
49 | yyclearin; | 49 | yyclearin; |
50 | yyerrok; | 50 | yyerrok; |
51 | } | 51 | } |
@@ -56,3 +56,3 @@ alias : /* empty */ | |||
56 | { | 56 | { |
57 | regalias ($1, $2); | 57 | regalias($1, $2); |
58 | } | 58 | } |
@@ -66,4 +66,4 @@ rhs : emails | |||
66 | { | 66 | { |
67 | slist_append (&$1, $3); | 67 | slist_append(&$1, $3); |
68 | $$ = $1; | 68 | $$ = $1; |
69 | } | 69 | } |
@@ -74,4 +74,4 @@ emails: email | |||
74 | { | 74 | { |
75 | slist_append (&$1, $3); | 75 | slist_append(&$1, $3); |
76 | $$ = $1; | 76 | $$ = $1; |
77 | } | 77 | } |
@@ -81,9 +81,8 @@ email : string | |||
81 | { | 81 | { |
82 | if (restricted && ($1[0] == '|' || $1[0] == '/')) | 82 | if (restricted && ($1[0] == '|' || $1[0] == '/')) { |
83 | { | 83 | yyerror("Construct not allowed"); |
84 | yyerror ("Construct not allowed"); | 84 | YYERROR; |
85 | YYERROR; | 85 | } |
86 | } | 86 | $$ = NULL; |
87 | $$ = NULL; | 87 | slist_add(&$$, $1); |
88 | slist_add (&$$, $1); | ||
89 | } | 88 | } |
@@ -91,4 +90,4 @@ email : string | |||
91 | { | 90 | { |
92 | $$ = NULL; | 91 | $$ = NULL; |
93 | slist_add (&$$, $1); | 92 | slist_add(&$$, $1); |
94 | } | 93 | } |
@@ -96,9 +95,8 @@ email : string | |||
96 | { | 95 | { |
97 | if (restricted) | 96 | if (restricted) { |
98 | { | 97 | yyerror("Include statement is not allowed"); |
99 | yyerror ("Include statement is not allowed"); | 98 | YYERROR; |
100 | YYERROR; | 99 | } |
101 | } | 100 | $$ = NULL; |
102 | $$ = NULL; | 101 | read_include(&$$, $2); |
103 | read_include (&$$, $2); | ||
104 | } | 102 | } |
@@ -115,4 +113,4 @@ yyerror (char *s) | |||
115 | { | 113 | { |
116 | error_at_line (0, 0, file_name, line_num, "%s", s); | 114 | error_at_line(0, 0, file_name, line_num, "%s", s); |
117 | error_count++; | 115 | error_count++; |
118 | } | 116 | } |
@@ -121,25 +119,25 @@ yyerror (char *s) | |||
121 | void | 119 | void |
122 | usage () | 120 | usage() |
123 | { | 121 | { |
124 | printf ("usage: ckaliases [OPTIONS] [FILES...]\n"); | 122 | printf("usage: ckaliases [OPTIONS] [FILES...]\n"); |
125 | printf ("OPTIONS and FILES may be interspered.\n"); | 123 | printf("OPTIONS and FILES may be interspered.\n"); |
126 | printf ("Valid options are:\n"); | 124 | printf("Valid options are:\n"); |
127 | printf (" -d,--debug=SPEC Set debug level. SPEC consists of the following\n"); | 125 | printf(" -d,--debug=SPEC Set debug level. SPEC consists of the following\n"); |
128 | printf (" letters:\n"); | 126 | printf(" letters:\n"); |
129 | printf (" y enable parser debugging\n"); | 127 | printf(" y enable parser debugging\n"); |
130 | printf (" l enable lexical analizer debugging\n"); | 128 | printf(" l enable lexical analizer debugging\n"); |
131 | printf (" Upper-case variants are also accepted. Prepending\n"); | 129 | printf(" Upper-case variants are also accepted. Prepending\n"); |
132 | printf (" a letter with '-' reverts its sense\n"); | 130 | printf(" a letter with '-' reverts its sense\n"); |
133 | printf (" -f, --files-from=FILE\n"); | 131 | printf(" -f, --files-from=FILE\n"); |
134 | printf (" Read names of alias files from FILE\n"); | 132 | printf(" Read names of alias files from FILE\n"); |
135 | printf (" -h, --help Display this help list\n"); | 133 | printf(" -h, --help Display this help list\n"); |
136 | printf (" -r, --restrict Restrict alias file syntax to aliases only (i.e.\n"); | 134 | printf(" -r, --restrict Restrict alias file syntax to aliases only (i.e.\n"); |
137 | printf (" prohibit use of pipes and file redirections\n"); | 135 | printf(" prohibit use of pipes and file redirections\n"); |
138 | printf (" -u, --unrestrict Revert the effect of the previous -r option\n"); | 136 | printf(" -u, --unrestrict Revert the effect of the previous -r option\n"); |
139 | printf (" -v, --verbose Verbose mode\n"); | 137 | printf(" -v, --verbose Verbose mode\n"); |
140 | printf (" -V, --version print program version and exit\n"); | 138 | printf(" -V, --version print program version and exit\n"); |
141 | printf (" -w FILE Read contents of Sendmail `w' class from the given\n"); | 139 | printf(" -w FILE Read contents of Sendmail `w' class from the given\n"); |
142 | printf (" file.\n"); | 140 | printf(" file.\n"); |
143 | printf ("\n"); | 141 | printf("\n"); |
144 | printf ("Report bugs to <%s>\n", PACKAGE_BUGREPORT); | 142 | printf("Report bugs to <%s>\n", PACKAGE_BUGREPORT); |
145 | } | 143 | } |
@@ -147,10 +145,10 @@ usage () | |||
147 | struct option options[] = { | 145 | struct option options[] = { |
148 | { "debug", required_argument, NULL, 'd' }, | 146 | { "debug", required_argument, NULL, 'd' }, |
149 | { "help", no_argument, NULL, 'h' }, | 147 | { "help", no_argument, NULL, 'h' }, |
150 | { "version", no_argument, NULL, 'V' }, | 148 | { "version", no_argument, NULL, 'V' }, |
151 | { "restrict", no_argument, NULL, 'r' }, | 149 | { "restrict", no_argument, NULL, 'r' }, |
152 | { "unrestrict", no_argument, NULL, 'u' }, | 150 | { "unrestrict", no_argument, NULL, 'u' }, |
153 | { "verbose", no_argument, NULL, 'v' }, | 151 | { "verbose", no_argument, NULL, 'v' }, |
154 | { "files-from", required_argument, NULL, 'f' }, | 152 | { "files-from", required_argument, NULL, 'f' }, |
155 | { NULL } | 153 | { NULL } |
156 | }; | 154 | }; |
@@ -158,124 +156,118 @@ struct option options[] = { | |||
158 | int | 156 | int |
159 | main (int argc, char **argv) | 157 | main(int argc, char **argv) |
160 | { | 158 | { |
161 | char *p; | 159 | char *p; |
162 | int c; | 160 | int c; |
163 | int file_count = 0; | 161 | int file_count = 0; |
164 | int true = 1; | 162 | int true = 1; |
165 | char *cwfile = "/etc/mail/sendmail.cw"; | 163 | char *cwfile = "/etc/mail/sendmail.cw"; |
166 | SLIST *file_list; /* List of files to be read */ | 164 | SLIST *file_list; /* List of files to be read */ |
167 | struct string_list *s; | 165 | struct string_list *s; |
168 | 166 | ||
169 | begin_aliases (); | 167 | begin_aliases(); |
170 | init_lex (); | 168 | init_lex (); |
171 | program_name = argv[0]; | 169 | program_name = argv[0]; |
172 | while ((c = getopt_long (argc, argv, "-d:f:hp:ruvw:", options, NULL)) != EOF) | 170 | while ((c = getopt_long(argc, argv, "-d:f:hp:ruvw:", |
173 | { | 171 | options, NULL)) != EOF) { |
174 | switch (c) | 172 | switch (c) { |
175 | { | 173 | case 1: |
176 | case 1: | 174 | if (!cw_list) |
177 | if (!cw_list) | 175 | read_include(&cw_list, cwfile); |
178 | read_include (&cw_list, cwfile); | 176 | openaliases(optarg); |
179 | openaliases (optarg); | 177 | yyparse(); |
180 | yyparse (); | 178 | file_count++; |
181 | file_count++; | 179 | break; |
182 | break; | ||
183 | 180 | ||
184 | case 'd': | 181 | case 'd': |
185 | for (p = optarg; *p; p++) | 182 | for (p = optarg; *p; p++) { |
186 | { | 183 | switch (*p) { |
187 | switch (*p) | 184 | case '-': |
188 | { | 185 | true = 0; |
189 | case '-': | 186 | break; |
190 | true = 0; | 187 | |
191 | break; | 188 | case 'y': |
192 | 189 | case 'Y': | |
193 | case 'y': | 190 | yydebug = true; |
194 | case 'Y': | 191 | true = 1; |
195 | yydebug = true; | 192 | break; |
196 | true = 1; | 193 | |
197 | break; | 194 | case 'l': |
198 | 195 | case 'L': | |
199 | case 'l': | 196 | lex_debug(true); |
200 | case 'L': | 197 | true = 1; |
201 | lex_debug (true); | 198 | break; |
202 | true = 1; | 199 | |
203 | break; | 200 | default: |
204 | 201 | error(1, 0, "%s: unknown debug option %c", argv[0]); | |
205 | default: | 202 | } |
206 | error (1, 0, "%s: unknown debug option %c", argv[0]); | 203 | } |
207 | } | 204 | break; |
208 | } | 205 | |
209 | break; | 206 | case 'f': |
210 | 207 | if (!cw_list) | |
211 | case 'f': | 208 | read_include(&cw_list, cwfile); |
212 | if (!cw_list) | 209 | file_list = NULL; |
213 | read_include (&cw_list, cwfile); | 210 | read_include(&file_list, optarg); |
214 | file_list = NULL; | 211 | if (file_list) { |
215 | read_include (&file_list, optarg); | 212 | for (s = file_list->head; s; s = s->next) { |
216 | if (file_list) | 213 | openaliases_prefix(optarg, s->str); |
217 | { | 214 | yyparse(); |
218 | for (s = file_list->head; s; s = s->next) | 215 | file_count++; |
219 | { | 216 | } |
220 | openaliases_prefix (optarg, s->str); | 217 | slist_destroy(&file_list); |
221 | yyparse (); | 218 | } |
222 | file_count++; | 219 | break; |
223 | } | ||
224 | slist_destroy (&file_list); | ||
225 | } | ||
226 | break; | ||
227 | 220 | ||
228 | case 'h': | 221 | case 'h': |
229 | usage (); | 222 | usage(); |
230 | exit (0); | 223 | exit(0); |
231 | 224 |