version 1.120, 2012/11/18 00:05:35 |
version 1.128, 2014/01/20 11:28:29 |
|
|
/* $Id$ */ |
/* $Id$ */ |
/* |
/* |
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2010, 2012 Ingo Schwarze <schwarze@openbsd.org> |
* Copyright (c) 2010, 2012, 2013 Ingo Schwarze <schwarze@openbsd.org> |
* |
* |
* Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
* purpose with or without fee is hereby granted, provided that the above |
* purpose with or without fee is hereby granted, provided that the above |
Line 51 static int in_line(MACRO_PROT_ARGS); |
|
Line 51 static int in_line(MACRO_PROT_ARGS); |
|
static int obsolete(MACRO_PROT_ARGS); |
static int obsolete(MACRO_PROT_ARGS); |
static int phrase_ta(MACRO_PROT_ARGS); |
static int phrase_ta(MACRO_PROT_ARGS); |
|
|
static int dword(struct mdoc *, int, int, |
static int dword(struct mdoc *, int, int, const char *, |
const char *, enum mdelim); |
enum mdelim, int); |
static int append_delims(struct mdoc *, |
static int append_delims(struct mdoc *, |
int, int *, char *); |
int, int *, char *); |
static enum mdoct lookup(enum mdoct, const char *); |
static enum mdoct lookup(enum mdoct, const char *); |
Line 70 static int rew_sub(enum mdoc_type, struct mdoc *, |
|
Line 70 static int rew_sub(enum mdoc_type, struct mdoc *, |
|
enum mdoct, int, int); |
enum mdoct, int, int); |
|
|
const struct mdoc_macro __mdoc_macros[MDOC_MAX] = { |
const struct mdoc_macro __mdoc_macros[MDOC_MAX] = { |
{ in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* Ap */ |
{ in_line_argn, MDOC_CALLABLE | MDOC_PARSED | MDOC_JOIN }, /* Ap */ |
{ in_line_eoln, MDOC_PROLOGUE }, /* Dd */ |
{ in_line_eoln, MDOC_PROLOGUE }, /* Dd */ |
{ in_line_eoln, MDOC_PROLOGUE }, /* Dt */ |
{ in_line_eoln, MDOC_PROLOGUE }, /* Dt */ |
{ in_line_eoln, MDOC_PROLOGUE }, /* Os */ |
{ in_line_eoln, MDOC_PROLOGUE }, /* Os */ |
{ blk_full, MDOC_PARSED }, /* Sh */ |
{ blk_full, MDOC_PARSED | MDOC_JOIN }, /* Sh */ |
{ blk_full, MDOC_PARSED }, /* Ss */ |
{ blk_full, MDOC_PARSED | MDOC_JOIN }, /* Ss */ |
{ in_line_eoln, 0 }, /* Pp */ |
{ in_line_eoln, 0 }, /* Pp */ |
{ blk_part_imp, MDOC_PARSED }, /* D1 */ |
{ blk_part_imp, MDOC_PARSED | MDOC_JOIN }, /* D1 */ |
{ blk_part_imp, MDOC_PARSED }, /* Dl */ |
{ blk_part_imp, MDOC_PARSED | MDOC_JOIN }, /* Dl */ |
{ blk_full, MDOC_EXPLICIT }, /* Bd */ |
{ blk_full, MDOC_EXPLICIT }, /* Bd */ |
{ blk_exp_close, MDOC_EXPLICIT }, /* Ed */ |
{ blk_exp_close, MDOC_EXPLICIT | MDOC_JOIN }, /* Ed */ |
{ blk_full, MDOC_EXPLICIT }, /* Bl */ |
{ blk_full, MDOC_EXPLICIT }, /* Bl */ |
{ blk_exp_close, MDOC_EXPLICIT }, /* El */ |
{ blk_exp_close, MDOC_EXPLICIT | MDOC_JOIN }, /* El */ |
{ blk_full, MDOC_PARSED }, /* It */ |
{ blk_full, MDOC_PARSED | MDOC_JOIN }, /* It */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Ad */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Ad */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* An */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED | MDOC_JOIN }, /* An */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Ar */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Ar */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Cd */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Cd */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Cm */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Cm */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Dv */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Dv */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Er */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Er */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Ev */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Ev */ |
{ in_line_eoln, 0 }, /* Ex */ |
{ in_line_eoln, 0 }, /* Ex */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Fa */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Fa */ |
{ in_line_eoln, 0 }, /* Fd */ |
{ in_line_eoln, 0 }, /* Fd */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Fl */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Fl */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Fn */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Fn */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Ft */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Ft */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Ic */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED | MDOC_JOIN }, /* Ic */ |
{ in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* In */ |
{ in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* In */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Li */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED | MDOC_JOIN }, /* Li */ |
{ blk_full, 0 }, /* Nd */ |
{ blk_full, MDOC_JOIN }, /* Nd */ |
{ ctx_synopsis, MDOC_CALLABLE | MDOC_PARSED }, /* Nm */ |
{ ctx_synopsis, MDOC_CALLABLE | MDOC_PARSED }, /* Nm */ |
{ blk_part_imp, MDOC_CALLABLE | MDOC_PARSED }, /* Op */ |
{ blk_part_imp, MDOC_CALLABLE | MDOC_PARSED }, /* Op */ |
{ obsolete, 0 }, /* Ot */ |
{ obsolete, 0 }, /* Ot */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Pa */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Pa */ |
{ in_line_eoln, 0 }, /* Rv */ |
{ in_line_eoln, 0 }, /* Rv */ |
{ in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* St */ |
{ in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* St */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Va */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Va */ |
{ ctx_synopsis, MDOC_CALLABLE | MDOC_PARSED }, /* Vt */ |
{ ctx_synopsis, MDOC_CALLABLE | MDOC_PARSED }, /* Vt */ |
{ in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* Xr */ |
{ in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* Xr */ |
{ in_line_eoln, 0 }, /* %A */ |
{ in_line_eoln, MDOC_JOIN }, /* %A */ |
{ in_line_eoln, 0 }, /* %B */ |
{ in_line_eoln, MDOC_JOIN }, /* %B */ |
{ in_line_eoln, 0 }, /* %D */ |
{ in_line_eoln, MDOC_JOIN }, /* %D */ |
{ in_line_eoln, 0 }, /* %I */ |
{ in_line_eoln, MDOC_JOIN }, /* %I */ |
{ in_line_eoln, 0 }, /* %J */ |
{ in_line_eoln, MDOC_JOIN }, /* %J */ |
{ in_line_eoln, 0 }, /* %N */ |
{ in_line_eoln, 0 }, /* %N */ |
{ in_line_eoln, 0 }, /* %O */ |
{ in_line_eoln, MDOC_JOIN }, /* %O */ |
{ in_line_eoln, 0 }, /* %P */ |
{ in_line_eoln, 0 }, /* %P */ |
{ in_line_eoln, 0 }, /* %R */ |
{ in_line_eoln, MDOC_JOIN }, /* %R */ |
{ in_line_eoln, 0 }, /* %T */ |
{ in_line_eoln, MDOC_JOIN }, /* %T */ |
{ in_line_eoln, 0 }, /* %V */ |
{ in_line_eoln, 0 }, /* %V */ |
{ blk_exp_close, MDOC_EXPLICIT | MDOC_CALLABLE | MDOC_PARSED }, /* Ac */ |
{ blk_exp_close, MDOC_CALLABLE | MDOC_PARSED | |
{ blk_part_exp, MDOC_CALLABLE | MDOC_PARSED | MDOC_EXPLICIT }, /* Ao */ |
MDOC_EXPLICIT | MDOC_JOIN }, /* Ac */ |
{ blk_part_imp, MDOC_CALLABLE | MDOC_PARSED }, /* Aq */ |
{ blk_part_exp, MDOC_CALLABLE | MDOC_PARSED | |
|
MDOC_EXPLICIT | MDOC_JOIN }, /* Ao */ |
|
{ blk_part_imp, MDOC_CALLABLE | MDOC_PARSED | MDOC_JOIN }, /* Aq */ |
{ in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* At */ |
{ in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* At */ |
{ blk_exp_close, MDOC_EXPLICIT | MDOC_CALLABLE | MDOC_PARSED }, /* Bc */ |
{ blk_exp_close, MDOC_CALLABLE | MDOC_PARSED | |
{ blk_full, MDOC_EXPLICIT }, /* Bf */ |
MDOC_EXPLICIT | MDOC_JOIN }, /* Bc */ |
{ blk_part_exp, MDOC_CALLABLE | MDOC_PARSED | MDOC_EXPLICIT }, /* Bo */ |
{ blk_full, MDOC_EXPLICIT }, /* Bf */ |
{ blk_part_imp, MDOC_CALLABLE | MDOC_PARSED }, /* Bq */ |
{ blk_part_exp, MDOC_CALLABLE | MDOC_PARSED | |
|
MDOC_EXPLICIT | MDOC_JOIN }, /* Bo */ |
|
{ blk_part_imp, MDOC_CALLABLE | MDOC_PARSED | MDOC_JOIN }, /* Bq */ |
{ in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* Bsx */ |
{ in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* Bsx */ |
{ in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* Bx */ |
{ in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* Bx */ |
{ in_line_eoln, 0 }, /* Db */ |
{ in_line_eoln, 0 }, /* Db */ |
{ blk_exp_close, MDOC_EXPLICIT | MDOC_CALLABLE | MDOC_PARSED }, /* Dc */ |
{ blk_exp_close, MDOC_CALLABLE | MDOC_PARSED | |
{ blk_part_exp, MDOC_CALLABLE | MDOC_PARSED | MDOC_EXPLICIT }, /* Do */ |
MDOC_EXPLICIT | MDOC_JOIN }, /* Dc */ |
{ blk_part_imp, MDOC_CALLABLE | MDOC_PARSED }, /* Dq */ |
{ blk_part_exp, MDOC_CALLABLE | MDOC_PARSED | |
{ blk_exp_close, MDOC_EXPLICIT | MDOC_CALLABLE | MDOC_PARSED }, /* Ec */ |
MDOC_EXPLICIT | MDOC_JOIN }, /* Do */ |
{ blk_exp_close, MDOC_EXPLICIT }, /* Ef */ |
{ blk_part_imp, MDOC_CALLABLE | MDOC_PARSED | MDOC_JOIN }, /* Dq */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Em */ |
{ blk_exp_close, MDOC_CALLABLE | MDOC_PARSED | MDOC_EXPLICIT }, /* Ec */ |
|
{ blk_exp_close, MDOC_EXPLICIT | MDOC_JOIN }, /* Ef */ |
|
{ in_line, MDOC_CALLABLE | MDOC_PARSED | MDOC_JOIN }, /* Em */ |
{ blk_part_exp, MDOC_CALLABLE | MDOC_PARSED | MDOC_EXPLICIT }, /* Eo */ |
{ blk_part_exp, MDOC_CALLABLE | MDOC_PARSED | MDOC_EXPLICIT }, /* Eo */ |
{ in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* Fx */ |
{ in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* Fx */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Ms */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Ms */ |
{ in_line_argn, MDOC_CALLABLE | MDOC_PARSED | MDOC_IGNDELIM }, /* No */ |
{ in_line_argn, MDOC_CALLABLE | MDOC_PARSED | |
{ in_line_argn, MDOC_CALLABLE | MDOC_PARSED | MDOC_IGNDELIM }, /* Ns */ |
MDOC_IGNDELIM | MDOC_JOIN }, /* No */ |
|
{ in_line_argn, MDOC_CALLABLE | MDOC_PARSED | |
|
MDOC_IGNDELIM | MDOC_JOIN }, /* Ns */ |
{ in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* Nx */ |
{ in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* Nx */ |
{ in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* Ox */ |
{ in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* Ox */ |
{ blk_exp_close, MDOC_EXPLICIT | MDOC_CALLABLE | MDOC_PARSED }, /* Pc */ |
{ blk_exp_close, MDOC_CALLABLE | MDOC_PARSED | |
|
MDOC_EXPLICIT | MDOC_JOIN }, /* Pc */ |
{ in_line_argn, MDOC_CALLABLE | MDOC_PARSED | MDOC_IGNDELIM }, /* Pf */ |
{ in_line_argn, MDOC_CALLABLE | MDOC_PARSED | MDOC_IGNDELIM }, /* Pf */ |
{ blk_part_exp, MDOC_CALLABLE | MDOC_PARSED | MDOC_EXPLICIT }, /* Po */ |
{ blk_part_exp, MDOC_CALLABLE | MDOC_PARSED | |
{ blk_part_imp, MDOC_CALLABLE | MDOC_PARSED }, /* Pq */ |
MDOC_EXPLICIT | MDOC_JOIN }, /* Po */ |
{ blk_exp_close, MDOC_EXPLICIT | MDOC_CALLABLE | MDOC_PARSED }, /* Qc */ |
{ blk_part_imp, MDOC_CALLABLE | MDOC_PARSED | MDOC_JOIN }, /* Pq */ |
{ blk_part_imp, MDOC_CALLABLE | MDOC_PARSED }, /* Ql */ |
{ blk_exp_close, MDOC_CALLABLE | MDOC_PARSED | |
{ blk_part_exp, MDOC_CALLABLE | MDOC_PARSED | MDOC_EXPLICIT }, /* Qo */ |
MDOC_EXPLICIT | MDOC_JOIN }, /* Qc */ |
{ blk_part_imp, MDOC_CALLABLE | MDOC_PARSED }, /* Qq */ |
{ blk_part_imp, MDOC_CALLABLE | MDOC_PARSED | MDOC_JOIN }, /* Ql */ |
{ blk_exp_close, MDOC_EXPLICIT }, /* Re */ |
{ blk_part_exp, MDOC_CALLABLE | MDOC_PARSED | |
|
MDOC_EXPLICIT | MDOC_JOIN }, /* Qo */ |
|
{ blk_part_imp, MDOC_CALLABLE | MDOC_PARSED | MDOC_JOIN }, /* Qq */ |
|
{ blk_exp_close, MDOC_EXPLICIT | MDOC_JOIN }, /* Re */ |
{ blk_full, MDOC_EXPLICIT }, /* Rs */ |
{ blk_full, MDOC_EXPLICIT }, /* Rs */ |
{ blk_exp_close, MDOC_EXPLICIT | MDOC_CALLABLE | MDOC_PARSED }, /* Sc */ |
{ blk_exp_close, MDOC_CALLABLE | MDOC_PARSED | |
{ blk_part_exp, MDOC_CALLABLE | MDOC_PARSED | MDOC_EXPLICIT }, /* So */ |
MDOC_EXPLICIT | MDOC_JOIN }, /* Sc */ |
{ blk_part_imp, MDOC_CALLABLE | MDOC_PARSED }, /* Sq */ |
{ blk_part_exp, MDOC_CALLABLE | MDOC_PARSED | |
|
MDOC_EXPLICIT | MDOC_JOIN }, /* So */ |
|
{ blk_part_imp, MDOC_CALLABLE | MDOC_PARSED | MDOC_JOIN }, /* Sq */ |
{ in_line_eoln, 0 }, /* Sm */ |
{ in_line_eoln, 0 }, /* Sm */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Sx */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED | MDOC_JOIN }, /* Sx */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Sy */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED | MDOC_JOIN }, /* Sy */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Tn */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Tn */ |
{ in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* Ux */ |
{ in_line_argn, MDOC_CALLABLE | MDOC_PARSED | MDOC_JOIN }, /* Ux */ |
{ blk_exp_close, MDOC_EXPLICIT | MDOC_CALLABLE | MDOC_PARSED }, /* Xc */ |
{ blk_exp_close, MDOC_EXPLICIT | MDOC_CALLABLE | MDOC_PARSED }, /* Xc */ |
{ blk_part_exp, MDOC_CALLABLE | MDOC_PARSED | MDOC_EXPLICIT }, /* Xo */ |
{ blk_part_exp, MDOC_CALLABLE | MDOC_PARSED | MDOC_EXPLICIT }, /* Xo */ |
{ blk_full, MDOC_EXPLICIT | MDOC_CALLABLE }, /* Fo */ |
{ blk_full, MDOC_EXPLICIT | MDOC_CALLABLE }, /* Fo */ |
{ blk_exp_close, MDOC_EXPLICIT | MDOC_CALLABLE | MDOC_PARSED }, /* Fc */ |
{ blk_exp_close, MDOC_CALLABLE | MDOC_PARSED | |
{ blk_part_exp, MDOC_CALLABLE | MDOC_PARSED | MDOC_EXPLICIT }, /* Oo */ |
MDOC_EXPLICIT | MDOC_JOIN }, /* Fc */ |
{ blk_exp_close, MDOC_EXPLICIT | MDOC_CALLABLE | MDOC_PARSED }, /* Oc */ |
{ blk_part_exp, MDOC_CALLABLE | MDOC_PARSED | |
|
MDOC_EXPLICIT | MDOC_JOIN }, /* Oo */ |
|
{ blk_exp_close, MDOC_CALLABLE | MDOC_PARSED | |
|
MDOC_EXPLICIT | MDOC_JOIN }, /* Oc */ |
{ blk_full, MDOC_EXPLICIT }, /* Bk */ |
{ blk_full, MDOC_EXPLICIT }, /* Bk */ |
{ blk_exp_close, MDOC_EXPLICIT }, /* Ek */ |
{ blk_exp_close, MDOC_EXPLICIT | MDOC_JOIN }, /* Ek */ |
{ in_line_eoln, 0 }, /* Bt */ |
{ in_line_eoln, 0 }, /* Bt */ |
{ in_line_eoln, 0 }, /* Hf */ |
{ in_line_eoln, 0 }, /* Hf */ |
{ obsolete, 0 }, /* Fr */ |
{ obsolete, 0 }, /* Fr */ |
{ in_line_eoln, 0 }, /* Ud */ |
{ in_line_eoln, 0 }, /* Ud */ |
{ in_line, 0 }, /* Lb */ |
{ in_line, 0 }, /* Lb */ |
{ in_line_eoln, 0 }, /* Lp */ |
{ in_line_eoln, 0 }, /* Lp */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Lk */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Lk */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Mt */ |
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Mt */ |
{ blk_part_imp, MDOC_CALLABLE | MDOC_PARSED }, /* Brq */ |
{ blk_part_imp, MDOC_CALLABLE | MDOC_PARSED | MDOC_JOIN }, /* Brq */ |
{ blk_part_exp, MDOC_CALLABLE | MDOC_PARSED | MDOC_EXPLICIT }, /* Bro */ |
{ blk_part_exp, MDOC_CALLABLE | MDOC_PARSED | |
{ blk_exp_close, MDOC_EXPLICIT | MDOC_CALLABLE | MDOC_PARSED }, /* Brc */ |
MDOC_EXPLICIT | MDOC_JOIN }, /* Bro */ |
{ in_line_eoln, 0 }, /* %C */ |
{ blk_exp_close, MDOC_CALLABLE | MDOC_PARSED | |
|
MDOC_EXPLICIT | MDOC_JOIN }, /* Brc */ |
|
{ in_line_eoln, MDOC_JOIN }, /* %C */ |
{ obsolete, 0 }, /* Es */ |
{ obsolete, 0 }, /* Es */ |
{ obsolete, 0 }, /* En */ |
{ obsolete, 0 }, /* En */ |
{ in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* Dx */ |
{ in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* Dx */ |
{ in_line_eoln, 0 }, /* %Q */ |
{ in_line_eoln, MDOC_JOIN }, /* %Q */ |
{ in_line_eoln, 0 }, /* br */ |
{ in_line_eoln, 0 }, /* br */ |
{ in_line_eoln, 0 }, /* sp */ |
{ in_line_eoln, 0 }, /* sp */ |
{ in_line_eoln, 0 }, /* %U */ |
{ in_line_eoln, 0 }, /* %U */ |
{ phrase_ta, MDOC_CALLABLE | MDOC_PARSED }, /* Ta */ |
{ phrase_ta, MDOC_CALLABLE | MDOC_PARSED | MDOC_JOIN }, /* Ta */ |
}; |
}; |
|
|
const struct mdoc_macro * const mdoc_macros = __mdoc_macros; |
const struct mdoc_macro * const mdoc_macros = __mdoc_macros; |
Line 542 rew_sub(enum mdoc_type t, struct mdoc *mdoc, |
|
Line 561 rew_sub(enum mdoc_type t, struct mdoc *mdoc, |
|
case (REWIND_NONE): |
case (REWIND_NONE): |
return(1); |
return(1); |
case (REWIND_THIS): |
case (REWIND_THIS): |
|
n->lastline = line - |
|
(MDOC_NEWLINE & mdoc->flags && |
|
! (MDOC_EXPLICIT & mdoc_macros[tok].flags)); |
break; |
break; |
case (REWIND_FORCE): |
case (REWIND_FORCE): |
mandoc_vmsg(MANDOCERR_SCOPEBROKEN, mdoc->parse, |
mandoc_vmsg(MANDOCERR_SCOPEBROKEN, mdoc->parse, |
Line 550 rew_sub(enum mdoc_type t, struct mdoc *mdoc, |
|
Line 572 rew_sub(enum mdoc_type t, struct mdoc *mdoc, |
|
mdoc_macronames[n->tok]); |
mdoc_macronames[n->tok]); |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (REWIND_MORE): |
case (REWIND_MORE): |
|
n->lastline = line - |
|
(MDOC_NEWLINE & mdoc->flags ? 1 : 0); |
n = n->parent; |
n = n->parent; |
continue; |
continue; |
case (REWIND_LATER): |
case (REWIND_LATER): |
Line 588 rew_sub(enum mdoc_type t, struct mdoc *mdoc, |
|
Line 612 rew_sub(enum mdoc_type t, struct mdoc *mdoc, |
|
* Punctuation consists of those tokens found in mdoc_isdelim(). |
* Punctuation consists of those tokens found in mdoc_isdelim(). |
*/ |
*/ |
static int |
static int |
dword(struct mdoc *mdoc, int line, |
dword(struct mdoc *mdoc, int line, int col, const char *p, |
int col, const char *p, enum mdelim d) |
enum mdelim d, int may_append) |
{ |
{ |
|
|
if (DELIM_MAX == d) |
if (DELIM_MAX == d) |
d = mdoc_isdelim(p); |
d = mdoc_isdelim(p); |
|
|
|
if (may_append && |
|
! ((MDOC_SYNOPSIS | MDOC_KEEP | MDOC_SMOFF) & mdoc->flags) && |
|
DELIM_NONE == d && MDOC_TEXT == mdoc->last->type && |
|
DELIM_NONE == mdoc_isdelim(mdoc->last->string)) { |
|
mdoc_word_append(mdoc, p); |
|
return(1); |
|
} |
|
|
if ( ! mdoc_word_alloc(mdoc, line, col, p)) |
if ( ! mdoc_word_alloc(mdoc, line, col, p)) |
return(0); |
return(0); |
|
|
Line 638 append_delims(struct mdoc *mdoc, int line, int *pos, c |
|
Line 670 append_delims(struct mdoc *mdoc, int line, int *pos, c |
|
else if (ARGS_EOLN == ac) |
else if (ARGS_EOLN == ac) |
break; |
break; |
|
|
dword(mdoc, line, la, p, DELIM_MAX); |
dword(mdoc, line, la, p, DELIM_MAX, 1); |
|
|
/* |
/* |
* If we encounter end-of-sentence symbols, then trigger |
* If we encounter end-of-sentence symbols, then trigger |
Line 651 append_delims(struct mdoc *mdoc, int line, int *pos, c |
|
Line 683 append_delims(struct mdoc *mdoc, int line, int *pos, c |
|
* knowing which symbols break this behaviour, for |
* knowing which symbols break this behaviour, for |
* example, `. ;' shouldn't propagate the double-space. |
* example, `. ;' shouldn't propagate the double-space. |
*/ |
*/ |
if (mandoc_eos(p, strlen(p), 0)) |
if (mandoc_eos(p, strlen(p))) |
mdoc->last->flags |= MDOC_EOS; |
mdoc->last->flags |= MDOC_EOS; |
} |
} |
|
|
Line 680 blk_exp_close(MACRO_PROT_ARGS) |
|
Line 712 blk_exp_close(MACRO_PROT_ARGS) |
|
case (MDOC_Ec): |
case (MDOC_Ec): |
maxargs = 1; |
maxargs = 1; |
break; |
break; |
|
case (MDOC_Ek): |
|
mdoc->flags &= ~MDOC_KEEP; |
default: |
default: |
maxargs = 0; |
maxargs = 0; |
break; |
break; |
Line 782 blk_exp_close(MACRO_PROT_ARGS) |
|
Line 816 blk_exp_close(MACRO_PROT_ARGS) |
|
ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup(tok, p); |
ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup(tok, p); |
|
|
if (MDOC_MAX == ntok) { |
if (MDOC_MAX == ntok) { |
if ( ! dword(mdoc, line, lastarg, p, DELIM_MAX)) |
if ( ! dword(mdoc, line, lastarg, p, DELIM_MAX, |
|
MDOC_JOIN & mdoc_macros[tok].flags)) |
return(0); |
return(0); |
continue; |
continue; |
} |
} |
Line 792 blk_exp_close(MACRO_PROT_ARGS) |
|
Line 827 blk_exp_close(MACRO_PROT_ARGS) |
|
return(0); |
return(0); |
flushed = 1; |
flushed = 1; |
} |
} |
|
|
|
mdoc->flags &= ~MDOC_NEWLINE; |
|
|
if ( ! mdoc_macro(mdoc, ntok, line, lastarg, pos, buf)) |
if ( ! mdoc_macro(mdoc, ntok, line, lastarg, pos, buf)) |
return(0); |
return(0); |
break; |
break; |
Line 945 in_line(MACRO_PROT_ARGS) |
|
Line 983 in_line(MACRO_PROT_ARGS) |
|
if (DELIM_NONE == d) |
if (DELIM_NONE == d) |
cnt++; |
cnt++; |
|
|
if ( ! dword(mdoc, line, la, p, d)) |
if ( ! dword(mdoc, line, la, p, d, |
|
MDOC_JOIN & mdoc_macros[tok].flags)) |
return(0); |
return(0); |
|
|
/* |
/* |
Line 1064 blk_full(MACRO_PROT_ARGS) |
|
Line 1103 blk_full(MACRO_PROT_ARGS) |
|
if ( ! mdoc_body_alloc(mdoc, line, ppos, tok)) |
if ( ! mdoc_body_alloc(mdoc, line, ppos, tok)) |
return(0); |
return(0); |
body = mdoc->last; |
body = mdoc->last; |
} |
} |
|
|
|
if (MDOC_Bk == tok) |
|
mdoc->flags |= MDOC_KEEP; |
|
|
ac = ARGS_ERROR; |
ac = ARGS_ERROR; |
|
|
for ( ; ; ) { |
for ( ; ; ) { |
Line 1109 blk_full(MACRO_PROT_ARGS) |
|
Line 1151 blk_full(MACRO_PROT_ARGS) |
|
ARGS_PPHRASE != ac && |
ARGS_PPHRASE != ac && |
ARGS_QWORD != ac && |
ARGS_QWORD != ac && |
DELIM_OPEN == mdoc_isdelim(p)) { |
DELIM_OPEN == mdoc_isdelim(p)) { |
if ( ! dword(mdoc, line, la, p, DELIM_OPEN)) |
if ( ! dword(mdoc, line, la, p, DELIM_OPEN, 0)) |
return(0); |
return(0); |
continue; |
continue; |
} |
} |
Line 1162 blk_full(MACRO_PROT_ARGS) |
|
Line 1204 blk_full(MACRO_PROT_ARGS) |
|
MDOC_MAX : lookup(tok, p); |
MDOC_MAX : lookup(tok, p); |
|
|
if (MDOC_MAX == ntok) { |
if (MDOC_MAX == ntok) { |
if ( ! dword(mdoc, line, la, p, DELIM_MAX)) |
if ( ! dword(mdoc, line, la, p, DELIM_MAX, |
|
MDOC_JOIN & mdoc_macros[tok].flags)) |
return(0); |
return(0); |
continue; |
continue; |
} |
} |
Line 1273 blk_part_imp(MACRO_PROT_ARGS) |
|
Line 1316 blk_part_imp(MACRO_PROT_ARGS) |
|
|
|
if (NULL == body && ARGS_QWORD != ac && |
if (NULL == body && ARGS_QWORD != ac && |
DELIM_OPEN == mdoc_isdelim(p)) { |
DELIM_OPEN == mdoc_isdelim(p)) { |
if ( ! dword(mdoc, line, la, p, DELIM_OPEN)) |
if ( ! dword(mdoc, line, la, p, DELIM_OPEN, 0)) |
return(0); |
return(0); |
continue; |
continue; |
} |
} |
|
|
if (NULL == body) { |
if (NULL == body) { |
if ( ! mdoc_body_alloc(mdoc, line, ppos, tok)) |
if ( ! mdoc_body_alloc(mdoc, line, ppos, tok)) |
Line 1287 blk_part_imp(MACRO_PROT_ARGS) |
|
Line 1330 blk_part_imp(MACRO_PROT_ARGS) |
|
ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup(tok, p); |
ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup(tok, p); |
|
|
if (MDOC_MAX == ntok) { |
if (MDOC_MAX == ntok) { |
if ( ! dword(mdoc, line, la, p, DELIM_MAX)) |
if ( ! dword(mdoc, line, la, p, DELIM_MAX, |
|
MDOC_JOIN & mdoc_macros[tok].flags)) |
return(0); |
return(0); |
continue; |
continue; |
} |
} |
Line 1305 blk_part_imp(MACRO_PROT_ARGS) |
|
Line 1349 blk_part_imp(MACRO_PROT_ARGS) |
|
body = mdoc->last; |
body = mdoc->last; |
} |
} |
|
|
for (n = body->child; n && n->next; n = n->next) |
|
/* Do nothing. */ ; |
|
|
|
/* |
|
* End of sentence spacing: if the last node is a text node and |
|
* has a trailing period, then mark it as being end-of-sentence. |
|
*/ |
|
|
|
if (n && MDOC_TEXT == n->type && n->string) |
|
if (mandoc_eos(n->string, strlen(n->string), 1)) |
|
n->flags |= MDOC_EOS; |
|
|
|
/* Up-propagate the end-of-space flag. */ |
|
|
|
if (n && (MDOC_EOS & n->flags)) { |
|
body->flags |= MDOC_EOS; |
|
body->parent->flags |= MDOC_EOS; |
|
} |
|
|
|
/* |
/* |
* If there is an open sub-block requiring explicit close-out, |
* If there is an open sub-block requiring explicit close-out, |
* postpone closing out the current block |
* postpone closing out the current block |
Line 1413 blk_part_exp(MACRO_PROT_ARGS) |
|
Line 1438 blk_part_exp(MACRO_PROT_ARGS) |
|
if (NULL == head && ARGS_QWORD != ac && |
if (NULL == head && ARGS_QWORD != ac && |
DELIM_OPEN == mdoc_isdelim(p)) { |
DELIM_OPEN == mdoc_isdelim(p)) { |
assert(NULL == body); |
assert(NULL == body); |
if ( ! dword(mdoc, line, la, p, DELIM_OPEN)) |
if ( ! dword(mdoc, line, la, p, DELIM_OPEN, 0)) |
return(0); |
return(0); |
continue; |
continue; |
} |
} |
|
|
if (NULL == head) { |
if (NULL == head) { |
assert(NULL == body); |
assert(NULL == body); |
Line 1434 blk_part_exp(MACRO_PROT_ARGS) |
|
Line 1459 blk_part_exp(MACRO_PROT_ARGS) |
|
assert(head); |
assert(head); |
/* No check whether it's a macro! */ |
/* No check whether it's a macro! */ |
if (MDOC_Eo == tok) |
if (MDOC_Eo == tok) |
if ( ! dword(mdoc, line, la, p, DELIM_MAX)) |
if ( ! dword(mdoc, line, la, p, DELIM_MAX, 0)) |
return(0); |
return(0); |
|
|
if ( ! rew_sub(MDOC_HEAD, mdoc, tok, line, ppos)) |
if ( ! rew_sub(MDOC_HEAD, mdoc, tok, line, ppos)) |
Line 1452 blk_part_exp(MACRO_PROT_ARGS) |
|
Line 1477 blk_part_exp(MACRO_PROT_ARGS) |
|
ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup(tok, p); |
ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup(tok, p); |
|
|
if (MDOC_MAX == ntok) { |
if (MDOC_MAX == ntok) { |
if ( ! dword(mdoc, line, la, p, DELIM_MAX)) |
if ( ! dword(mdoc, line, la, p, DELIM_MAX, |
|
MDOC_JOIN & mdoc_macros[tok].flags)) |
return(0); |
return(0); |
continue; |
continue; |
} |
} |
Line 1556 in_line_argn(MACRO_PROT_ARGS) |
|
Line 1582 in_line_argn(MACRO_PROT_ARGS) |
|
if ( ! (MDOC_IGNDELIM & mdoc_macros[tok].flags) && |
if ( ! (MDOC_IGNDELIM & mdoc_macros[tok].flags) && |
ARGS_QWORD != ac && 0 == j && |
ARGS_QWORD != ac && 0 == j && |
DELIM_OPEN == mdoc_isdelim(p)) { |
DELIM_OPEN == mdoc_isdelim(p)) { |
if ( ! dword(mdoc, line, la, p, DELIM_OPEN)) |
if ( ! dword(mdoc, line, la, p, DELIM_OPEN, 0)) |
return(0); |
return(0); |
continue; |
continue; |
} else if (0 == j) |
} else if (0 == j) |
Line 1590 in_line_argn(MACRO_PROT_ARGS) |
|
Line 1616 in_line_argn(MACRO_PROT_ARGS) |
|
flushed = 1; |
flushed = 1; |
} |
} |
|
|
if ( ! dword(mdoc, line, la, p, DELIM_MAX)) |
if ( ! dword(mdoc, line, la, p, DELIM_MAX, |
|
MDOC_JOIN & mdoc_macros[tok].flags)) |
return(0); |
return(0); |
j++; |
j++; |
} |
} |
Line 1661 in_line_eoln(MACRO_PROT_ARGS) |
|
Line 1688 in_line_eoln(MACRO_PROT_ARGS) |
|
ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup(tok, p); |
ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup(tok, p); |
|
|
if (MDOC_MAX == ntok) { |
if (MDOC_MAX == ntok) { |
if ( ! dword(mdoc, line, la, p, DELIM_MAX)) |
if ( ! dword(mdoc, line, la, p, DELIM_MAX, |
|
MDOC_JOIN & mdoc_macros[tok].flags)) |
return(0); |
return(0); |
continue; |
continue; |
} |
} |
Line 1741 phrase(struct mdoc *mdoc, int line, int ppos, char *bu |
|
Line 1769 phrase(struct mdoc *mdoc, int line, int ppos, char *bu |
|
ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup_raw(p); |
ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup_raw(p); |
|
|
if (MDOC_MAX == ntok) { |
if (MDOC_MAX == ntok) { |
if ( ! dword(mdoc, line, la, p, DELIM_MAX)) |
if ( ! dword(mdoc, line, la, p, DELIM_MAX, 1)) |
return(0); |
return(0); |
continue; |
continue; |
} |
} |
Line 1759 phrase(struct mdoc *mdoc, int line, int ppos, char *bu |
|
Line 1787 phrase(struct mdoc *mdoc, int line, int ppos, char *bu |
|
static int |
static int |
phrase_ta(MACRO_PROT_ARGS) |
phrase_ta(MACRO_PROT_ARGS) |
{ |
{ |
|
struct mdoc_node *n; |
int la; |
int la; |
enum mdoct ntok; |
enum mdoct ntok; |
enum margserr ac; |
enum margserr ac; |
char *p; |
char *p; |
|
|
/* |
/* Make sure we are in a column list or ignore this macro. */ |
* FIXME: this is overly restrictive: if the `Ta' is unexpected, |
n = mdoc->last; |
* it should simply error out with ARGSLOST. |
while (NULL != n && MDOC_Bl != n->tok) |
*/ |
n = n->parent; |
|
if (NULL == n || LIST_column != n->norm->Bl.type) { |
|
mdoc_pmsg(mdoc, line, ppos, MANDOCERR_STRAYTA); |
|
return(1); |
|
} |
|
|
|
/* Advance to the next column. */ |
if ( ! rew_sub(MDOC_BODY, mdoc, MDOC_It, line, ppos)) |
if ( ! rew_sub(MDOC_BODY, mdoc, MDOC_It, line, ppos)) |
return(0); |
return(0); |
if ( ! mdoc_body_alloc(mdoc, line, ppos, MDOC_It)) |
if ( ! mdoc_body_alloc(mdoc, line, ppos, MDOC_It)) |
Line 1786 phrase_ta(MACRO_PROT_ARGS) |
|
Line 1820 phrase_ta(MACRO_PROT_ARGS) |
|
ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup_raw(p); |
ntok = ARGS_QWORD == ac ? MDOC_MAX : lookup_raw(p); |
|
|
if (MDOC_MAX == ntok) { |
if (MDOC_MAX == ntok) { |
if ( ! dword(mdoc, line, la, p, DELIM_MAX)) |
if ( ! dword(mdoc, line, la, p, DELIM_MAX, |
|
MDOC_JOIN & mdoc_macros[tok].flags)) |
return(0); |
return(0); |
continue; |
continue; |
} |
} |