=================================================================== RCS file: /cvs/mandoc/eqn.c,v retrieving revision 1.68 retrieving revision 1.70 diff -u -p -r1.68 -r1.70 --- mandoc/eqn.c 2017/06/23 00:30:38 1.68 +++ mandoc/eqn.c 2017/06/26 11:04:47 1.70 @@ -1,4 +1,4 @@ -/* $Id: eqn.c,v 1.68 2017/06/23 00:30:38 schwarze Exp $ +/* $Id: eqn.c,v 1.70 2017/06/26 11:04:47 schwarze Exp $ */ /* * Copyright (c) 2011, 2014 Kristaps Dzonsons * Copyright (c) 2014, 2015, 2017 Ingo Schwarze @@ -722,7 +722,7 @@ static enum rofferr eqn_parse(struct eqn_node *ep, struct eqn_box *parent) { char sym[64]; - struct eqn_box *cur, *nbox; + struct eqn_box *cur, *nbox, *split; const char *cp, *cpn, *start; char *p; size_t sz; @@ -1118,6 +1118,7 @@ this_tok: break; cpn = p - 1; ccln = CCL_LET; + split = NULL; for (;;) { /* Advance to next character. */ cp = cpn++; @@ -1139,7 +1140,25 @@ this_tok: break; if (ccln == ccl) continue; - /* Boundary found, add a new box. */ + /* Boundary found, split the text. */ + if (parent->args == parent->expectargs) { + /* Remove the text from the tree. */ + if (cur->prev == NULL) + parent->first = cur->next; + else + cur->prev->next = NULL; + parent->last = cur->prev; + parent->args--; + /* Set up a list instead. */ + split = eqn_box_alloc(ep, parent); + split->type = EQN_LIST; + /* Insert the word into the list. */ + split->first = split->last = cur; + cur->parent = split; + cur->prev = NULL; + parent = split; + } + /* Append a new text box. */ nbox = eqn_box_alloc(ep, parent); nbox->type = EQN_TEXT; nbox->text = mandoc_strdup(cpn); @@ -1154,6 +1173,8 @@ this_tok: cpn = p - 1; ccln = CCL_LET; } + if (split != NULL) + parent = split->parent; break; } /*