Date: Sat, 8 Jun 2019 08:25:44 +0000 (UTC) From: Ed Maste <emaste@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r348796 - head/usr.bin/vtfontcvt Message-ID: <201906080825.x588PiB4044128@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: emaste Date: Sat Jun 8 08:25:43 2019 New Revision: 348796 URL: https://svnweb.freebsd.org/changeset/base/348796 Log: vtfontcvt: allow out-of-order glyphs PR: 205707 Reported by: mi MFC after: 2 weeks Event: Vienna Hackathon 2019 Sponsored by: The FreeBSD Foundation Modified: head/usr.bin/vtfontcvt/vtfontcvt.c Modified: head/usr.bin/vtfontcvt/vtfontcvt.c ============================================================================== --- head/usr.bin/vtfontcvt/vtfontcvt.c Sat Jun 8 03:07:08 2019 (r348795) +++ head/usr.bin/vtfontcvt/vtfontcvt.c Sat Jun 8 08:25:43 2019 (r348796) @@ -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 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++;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201906080825.x588PiB4044128>