=================================================================== RCS file: /cvs/mandoc/mdoc.c,v retrieving revision 1.154 retrieving revision 1.159 diff -u -p -r1.154 -r1.159 --- mandoc/mdoc.c 2010/07/01 22:56:17 1.154 +++ mandoc/mdoc.c 2010/07/18 17:00:26 1.159 @@ -1,6 +1,7 @@ -/* $Id: mdoc.c,v 1.154 2010/07/01 22:56:17 kristaps Exp $ */ +/* $Id: mdoc.c,v 1.159 2010/07/18 17:00:26 schwarze Exp $ */ /* - * Copyright (c) 2008, 2009 Kristaps Dzonsons + * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons + * Copyright (c) 2010 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -29,7 +30,6 @@ #include #include "mandoc.h" -#include "regs.h" #include "libmdoc.h" #include "libmandoc.h" @@ -514,17 +514,25 @@ mdoc_word_alloc(struct mdoc *m, int line, int pos, con } -/* FIXME: put in mdoc_node_delete(). */ -void +static void mdoc_node_free(struct mdoc_node *p) { + /* + * XXX: if these end up being problematic in terms of memory + * management and dereferencing freed blocks, then make them + * into reference-counted double-pointers. + */ + if (MDOC_Bd == p->tok && MDOC_BLOCK == p->type) if (p->data.Bd) free(p->data.Bd); if (MDOC_Bl == p->tok && MDOC_BLOCK == p->type) if (p->data.Bl) free(p->data.Bl); + if (MDOC_Bf == p->tok && MDOC_HEAD == p->type) + if (p->data.Bf) + free(p->data.Bf); if (p->string) free(p->string); @@ -713,7 +721,7 @@ mdoc_ptext(struct mdoc *m, int line, char *buf, int of assert(buf < end); - if (mandoc_eos(buf+offs, (size_t)(end-buf-offs))) + if (mandoc_eos(buf+offs, (size_t)(end-buf-offs), 0)) m->last->flags |= MDOC_EOS; return(1); @@ -739,7 +747,7 @@ macrowarn(struct mdoc *m, int ln, const char *buf, int * Parse a macro line, that is, a line beginning with the control * character. */ -int +static int mdoc_pmacro(struct mdoc *m, int ln, char *buf, int offs) { enum mdoct tok;