version 1.7, 2011/04/05 13:12:34 |
version 1.8, 2011/04/05 14:10:52 |
Line 66 static void dbt_append(DBT *, size_t *, const char |
|
Line 66 static void dbt_append(DBT *, size_t *, const char |
|
static void dbt_appendb(DBT *, size_t *, |
static void dbt_appendb(DBT *, size_t *, |
const void *, size_t); |
const void *, size_t); |
static void dbt_init(DBT *, size_t *); |
static void dbt_init(DBT *, size_t *); |
|
static void dbt_put(DB *, const char *, DBT *, DBT *); |
static void usage(void); |
static void usage(void); |
static void pman(DB *, const char *, |
static void pman(DB *, const char *, |
DBT *, size_t *, DBT *, |
DBT *, size_t *, DBT *, |
Line 619 pmdoc_Nm(MDOC_ARGS) |
|
Line 620 pmdoc_Nm(MDOC_ARGS) |
|
memcpy(val->data, &fl, 4); |
memcpy(val->data, &fl, 4); |
} |
} |
|
|
|
static void |
|
dbt_put(DB *db, const char *dbn, DBT *key, DBT *val) |
|
{ |
|
|
|
if (0 == key->size) |
|
return; |
|
|
|
assert(key->data); |
|
assert(8 == val->size); |
|
assert(val->data); |
|
|
|
if (0 == (*db->put)(db, key, val, 0)) |
|
return; |
|
|
|
perror(dbn); |
|
exit((int)MANDOCLEVEL_SYSERR); |
|
/* NOTREACHED */ |
|
} |
|
|
/* |
/* |
* Call out to per-macro handlers after clearing the persistent database |
* Call out to per-macro handlers after clearing the persistent database |
* key. If the macro sets the database key, flush it to the database. |
* key. If the macro sets the database key, flush it to the database. |
Line 646 pmdoc_node(MDOC_ARGS) |
|
Line 666 pmdoc_node(MDOC_ARGS) |
|
dbt_init(key, ksz); |
dbt_init(key, ksz); |
(*mdocs[n->tok])(db, dbn, key, ksz, val, n); |
(*mdocs[n->tok])(db, dbn, key, ksz, val, n); |
|
|
if (0 == key->size) |
dbt_put(db, dbn, key, val); |
break; |
break; |
if (0 == (*db->put)(db, key, val, 0)) |
|
break; |
|
|
|
perror(dbn); |
|
exit((int)MANDOCLEVEL_SYSERR); |
|
/* NOTREACHED */ |
|
default: |
default: |
break; |
break; |
} |
} |
|
|
pman_node(MAN_ARGS) |
pman_node(MAN_ARGS) |
{ |
{ |
const struct man_node *head, *body; |
const struct man_node *head, *body; |
const char *end, *start; |
const char *start; |
char nil; |
char nil; |
|
size_t sz; |
uint32_t fl; |
uint32_t fl; |
|
|
if (NULL == n) |
if (NULL == n) |
Line 692 pman_node(MAN_ARGS) |
|
Line 707 pman_node(MAN_ARGS) |
|
MAN_TEXT == body->type) { |
MAN_TEXT == body->type) { |
nil = '\0'; |
nil = '\0'; |
|
|
start = body->string; |
|
if (NULL == (end = strchr(start, ' '))) |
|
end = start + strlen(start); |
|
|
|
dbt_init(key, ksz); |
|
dbt_appendb(key, ksz, start, end - start + 1); |
|
dbt_appendb(key, ksz, &nil, 1); |
|
fl = MANDOC_NAME; |
fl = MANDOC_NAME; |
memcpy(val->data, &fl, 4); |
memcpy(val->data, &fl, 4); |
|
|
|
start = body->string; |
|
|
|
/* |
|
* Go through a special heuristic dance here. |
|
* This is why -man manuals are great! |
|
* Conventionally, one or more manual names are |
|
* comma-specified prior to a whitespace, then a |
|
* dash, then a description. Try to puzzle out |
|
* the name parts here. |
|
*/ |
|
|
|
while (start) { |
|
sz = strcspn(start, " ,"); |
|
if ('\0' == start[(int)sz]) |
|
break; |
|
|
|
dbt_init(key, ksz); |
|
dbt_appendb(key, ksz, start, sz); |
|
dbt_appendb(key, ksz, &nil, 1); |
|
|
|
dbt_put(db, dbn, key, val); |
|
|
|
if (' ' == start[(int)sz]) |
|
break; |
|
|
|
assert(',' == start[(int)sz]); |
|
start += (int)sz + 1; |
|
while (' ' == *start) |
|
start++; |
|
} |
|
|
return(1); |
return(1); |
} |
} |
} |
} |