]>
git.cameronkatri.com Git - mandoc.git/blob - man_action.c
7e3cde24a0ae2fca3050ff4636edc81afc983f02
1 /* $Id: man_action.c,v 1.27 2010/03/23 11:30:48 kristaps Exp $ */
3 * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
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.
21 #include <sys/utsname.h>
28 #include "libmandoc.h"
31 int (*post
)(struct man
*);
34 static int post_TH(struct man
*);
35 static int post_fi(struct man
*);
36 static int post_nf(struct man
*);
38 const struct actions man_actions
[MAN_MAX
] = {
78 man_action_post(struct man
*m
)
81 if (MAN_ACTED
& m
->last
->flags
)
83 m
->last
->flags
|= MAN_ACTED
;
85 switch (m
->last
->type
) {
94 if (NULL
== man_actions
[m
->last
->tok
].post
)
96 return((*man_actions
[m
->last
->tok
].post
)(m
));
101 post_fi(struct man
*m
)
104 if ( ! (MAN_LITERAL
& m
->flags
))
105 if ( ! man_nwarn(m
, m
->last
, WNLITERAL
))
107 m
->flags
&= ~MAN_LITERAL
;
113 post_nf(struct man
*m
)
116 if (MAN_LITERAL
& m
->flags
)
117 if ( ! man_nwarn(m
, m
->last
, WOLITERAL
))
119 m
->flags
|= MAN_LITERAL
;
125 post_TH(struct man
*m
)
136 free(m
->meta
.source
);
138 m
->meta
.title
= m
->meta
.vol
= m
->meta
.source
= NULL
;
142 /* ->TITLE<- MSEC DATE SOURCE VOL */
146 m
->meta
.title
= mandoc_strdup(n
->string
);
148 /* TITLE ->MSEC<- DATE SOURCE VOL */
153 lval
= strtol(n
->string
, &ep
, 10);
154 if (n
->string
[0] != '\0' && *ep
== '\0')
155 m
->meta
.msec
= (int)lval
;
156 else if ( ! man_nwarn(m
, n
, WMSEC
))
159 /* TITLE MSEC ->DATE<- SOURCE VOL */
163 m
->meta
.date
= mandoc_a2time
164 (MTIME_ISO_8601
, n
->string
);
166 if (0 == m
->meta
.date
) {
167 if ( ! man_nwarn(m
, n
, WDATE
))
169 m
->meta
.date
= time(NULL
);
172 m
->meta
.date
= time(NULL
);
174 /* TITLE MSEC DATE ->SOURCE<- VOL */
176 if (n
&& (n
= n
->next
))
177 m
->meta
.source
= mandoc_strdup(n
->string
);
179 /* TITLE MSEC DATE SOURCE ->VOL<- */
181 if (n
&& (n
= n
->next
))
182 m
->meta
.vol
= mandoc_strdup(n
->string
);
185 man_node_unlink(m
, n
);
186 man_node_freelist(n
);