diff options
| author | Ed Maste <emaste@FreeBSD.org> | 2019-06-08 08:25:43 +0000 |
|---|---|---|
| committer | Ed Maste <emaste@FreeBSD.org> | 2019-06-08 08:25:43 +0000 |
| commit | a9de4100e61e27a19bae90503f7396212dceaa48 (patch) | |
| tree | 7c5a4272f34bec2368045bb61a4bf97b8f5d0ee8 /usr.bin | |
| parent | 988d63af1c690f3db4346b70ade093cdb30def68 (diff) | |
Notes
Diffstat (limited to 'usr.bin')
| -rw-r--r-- | usr.bin/vtfontcvt/vtfontcvt.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/usr.bin/vtfontcvt/vtfontcvt.c b/usr.bin/vtfontcvt/vtfontcvt.c index 58bc26938f447..d3c43f424839e 100644 --- a/usr.bin/vtfontcvt/vtfontcvt.c +++ b/usr.bin/vtfontcvt/vtfontcvt.c @@ -111,7 +111,7 @@ xmalloc(size_t size) static int add_mapping(struct glyph *gl, unsigned int c, unsigned int map_idx) { - struct mapping *mp; + struct mapping *mp, *mp_temp; struct mapping_list *ml; mapping_total++; @@ -122,10 +122,19 @@ add_mapping(struct glyph *gl, unsigned int c, unsigned int map_idx) mp->m_length = 0; ml = &maps[map_idx]; - if (TAILQ_LAST(ml, mapping_list) != NULL && - TAILQ_LAST(ml, mapping_list)->m_char >= c) - errx(1, "Bad ordering at character %u", c); - TAILQ_INSERT_TAIL(ml, mp, m_list); + if (TAILQ_LAST(ml, mapping_list) == NULL || + TAILQ_LAST(ml, mapping_list)->m_char < c) { + /* Common case: empty list or new char at end of list. */ + TAILQ_INSERT_TAIL(ml, mp, m_list); + } else { + /* Find insertion point for char; cannot be at end. */ + TAILQ_FOREACH(mp_temp, ml, m_list) { + if (mp_temp->m_char >= c) { + TAILQ_INSERT_BEFORE(mp_temp, mp, m_list); + break; + } + } + } map_count[map_idx]++; mapping_unique++; |
