=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mandoc/tbl.c,v retrieving revision 1.24 retrieving revision 1.25 diff -c -r1.24 -r1.25 *** src/usr.bin/mandoc/tbl.c 2018/12/12 21:54:30 1.24 --- src/usr.bin/mandoc/tbl.c 2018/12/13 02:05:57 1.25 *************** *** 1,4 **** ! /* $OpenBSD: tbl.c,v 1.24 2018/12/12 21:54:30 schwarze Exp $ */ /* * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2011, 2015 Ingo Schwarze --- 1,4 ---- ! /* $OpenBSD: tbl.c,v 1.25 2018/12/13 02:05:57 schwarze Exp $ */ /* * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2011, 2015 Ingo Schwarze *************** *** 27,33 **** #include "mandoc.h" #include "tbl.h" #include "libmandoc.h" ! #include "libroff.h" void --- 27,34 ---- #include "mandoc.h" #include "tbl.h" #include "libmandoc.h" ! #include "tbl_parse.h" ! #include "tbl_int.h" void *************** *** 85,95 **** } struct tbl_node * ! tbl_alloc(int pos, int line, struct mparse *parse) { struct tbl_node *tbl; tbl = mandoc_calloc(1, sizeof(*tbl)); tbl->line = line; tbl->pos = pos; tbl->parse = parse; --- 86,98 ---- } struct tbl_node * ! tbl_alloc(int pos, int line, struct mparse *parse, struct tbl_node *last_tbl) { struct tbl_node *tbl; tbl = mandoc_calloc(1, sizeof(*tbl)); + if (last_tbl != NULL) + last_tbl->next = tbl; tbl->line = line; tbl->pos = pos; tbl->parse = parse; *************** *** 102,135 **** void tbl_free(struct tbl_node *tbl) { struct tbl_row *rp; struct tbl_cell *cp; struct tbl_span *sp; struct tbl_dat *dp; ! while ((rp = tbl->first_row) != NULL) { ! tbl->first_row = rp->next; ! while (rp->first != NULL) { ! cp = rp->first; ! rp->first = cp->next; ! free(cp->wstr); ! free(cp); } ! free(rp); ! } ! ! while ((sp = tbl->first_span) != NULL) { ! tbl->first_span = sp->next; ! while (sp->first != NULL) { ! dp = sp->first; ! sp->first = dp->next; ! free(dp->string); ! free(dp); } ! free(sp); } - - free(tbl); } void --- 105,141 ---- void tbl_free(struct tbl_node *tbl) { + struct tbl_node *old_tbl; struct tbl_row *rp; struct tbl_cell *cp; struct tbl_span *sp; struct tbl_dat *dp; ! while (tbl != NULL) { ! while ((rp = tbl->first_row) != NULL) { ! tbl->first_row = rp->next; ! while (rp->first != NULL) { ! cp = rp->first; ! rp->first = cp->next; ! free(cp->wstr); ! free(cp); ! } ! free(rp); } ! while ((sp = tbl->first_span) != NULL) { ! tbl->first_span = sp->next; ! while (sp->first != NULL) { ! dp = sp->first; ! sp->first = dp->next; ! free(dp->string); ! free(dp); ! } ! free(sp); } ! old_tbl = tbl; ! tbl = tbl->next; ! free(old_tbl); } } void *************** *** 144,168 **** tbl->pos = pos; } ! const struct tbl_span * tbl_span(struct tbl_node *tbl) { struct tbl_span *span; - assert(tbl); span = tbl->current_span ? tbl->current_span->next : tbl->first_span; ! if (span) tbl->current_span = span; return span; } int ! tbl_end(struct tbl_node *tbl) { struct tbl_span *sp; ! if (tbl->part == TBL_PART_CDATA) mandoc_msg(MANDOCERR_TBLDATA_BLK, tbl->parse, tbl->line, tbl->pos, "TE"); --- 150,176 ---- tbl->pos = pos; } ! struct tbl_span * tbl_span(struct tbl_node *tbl) { struct tbl_span *span; span = tbl->current_span ? tbl->current_span->next : tbl->first_span; ! if (span != NULL) tbl->current_span = span; return span; } int ! tbl_end(struct tbl_node *tbl, int still_open) { struct tbl_span *sp; ! if (still_open) ! mandoc_msg(MANDOCERR_BLK_NOEND, tbl->parse, ! tbl->line, tbl->pos, "TS"); ! else if (tbl->part == TBL_PART_CDATA) mandoc_msg(MANDOCERR_TBLDATA_BLK, tbl->parse, tbl->line, tbl->pos, "TE");