]>
git.cameronkatri.com Git - mandoc.git/blob - man_action.c
1 /* $Id: man_action.c,v 1.33 2010/05/15 20:51:40 kristaps Exp $ */
3 * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
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.
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.
26 #include "libmandoc.h"
29 int (*post
)(struct man
*);
32 static int post_TH(struct man
*);
33 static int post_de(struct man
*);
34 static int post_fi(struct man
*);
35 static int post_nf(struct man
*);
37 const struct actions man_actions
[MAN_MAX
] = {
74 { post_de
}, /* dei */
76 { post_de
}, /* ami */
82 man_action_post(struct man
*m
)
85 if (MAN_ACTED
& m
->last
->flags
)
87 m
->last
->flags
|= MAN_ACTED
;
89 switch (m
->last
->type
) {
98 if (NULL
== man_actions
[m
->last
->tok
].post
)
100 return((*man_actions
[m
->last
->tok
].post
)(m
));
105 post_fi(struct man
*m
)
108 if ( ! (MAN_LITERAL
& m
->flags
))
109 if ( ! man_nwarn(m
, m
->last
, WNLITERAL
))
111 m
->flags
&= ~MAN_LITERAL
;
117 post_de(struct man
*m
)
121 * XXX: for the time being, we indiscriminately remove roff
122 * instructions from the parse stream.
124 if (MAN_BLOCK
== m
->last
->type
)
125 man_node_delete(m
, m
->last
);
131 post_nf(struct man
*m
)
134 if (MAN_LITERAL
& m
->flags
)
135 if ( ! man_nwarn(m
, m
->last
, WOLITERAL
))
137 m
->flags
|= MAN_LITERAL
;
143 post_TH(struct man
*m
)
152 free(m
->meta
.source
);
156 m
->meta
.title
= m
->meta
.vol
=
157 m
->meta
.msec
= m
->meta
.source
= NULL
;
160 /* ->TITLE<- MSEC DATE SOURCE VOL */
164 m
->meta
.title
= mandoc_strdup(n
->string
);
166 /* TITLE ->MSEC<- DATE SOURCE VOL */
170 m
->meta
.msec
= mandoc_strdup(n
->string
);
172 /* TITLE MSEC ->DATE<- SOURCE VOL */
176 m
->meta
.date
= mandoc_a2time
177 (MTIME_ISO_8601
, n
->string
);
178 if (0 == m
->meta
.date
) {
179 if ( ! man_nwarn(m
, n
, WDATE
))
181 m
->meta
.date
= time(NULL
);
184 m
->meta
.date
= time(NULL
);
186 /* TITLE MSEC DATE ->SOURCE<- VOL */
188 if (n
&& (n
= n
->next
))
189 m
->meta
.source
= mandoc_strdup(n
->string
);
191 /* TITLE MSEC DATE SOURCE ->VOL<- */
193 if (n
&& (n
= n
->next
))
194 m
->meta
.vol
= mandoc_strdup(n
->string
);
197 * Remove the `TH' node after we've processed it for our
200 man_node_delete(m
, m
->last
);