=================================================================== RCS file: /cvs/mandoc/mdoc.c,v retrieving revision 1.3 retrieving revision 1.5 diff -u -p -r1.3 -r1.5 --- mandoc/mdoc.c 2008/12/17 17:18:38 1.3 +++ mandoc/mdoc.c 2008/12/28 00:34:20 1.5 @@ -1,4 +1,4 @@ -/* $Id: mdoc.c,v 1.3 2008/12/17 17:18:38 kristaps Exp $ */ +/* $Id: mdoc.c,v 1.5 2008/12/28 00:34:20 kristaps Exp $ */ /* * Copyright (c) 2008 Kristaps Dzonsons * @@ -86,16 +86,16 @@ const struct mdoc_macro __mdoc_macros[MDOC_MAX] = { { NULL, 0 }, /* \" */ { macro_prologue_ddate, 0 }, /* Dd */ { macro_prologue_dtitle, 0 }, /* Dt */ - { NULL, 0 }, /* Os */ + { macro_prologue_os, 0 }, /* Os */ { macro_scoped_implicit, 0 }, /* Sh */ { macro_scoped_implicit, 0 }, /* Ss */ - { NULL, 0 }, /* Pp */ + { macro_text, 0 }, /* Pp */ { NULL, 0 }, /* D1 */ { NULL, 0 }, /* Dl */ - { NULL, 0 }, /* Bd */ - { NULL, 0 }, /* Ed */ - { NULL, 0 }, /* Bl */ - { NULL, 0 }, /* El */ + { macro_scoped_explicit, MDOC_EXPLICIT }, /* Bd */ + { macro_scoped_explicit, 0 }, /* Ed */ + { macro_scoped_explicit, MDOC_EXPLICIT }, /* Bl */ + { macro_scoped_explicit, 0 }, /* El */ { NULL, 0 }, /* It */ { macro_text, MDOC_CALLABLE }, /* Ad */ { NULL, 0 }, /* An */ @@ -196,9 +196,6 @@ const char * const *mdoc_argnames = __mdoc_argnames; const struct mdoc_macro * const mdoc_macros = __mdoc_macros; -static void *xcalloc(size_t, size_t); -static char *xstrdup(const char *); - static struct mdoc_arg *argdup(size_t, const struct mdoc_arg *); static void argfree(size_t, struct mdoc_arg *); static void argcpy(struct mdoc_arg *, @@ -228,7 +225,7 @@ mdoc_free(struct mdoc *mdoc) if (mdoc->first) mdoc_node_freelist(mdoc->first); if (mdoc->htab) - mdoc_hash_free(mdoc->htab); + mdoc_tokhash_free(mdoc->htab); free(mdoc); } @@ -244,42 +241,20 @@ mdoc_alloc(void *data, const struct mdoc_cb *cb) p->data = data; (void)memcpy(&p->cb, cb, sizeof(struct mdoc_cb)); - p->htab = mdoc_hash_alloc(); + p->htab = mdoc_tokhash_alloc(); return(p); } -static void * -xcalloc(size_t num, size_t sz) -{ - void *p; - - if (NULL == (p = calloc(num, sz))) - err(EXIT_FAILURE, "calloc"); - return(p); -} - - -static char * -xstrdup(const char *p) -{ - char *pp; - - if (NULL == (pp = strdup(p))) - err(EXIT_FAILURE, "strdup"); - return(pp); -} - - int mdoc_parseln(struct mdoc *mdoc, char *buf) { int c, i; char tmp[5]; - if ('.' != *buf) { - /* TODO. */ - return(1); + if ('.' != *buf) { + mdoc_word_alloc(mdoc, 0, buf); + return(1); } if (buf[1] && '\\' == buf[1]) @@ -372,7 +347,7 @@ mdoc_node_append(struct mdoc *mdoc, int pos, struct md switch (p->type) { case (MDOC_TEXT): - nn = ""; + nn = p->data.text.string; nt = "text"; break; case (MDOC_BODY): @@ -441,6 +416,7 @@ mdoc_node_append(struct mdoc *mdoc, int pos, struct md case (MDOC_HEAD): p->parent = mdoc->last->parent; mdoc->last->next = p; + p->prev = mdoc->last; act = "sibling"; break; default: @@ -465,6 +441,7 @@ mdoc_node_append(struct mdoc *mdoc, int pos, struct md break; default: p->parent = mdoc->last->parent; + p->prev = mdoc->last; mdoc->last->next = p; act = "sibling"; break; @@ -668,7 +645,7 @@ int mdoc_find(const struct mdoc *mdoc, const char *key) { - return(mdoc_hash_find(mdoc->htab, key)); + return(mdoc_tokhash_find(mdoc->htab, key)); }