diff options
author | Thomas White <taw@physics.org> | 2018-01-18 22:54:33 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2018-01-18 22:54:33 +0100 |
commit | e7d62e1cd2023fc0b4eedc41aa532c22bb96117c (patch) | |
tree | 7ec098b024277b2a2aec3d829dae2cd5e423197c | |
parent | 7b0d0bf3e125018e1cf191ec36e823d797a91f8c (diff) |
Try deleting based on macro contents if paragraphs can't be merged straight away
Also, avoid a segfault if it still doesn't work after that.
-rw-r--r-- | src/frame.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/frame.c b/src/frame.c index 1bc21bc..656bf5c 100644 --- a/src/frame.c +++ b/src/frame.c @@ -1312,6 +1312,19 @@ void merge_paragraphs(struct frame *fr, int para) return; } + /* Delete the \newpara block to unite the paragraphs */ + n = get_newline_at_end(p1); + assert(n != NULL); + + if ( sc_block_delete(&fr->scblocks, n) ) { + if ( p1->runs[p1->n_runs-1].macro_contents != NULL ) { + if ( sc_block_delete(&p1->runs[p1->n_runs-1].macro_contents, n) ) { + fprintf(stderr, "Failed to delete paragraph end sentinel.\n"); + return; + } + } + } + /* All the runs from p2 get added to p1 */ runs_new = realloc(p1->runs, (p1->n_runs+p2->n_runs)*sizeof(struct text_run)); @@ -1321,11 +1334,6 @@ void merge_paragraphs(struct frame *fr, int para) } p1->runs = runs_new; - /* Delete the \newpara block to unite the paragraphs */ - n = get_newline_at_end(p1); - assert(n != NULL); - sc_block_delete(&fr->scblocks, n); - /* The end of the united paragraph should now be the end of the * second one */ set_newline_at_end(p1, get_newline_at_end(p2)); |