vtfontcvt: allow out-of-order glyphs

PR:		205707
Reported by:	mi
MFC after:	2 weeks
Event:		Vienna Hackathon 2019
Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Ed Maste 2019-06-08 08:25:43 +00:00
parent 988d63af1c
commit a9de4100e6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=348796

View File

@ -111,7 +111,7 @@ xmalloc(size_t size)
static int static int
add_mapping(struct glyph *gl, unsigned int c, unsigned int map_idx) add_mapping(struct glyph *gl, unsigned int c, unsigned int map_idx)
{ {
struct mapping *mp; struct mapping *mp, *mp_temp;
struct mapping_list *ml; struct mapping_list *ml;
mapping_total++; mapping_total++;
@ -122,10 +122,19 @@ add_mapping(struct glyph *gl, unsigned int c, unsigned int map_idx)
mp->m_length = 0; mp->m_length = 0;
ml = &maps[map_idx]; ml = &maps[map_idx];
if (TAILQ_LAST(ml, mapping_list) != NULL && if (TAILQ_LAST(ml, mapping_list) == NULL ||
TAILQ_LAST(ml, mapping_list)->m_char >= c) TAILQ_LAST(ml, mapping_list)->m_char < c) {
errx(1, "Bad ordering at character %u", c); /* Common case: empty list or new char at end of list. */
TAILQ_INSERT_TAIL(ml, mp, m_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]++; map_count[map_idx]++;
mapping_unique++; mapping_unique++;