version 1.169, 2014/11/19 20:40:51 |
version 1.172, 2014/12/04 17:36:00 |
|
|
STMT__MAX |
STMT__MAX |
}; |
}; |
|
|
typedef int (*mdoc_fp)(struct mpage *, const struct mdoc_node *); |
typedef int (*mdoc_fp)(struct mpage *, const struct mdoc_meta *, |
|
const struct mdoc_node *); |
|
|
struct mdoc_handler { |
struct mdoc_handler { |
mdoc_fp fp; /* optional handler */ |
mdoc_fp fp; /* optional handler */ |
Line 154 static void mpages_merge(struct mchars *, struct mpar |
|
Line 155 static void mpages_merge(struct mchars *, struct mpar |
|
static void names_check(void); |
static void names_check(void); |
static void parse_cat(struct mpage *, int); |
static void parse_cat(struct mpage *, int); |
static void parse_man(struct mpage *, const struct man_node *); |
static void parse_man(struct mpage *, const struct man_node *); |
static void parse_mdoc(struct mpage *, const struct mdoc_node *); |
static void parse_mdoc(struct mpage *, const struct mdoc_meta *, |
static int parse_mdoc_body(struct mpage *, const struct mdoc_node *); |
const struct mdoc_node *); |
static int parse_mdoc_head(struct mpage *, const struct mdoc_node *); |
static int parse_mdoc_body(struct mpage *, const struct mdoc_meta *, |
static int parse_mdoc_Fd(struct mpage *, const struct mdoc_node *); |
const struct mdoc_node *); |
static int parse_mdoc_Fn(struct mpage *, const struct mdoc_node *); |
static int parse_mdoc_head(struct mpage *, const struct mdoc_meta *, |
static int parse_mdoc_Nd(struct mpage *, const struct mdoc_node *); |
const struct mdoc_node *); |
static int parse_mdoc_Nm(struct mpage *, const struct mdoc_node *); |
static int parse_mdoc_Fd(struct mpage *, const struct mdoc_meta *, |
static int parse_mdoc_Sh(struct mpage *, const struct mdoc_node *); |
const struct mdoc_node *); |
static int parse_mdoc_Xr(struct mpage *, const struct mdoc_node *); |
static int parse_mdoc_Fn(struct mpage *, const struct mdoc_meta *, |
|
const struct mdoc_node *); |
|
static int parse_mdoc_Nd(struct mpage *, const struct mdoc_meta *, |
|
const struct mdoc_node *); |
|
static int parse_mdoc_Nm(struct mpage *, const struct mdoc_meta *, |
|
const struct mdoc_node *); |
|
static int parse_mdoc_Sh(struct mpage *, const struct mdoc_meta *, |
|
const struct mdoc_node *); |
|
static int parse_mdoc_Xr(struct mpage *, const struct mdoc_meta *, |
|
const struct mdoc_node *); |
static void putkey(const struct mpage *, char *, uint64_t); |
static void putkey(const struct mpage *, char *, uint64_t); |
static void putkeys(const struct mpage *, |
static void putkeys(const struct mpage *, |
const char *, size_t, uint64_t); |
const char *, size_t, uint64_t); |
Line 1084 mpages_merge(struct mchars *mc, struct mparse *mp) |
|
Line 1094 mpages_merge(struct mchars *mc, struct mparse *mp) |
|
struct man *man; |
struct man *man; |
char *sodest; |
char *sodest; |
char *cp; |
char *cp; |
pid_t child_pid; |
|
int fd; |
int fd; |
unsigned int pslot; |
unsigned int pslot; |
enum mandoclevel lvl; |
enum mandoclevel lvl; |
Line 1094 mpages_merge(struct mchars *mc, struct mparse *mp) |
|
Line 1103 mpages_merge(struct mchars *mc, struct mparse *mp) |
|
str_info.free = hash_free; |
str_info.free = hash_free; |
str_info.key_offset = offsetof(struct str, key); |
str_info.key_offset = offsetof(struct str, key); |
|
|
if (0 == nodb) |
if ( ! nodb) |
SQL_EXEC("BEGIN TRANSACTION"); |
SQL_EXEC("BEGIN TRANSACTION"); |
|
|
mpage = ohash_first(&mpages, &pslot); |
mpage = ohash_first(&mpages, &pslot); |
while (NULL != mpage) { |
while (mpage != NULL) { |
mlinks_undupe(mpage); |
mlinks_undupe(mpage); |
if (NULL == mpage->mlinks) { |
if (mpage->mlinks == NULL) { |
mpage = ohash_next(&mpages, &pslot); |
mpage = ohash_next(&mpages, &pslot); |
continue; |
continue; |
} |
} |
Line 1112 mpages_merge(struct mchars *mc, struct mparse *mp) |
|
Line 1121 mpages_merge(struct mchars *mc, struct mparse *mp) |
|
mdoc = NULL; |
mdoc = NULL; |
man = NULL; |
man = NULL; |
sodest = NULL; |
sodest = NULL; |
child_pid = 0; |
|
|
|
mparse_open(mp, &fd, mpage->mlinks->file, &child_pid); |
mparse_open(mp, &fd, mpage->mlinks->file); |
if (fd == -1) { |
if (fd == -1) { |
say(mpage->mlinks->file, "&open"); |
say(mpage->mlinks->file, "&open"); |
goto nextpage; |
goto nextpage; |
Line 1125 mpages_merge(struct mchars *mc, struct mparse *mp) |
|
Line 1133 mpages_merge(struct mchars *mc, struct mparse *mp) |
|
* source code, unless it is already known to be |
* source code, unless it is already known to be |
* formatted. Fall back to formatted mode. |
* formatted. Fall back to formatted mode. |
*/ |
*/ |
if (FORM_CAT != mpage->mlinks->dform || |
if (mpage->mlinks->dform != FORM_CAT || |
FORM_CAT != mpage->mlinks->fform) { |
mpage->mlinks->fform != FORM_CAT) { |
lvl = mparse_readfd(mp, fd, mpage->mlinks->file); |
lvl = mparse_readfd(mp, fd, mpage->mlinks->file); |
if (lvl < MANDOCLEVEL_FATAL) |
if (lvl < MANDOCLEVEL_FATAL) |
mparse_result(mp, &mdoc, &man, &sodest); |
mparse_result(mp, &mdoc, &man, &sodest); |
} |
} |
|
|
if (NULL != sodest) { |
if (sodest != NULL) { |
mlink_dest = ohash_find(&mlinks, |
mlink_dest = ohash_find(&mlinks, |
ohash_qlookup(&mlinks, sodest)); |
ohash_qlookup(&mlinks, sodest)); |
if (NULL != mlink_dest) { |
if (mlink_dest == NULL) { |
|
mandoc_asprintf(&cp, "%s.gz", sodest); |
|
mlink_dest = ohash_find(&mlinks, |
|
ohash_qlookup(&mlinks, cp)); |
|
free(cp); |
|
} |
|
if (mlink_dest != NULL) { |
|
|
/* The .so target exists. */ |
/* The .so target exists. */ |
|
|
Line 1156 mpages_merge(struct mchars *mc, struct mparse *mp) |
|
Line 1170 mpages_merge(struct mchars *mc, struct mparse *mp) |
|
if (mpage_dest->pageid) |
if (mpage_dest->pageid) |
dbadd_mlink_name(mlink); |
dbadd_mlink_name(mlink); |
|
|
if (NULL == mlink->next) |
if (mlink->next == NULL) |
break; |
break; |
mlink = mlink->next; |
mlink = mlink->next; |
} |
} |
Line 1168 mpages_merge(struct mchars *mc, struct mparse *mp) |
|
Line 1182 mpages_merge(struct mchars *mc, struct mparse *mp) |
|
mpage->mlinks = NULL; |
mpage->mlinks = NULL; |
} |
} |
goto nextpage; |
goto nextpage; |
} else if (NULL != mdoc) { |
} else if (mdoc != NULL) { |
mpage->form = FORM_SRC; |
mpage->form = FORM_SRC; |
mpage->sec = mdoc_meta(mdoc)->msec; |
mpage->sec = mdoc_meta(mdoc)->msec; |
mpage->sec = mandoc_strdup( |
mpage->sec = mandoc_strdup( |
NULL == mpage->sec ? "" : mpage->sec); |
mpage->sec == NULL ? "" : mpage->sec); |
mpage->arch = mdoc_meta(mdoc)->arch; |
mpage->arch = mdoc_meta(mdoc)->arch; |
mpage->arch = mandoc_strdup( |
mpage->arch = mandoc_strdup( |
NULL == mpage->arch ? "" : mpage->arch); |
mpage->arch == NULL ? "" : mpage->arch); |
mpage->title = |
mpage->title = |
mandoc_strdup(mdoc_meta(mdoc)->title); |
mandoc_strdup(mdoc_meta(mdoc)->title); |
} else if (NULL != man) { |
} else if (man != NULL) { |
mpage->form = FORM_SRC; |
mpage->form = FORM_SRC; |
mpage->sec = |
mpage->sec = |
mandoc_strdup(man_meta(man)->msec); |
mandoc_strdup(man_meta(man)->msec); |
Line 1195 mpages_merge(struct mchars *mc, struct mparse *mp) |
|
Line 1209 mpages_merge(struct mchars *mc, struct mparse *mp) |
|
mpage->title = |
mpage->title = |
mandoc_strdup(mpage->mlinks->name); |
mandoc_strdup(mpage->mlinks->name); |
} |
} |
if (mpage->mlinks->gzip) |
|
mpage->form |= FORM_GZ; |
|
putkey(mpage, mpage->sec, TYPE_sec); |
putkey(mpage, mpage->sec, TYPE_sec); |
if (*mpage->arch != '\0') |
if (*mpage->arch != '\0') |
putkey(mpage, mpage->arch, TYPE_arch); |
putkey(mpage, mpage->arch, TYPE_arch); |
Line 1215 mpages_merge(struct mchars *mc, struct mparse *mp) |
|
Line 1227 mpages_merge(struct mchars *mc, struct mparse *mp) |
|
if (NULL != mdoc) { |
if (NULL != mdoc) { |
if (NULL != (cp = mdoc_meta(mdoc)->name)) |
if (NULL != (cp = mdoc_meta(mdoc)->name)) |
putkey(mpage, cp, NAME_HEAD); |
putkey(mpage, cp, NAME_HEAD); |
parse_mdoc(mpage, mdoc_node(mdoc)); |
parse_mdoc(mpage, mdoc_meta(mdoc), mdoc_node(mdoc)); |
} else if (NULL != man) |
} else if (NULL != man) |
parse_man(mpage, man_node(man)); |
parse_man(mpage, man_node(man)); |
else |
else |
Line 1231 mpages_merge(struct mchars *mc, struct mparse *mp) |
|
Line 1243 mpages_merge(struct mchars *mc, struct mparse *mp) |
|
dbadd(mpage, mc); |
dbadd(mpage, mc); |
|
|
nextpage: |
nextpage: |
if (child_pid && |
if (mparse_wait(mp) != MANDOCLEVEL_OK) { |
mparse_wait(mp, child_pid) != MANDOCLEVEL_OK) { |
|
exitcode = (int)MANDOCLEVEL_SYSERR; |
exitcode = (int)MANDOCLEVEL_SYSERR; |
say(mpage->mlinks->file, "&wait gunzip"); |
say(mpage->mlinks->file, "&wait gunzip"); |
} |
} |
Line 1541 parse_man(struct mpage *mpage, const struct man_node * |
|
Line 1552 parse_man(struct mpage *mpage, const struct man_node * |
|
} |
} |
|
|
static void |
static void |
parse_mdoc(struct mpage *mpage, const struct mdoc_node *n) |
parse_mdoc(struct mpage *mpage, const struct mdoc_meta *meta, |
|
const struct mdoc_node *n) |
{ |
{ |
|
|
assert(NULL != n); |
assert(NULL != n); |
Line 1557 parse_mdoc(struct mpage *mpage, const struct mdoc_node |
|
Line 1569 parse_mdoc(struct mpage *mpage, const struct mdoc_node |
|
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case MDOC_TAIL: |
case MDOC_TAIL: |
if (NULL != mdocs[n->tok].fp) |
if (NULL != mdocs[n->tok].fp) |
if (0 == (*mdocs[n->tok].fp)(mpage, n)) |
if (0 == (*mdocs[n->tok].fp)(mpage, meta, n)) |
break; |
break; |
if (mdocs[n->tok].mask) |
if (mdocs[n->tok].mask) |
putmdockey(mpage, n->child, |
putmdockey(mpage, n->child, |
Line 1568 parse_mdoc(struct mpage *mpage, const struct mdoc_node |
|
Line 1580 parse_mdoc(struct mpage *mpage, const struct mdoc_node |
|
continue; |
continue; |
} |
} |
if (NULL != n->child) |
if (NULL != n->child) |
parse_mdoc(mpage, n); |
parse_mdoc(mpage, meta, n); |
} |
} |
} |
} |
|
|
static int |
static int |
parse_mdoc_Fd(struct mpage *mpage, const struct mdoc_node *n) |
parse_mdoc_Fd(struct mpage *mpage, const struct mdoc_meta *meta, |
|
const struct mdoc_node *n) |
{ |
{ |
const char *start, *end; |
const char *start, *end; |
size_t sz; |
size_t sz; |
Line 1616 parse_mdoc_Fd(struct mpage *mpage, const struct mdoc_n |
|
Line 1629 parse_mdoc_Fd(struct mpage *mpage, const struct mdoc_n |
|
} |
} |
|
|
static int |
static int |
parse_mdoc_Fn(struct mpage *mpage, const struct mdoc_node *n) |
parse_mdoc_Fn(struct mpage *mpage, const struct mdoc_meta *meta, |
|
const struct mdoc_node *n) |
{ |
{ |
char *cp; |
char *cp; |
|
|
Line 1649 parse_mdoc_Fn(struct mpage *mpage, const struct mdoc_n |
|
Line 1663 parse_mdoc_Fn(struct mpage *mpage, const struct mdoc_n |
|
} |
} |
|
|
static int |
static int |
parse_mdoc_Xr(struct mpage *mpage, const struct mdoc_node *n) |
parse_mdoc_Xr(struct mpage *mpage, const struct mdoc_meta *meta, |
|
const struct mdoc_node *n) |
{ |
{ |
char *cp; |
char *cp; |
|
|
Line 1668 parse_mdoc_Xr(struct mpage *mpage, const struct mdoc_n |
|
Line 1683 parse_mdoc_Xr(struct mpage *mpage, const struct mdoc_n |
|
} |
} |
|
|
static int |
static int |
parse_mdoc_Nd(struct mpage *mpage, const struct mdoc_node *n) |
parse_mdoc_Nd(struct mpage *mpage, const struct mdoc_meta *meta, |
|
const struct mdoc_node *n) |
{ |
{ |
|
|
if (MDOC_BODY == n->type) |
if (MDOC_BODY == n->type) |
Line 1677 parse_mdoc_Nd(struct mpage *mpage, const struct mdoc_n |
|
Line 1693 parse_mdoc_Nd(struct mpage *mpage, const struct mdoc_n |
|
} |
} |
|
|
static int |
static int |
parse_mdoc_Nm(struct mpage *mpage, const struct mdoc_node *n) |
parse_mdoc_Nm(struct mpage *mpage, const struct mdoc_meta *meta, |
|
const struct mdoc_node *n) |
{ |
{ |
|
|
if (SEC_NAME == n->sec) |
if (SEC_NAME == n->sec) |
putmdockey(mpage, n->child, NAME_TITLE); |
putmdockey(mpage, n->child, NAME_TITLE); |
else if (SEC_SYNOPSIS == n->sec && MDOC_HEAD == n->type) |
else if (SEC_SYNOPSIS == n->sec && MDOC_HEAD == n->type) { |
putmdockey(mpage, n->child, NAME_SYN); |
if (n->child == NULL) |
|
putkey(mpage, meta->name, NAME_SYN); |
|
else |
|
putmdockey(mpage, n->child, NAME_SYN); |
|
} |
return(0); |
return(0); |
} |
} |
|
|
static int |
static int |
parse_mdoc_Sh(struct mpage *mpage, const struct mdoc_node *n) |
parse_mdoc_Sh(struct mpage *mpage, const struct mdoc_meta *meta, |
|
const struct mdoc_node *n) |
{ |
{ |
|
|
return(SEC_CUSTOM == n->sec && MDOC_HEAD == n->type); |
return(SEC_CUSTOM == n->sec && MDOC_HEAD == n->type); |
} |
} |
|
|
static int |
static int |
parse_mdoc_head(struct mpage *mpage, const struct mdoc_node *n) |
parse_mdoc_head(struct mpage *mpage, const struct mdoc_meta *meta, |
|
const struct mdoc_node *n) |
{ |
{ |
|
|
return(MDOC_HEAD == n->type); |
return(MDOC_HEAD == n->type); |
} |
} |
|
|
static int |
static int |
parse_mdoc_body(struct mpage *mpage, const struct mdoc_node *n) |
parse_mdoc_body(struct mpage *mpage, const struct mdoc_meta *meta, |
|
const struct mdoc_node *n) |
{ |
{ |
|
|
return(MDOC_BODY == n->type); |
return(MDOC_BODY == n->type); |