]>
git.cameronkatri.com Git - mandoc.git/blob - man_action.c
1 /* $Id: man_action.c,v 1.26 2010/03/22 14:03:03 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
] = {
75 man_action_post(struct man
*m
)
78 if (MAN_ACTED
& m
->last
->flags
)
80 m
->last
->flags
|= MAN_ACTED
;
82 switch (m
->last
->type
) {
91 if (NULL
== man_actions
[m
->last
->tok
].post
)
93 return((*man_actions
[m
->last
->tok
].post
)(m
));
98 post_fi(struct man
*m
)
101 if ( ! (MAN_LITERAL
& m
->flags
))
102 if ( ! man_nwarn(m
, m
->last
, WNLITERAL
))
104 m
->flags
&= ~MAN_LITERAL
;
110 post_nf(struct man
*m
)
113 if (MAN_LITERAL
& m
->flags
)
114 if ( ! man_nwarn(m
, m
->last
, WOLITERAL
))
116 m
->flags
|= MAN_LITERAL
;
122 post_TH(struct man
*m
)
133 free(m
->meta
.source
);
135 m
->meta
.title
= m
->meta
.vol
= m
->meta
.source
= NULL
;
139 /* ->TITLE<- MSEC DATE SOURCE VOL */
143 m
->meta
.title
= mandoc_strdup(n
->string
);
145 /* TITLE ->MSEC<- DATE SOURCE VOL */
150 lval
= strtol(n
->string
, &ep
, 10);
151 if (n
->string
[0] != '\0' && *ep
== '\0')
152 m
->meta
.msec
= (int)lval
;
153 else if ( ! man_nwarn(m
, n
, WMSEC
))
156 /* TITLE MSEC ->DATE<- SOURCE VOL */
160 m
->meta
.date
= mandoc_a2time
161 (MTIME_ISO_8601
, n
->string
);
163 if (0 == m
->meta
.date
) {
164 if ( ! man_nwarn(m
, n
, WDATE
))
166 m
->meta
.date
= time(NULL
);
169 m
->meta
.date
= time(NULL
);
171 /* TITLE MSEC DATE ->SOURCE<- VOL */
173 if (n
&& (n
= n
->next
))
174 m
->meta
.source
= mandoc_strdup(n
->string
);
176 /* TITLE MSEC DATE SOURCE ->VOL<- */
178 if (n
&& (n
= n
->next
))
179 m
->meta
.vol
= mandoc_strdup(n
->string
);
182 man_node_unlink(m
, n
);
183 man_node_freelist(n
);