[Fontconfig] fc-glyphname bug
cloos at jhcloos.com
Wed Mar 7 08:56:29 PST 2007
Running fc-glyphname with the glyphlist.txt as an argument fails.
A binary search shows that it is OK with up to 3615 glyph names in the
files specified as args, but fails as soon as there are 3616 glyph names.
When there are 3616 glyph names, hash is 4549 and rehash is 4547,
and the spin starts when i is 896 in the 1st insert at:
| for (i = 0; i < nraw; i++)
| insert (raw[i], name_to_ucs, FcHashGlyphName (raw[i]->name));
| insert (raw[i], ucs_to_name, raw[i]->ucs);
Given that insert() does:
| i = (int) (h % hash);
| while (table[i])
| if (!r) r = (int) (h % rehash);
| i += r;
| if (i >= hash)
| i -= hash;
| table[i] = gn;
i starts looping rather than finding an empty slot at that point.
A quick printf shows that i hits 4541 and remains there.
When h is 18188, i is 4541 and r is 0, since 18188 is 4 * 4547.
For the hell of it, I tried adding an i++ just before the i+=r,
and this at least avoided the spin, although I presume it is
less than optimal.
Is this why glyphlist is not getting included in making fcglyphname.h?
Cf my next post for why this came up.
James Cloos <cloos at jhcloos.com> OpenPGP: 1024D/ED7DAEA6
More information about the Fontconfig