1 /* $Id: mdoc_state.c,v 1.8 2017/05/05 15:17:32 schwarze Exp $ */
2 /*
3 * Copyright (c) 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17 #include <sys/types.h>
18
19 #include <assert.h>
20 #include <stdlib.h>
21 #include <string.h>
191 {
192 enum mdocargt arg;
193
194 if (n->type != ROFFT_HEAD &&
195 (n->type != ROFFT_BODY || n->end != ENDBODY_NOT))
196 return;
197
198 if (n->parent->args == NULL)
199 return;
200
201 arg = n->parent->args->argv[0].arg;
202 if (arg != MDOC_Literal && arg != MDOC_Unfilled)
203 return;
204
205 state_dl(mdoc, n);
206 }
207
208 static void
209 state_bl(STATE_ARGS)
210 {
211
212 if (n->type != ROFFT_HEAD || n->parent->args == NULL)
213 return;
214
215 switch(n->parent->args->argv[0].arg) {
216 case MDOC_Diag:
217 n->norm->Bl.type = LIST_diag;
218 break;
219 case MDOC_Column:
220 n->norm->Bl.type = LIST_column;
221 break;
222 default:
223 break;
224 }
225 }
226
227 static void
228 state_dl(STATE_ARGS)
229 {
230
231 switch (n->type) {
232 case ROFFT_HEAD:
233 mdoc->flags |= MDOC_LITERAL;
234 break;
235 case ROFFT_BODY:
236 mdoc->flags &= ~MDOC_LITERAL;
237 break;
238 default:
239 break;
240 }
241 }
242
243 static void
244 state_sh(STATE_ARGS)
|
1 /* $Id: mdoc_state.c,v 1.9 2017/11/29 20:05:33 schwarze Exp $ */
2 /*
3 * Copyright (c) 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17 #include <sys/types.h>
18
19 #include <assert.h>
20 #include <stdlib.h>
21 #include <string.h>
191 {
192 enum mdocargt arg;
193
194 if (n->type != ROFFT_HEAD &&
195 (n->type != ROFFT_BODY || n->end != ENDBODY_NOT))
196 return;
197
198 if (n->parent->args == NULL)
199 return;
200
201 arg = n->parent->args->argv[0].arg;
202 if (arg != MDOC_Literal && arg != MDOC_Unfilled)
203 return;
204
205 state_dl(mdoc, n);
206 }
207
208 static void
209 state_bl(STATE_ARGS)
210 {
211 struct mdoc_arg *args;
212 size_t i;
213
214 if (n->type != ROFFT_HEAD || n->parent->args == NULL)
215 return;
216
217 args = n->parent->args;
218 for (i = 0; i < args->argc; i++) {
219 switch(args->argv[i].arg) {
220 case MDOC_Diag:
221 n->norm->Bl.type = LIST_diag;
222 return;
223 case MDOC_Column:
224 n->norm->Bl.type = LIST_column;
225 return;
226 default:
227 break;
228 }
229 }
230 }
231
232 static void
233 state_dl(STATE_ARGS)
234 {
235
236 switch (n->type) {
237 case ROFFT_HEAD:
238 mdoc->flags |= MDOC_LITERAL;
239 break;
240 case ROFFT_BODY:
241 mdoc->flags &= ~MDOC_LITERAL;
242 break;
243 default:
244 break;
245 }
246 }
247
248 static void
249 state_sh(STATE_ARGS)
|