version 1.47, 2009/10/30 18:50:11 |
version 1.57, 2010/05/14 16:02:29 |
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
*/ |
*/ |
|
#ifdef HAVE_CONFIG_H |
|
#include "config.h" |
|
#endif |
|
|
#ifndef OSNAME |
#ifndef OSNAME |
#include <sys/utsname.h> |
#include <sys/utsname.h> |
#endif |
#endif |
|
|
#include <assert.h> |
#include <assert.h> |
#include <errno.h> |
|
#include <stdio.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <stdlib.h> |
#include <string.h> |
#include <string.h> |
|
|
|
|
static int concat(struct mdoc *, char *, |
static int concat(struct mdoc *, char *, |
const struct mdoc_node *, size_t); |
const struct mdoc_node *, size_t); |
static inline int order_rs(int); |
static inline int order_rs(enum mdoct); |
|
|
#ifdef __linux__ |
|
extern size_t strlcat(char *, const char *, size_t); |
|
#endif |
|
|
|
static int post_ar(POST_ARGS); |
static int post_ar(POST_ARGS); |
static int post_at(POST_ARGS); |
static int post_at(POST_ARGS); |
static int post_bl(POST_ARGS); |
static int post_bl(POST_ARGS); |
Line 197 static const struct actions mdoc_actions[MDOC_MAX] = { |
|
Line 196 static const struct actions mdoc_actions[MDOC_MAX] = { |
|
|
|
#define RSORD_MAX 14 |
#define RSORD_MAX 14 |
|
|
static const int rsord[RSORD_MAX] = { |
static const enum mdoct rsord[RSORD_MAX] = { |
MDOC__A, |
MDOC__A, |
MDOC__T, |
MDOC__T, |
MDOC__B, |
MDOC__B, |
Line 367 post_st(POST_ARGS) |
|
Line 366 post_st(POST_ARGS) |
|
|
|
assert(MDOC_TEXT == n->child->type); |
assert(MDOC_TEXT == n->child->type); |
p = mdoc_a2st(n->child->string); |
p = mdoc_a2st(n->child->string); |
assert(p); |
if (p != NULL) { |
free(n->child->string); |
free(n->child->string); |
n->child->string = mandoc_strdup(p); |
n->child->string = mandoc_strdup(p); |
|
} |
return(1); |
return(1); |
} |
} |
|
|
Line 382 post_st(POST_ARGS) |
|
Line 382 post_st(POST_ARGS) |
|
static int |
static int |
post_at(POST_ARGS) |
post_at(POST_ARGS) |
{ |
{ |
struct mdoc_node *nn; |
struct mdoc_node *nn; |
const char *p; |
const char *p, *q; |
|
char *buf; |
|
size_t sz; |
|
|
if (n->child) { |
if (n->child) { |
assert(MDOC_TEXT == n->child->type); |
assert(MDOC_TEXT == n->child->type); |
p = mdoc_a2att(n->child->string); |
p = mdoc_a2att(n->child->string); |
assert(p); |
if (p) { |
free(n->child->string); |
free(n->child->string); |
n->child->string = mandoc_strdup(p); |
n->child->string = mandoc_strdup(p); |
|
} else { |
|
p = "AT&T UNIX "; |
|
q = n->child->string; |
|
sz = strlen(p) + strlen(q) + 1; |
|
buf = mandoc_malloc(sz); |
|
strlcpy(buf, p, sz); |
|
strlcat(buf, q, sz); |
|
free(n->child->string); |
|
n->child->string = buf; |
|
} |
return(1); |
return(1); |
} |
} |
|
|
Line 420 post_sh(POST_ARGS) |
|
Line 432 post_sh(POST_ARGS) |
|
|
|
if ( ! concat(m, buf, n->child, BUFSIZ)) |
if ( ! concat(m, buf, n->child, BUFSIZ)) |
return(0); |
return(0); |
sec = mdoc_atosec(buf); |
sec = mdoc_str2sec(buf); |
if (SEC_CUSTOM != sec) |
/* |
|
* The first section should always make us move into a non-new |
|
* state. |
|
*/ |
|
if (SEC_NONE == m->lastnamed || SEC_CUSTOM != sec) |
m->lastnamed = sec; |
m->lastnamed = sec; |
|
|
/* Some sections only live in certain manual sections. */ |
/* Some sections only live in certain manual sections. */ |
Line 504 post_dt(POST_ARGS) |
|
Line 520 post_dt(POST_ARGS) |
|
if (cp) { |
if (cp) { |
/* FIXME: where is strtonum!? */ |
/* FIXME: where is strtonum!? */ |
m->meta.vol = mandoc_strdup(cp); |
m->meta.vol = mandoc_strdup(cp); |
errno = 0; |
|
lval = strtol(nn->string, &ep, 10); |
lval = strtol(nn->string, &ep, 10); |
if (nn->string[0] != '\0' && *ep == '\0') |
if (nn->string[0] != '\0' && *ep == '\0') |
m->meta.msec = (int)lval; |
m->meta.msec = (int)lval; |
|
|
post_bl_width(POST_ARGS) |
post_bl_width(POST_ARGS) |
{ |
{ |
size_t width; |
size_t width; |
int i, tok; |
int i; |
|
enum mdoct tok; |
char buf[NUMSIZ]; |
char buf[NUMSIZ]; |
char *p; |
char *p; |
|
|
Line 726 post_bl_head(POST_ARGS) |
|
Line 742 post_bl_head(POST_ARGS) |
|
nn->string = NULL; |
nn->string = NULL; |
nnp = nn; |
nnp = nn; |
nn = nn->next; |
nn = nn->next; |
mdoc_node_free(nnp); |
mdoc_node_delete(NULL, nnp); |
} |
} |
|
|
n->nchild = 0; |
n->nchild = 0; |
Line 820 post_ar(POST_ARGS) |
|
Line 836 post_ar(POST_ARGS) |
|
|
|
|
|
/* |
/* |
* Parse the date field in `Dd', primarily through mdoc_atotime(). |
* Parse the date field in `Dd'. |
* FIXME: push mdoc_atotime() into here. |
|
*/ |
*/ |
static int |
static int |
post_dd(POST_ARGS) |
post_dd(POST_ARGS) |
Line 831 post_dd(POST_ARGS) |
|
Line 846 post_dd(POST_ARGS) |
|
if ( ! concat(m, buf, n->child, DATESIZ)) |
if ( ! concat(m, buf, n->child, DATESIZ)) |
return(0); |
return(0); |
|
|
m->meta.date = mdoc_atotime(buf); |
m->meta.date = mandoc_a2time |
|
(MTIME_MDOCDATE | MTIME_CANONICAL, buf); |
|
|
if (0 == m->meta.date) { |
if (0 == m->meta.date) { |
if ( ! mdoc_nwarn(m, n, EBADDATE)) |
if ( ! mdoc_nwarn(m, n, EBADDATE)) |
return(0); |
return(0); |
Line 850 post_dd(POST_ARGS) |
|
Line 867 post_dd(POST_ARGS) |
|
static int |
static int |
post_prol(POST_ARGS) |
post_prol(POST_ARGS) |
{ |
{ |
struct mdoc_node *np; |
|
|
|
if (n->parent->child == n) |
mdoc_node_delete(m, n); |
n->parent->child = n->prev; |
|
if (n->prev) |
|
n->prev->next = NULL; |
|
|
|
np = n; |
|
assert(NULL == n->next); |
|
|
|
if (n->prev) { |
|
m->last = n->prev; |
|
m->next = MDOC_NEXT_SIBLING; |
|
} else { |
|
m->last = n->parent; |
|
m->next = MDOC_NEXT_CHILD; |
|
} |
|
|
|
mdoc_node_freelist(np); |
|
|
|
if (m->meta.title && m->meta.date && m->meta.os) |
if (m->meta.title && m->meta.date && m->meta.os) |
m->flags |= MDOC_PBODY; |
m->flags |= MDOC_PBODY; |
|
|
return(1); |
return(1); |
} |
} |
|
|
Line 960 post_display(POST_ARGS) |
|
Line 958 post_display(POST_ARGS) |
|
|
|
|
|
static inline int |
static inline int |
order_rs(int t) |
order_rs(enum mdoct t) |
{ |
{ |
int i; |
int i; |
|
|
for (i = 0; i < RSORD_MAX; i++) |
for (i = 0; i < (int)RSORD_MAX; i++) |
if (rsord[i] == t) |
if (rsord[i] == t) |
return(i); |
return(i); |
|
|