This commit is contained in:
Behdad Esfahbod 2013-01-02 02:27:57 -06:00
parent 766bed901f
commit 5c0a4f2726
1 changed files with 23 additions and 23 deletions

View File

@ -58,12 +58,12 @@ FcAllocGlyphName (FcChar32 ucs, FcChar8 *name)
return gn; return gn;
} }
static void static void
fatal (const char *file, int lineno, const char *msg) fatal (const char *file, int lineno, const char *msg)
{ {
if (lineno) if (lineno)
fprintf (stderr, "%s:%d: %s\n", file, lineno, msg); fprintf (stderr, "%s:%d: %s\n", file, lineno, msg);
else else
fprintf (stderr, "%s: %s\n", file, msg); fprintf (stderr, "%s: %s\n", file, msg);
exit (1); exit (1);
@ -100,7 +100,7 @@ scan (FILE *f, char *filename)
FcGlyphName *gn; FcGlyphName *gn;
int lineno = 0; int lineno = 0;
int len; int len;
while (fgets (buf, sizeof (buf), f)) while (fgets (buf, sizeof (buf), f))
{ {
lineno++; lineno++;
@ -177,7 +177,7 @@ find_hash (void)
int h; int h;
h = nraw + nraw / 4; h = nraw + nraw / 4;
if ((h & 1) == 0) if ((h & 1) == 0)
h++; h++;
while (!isprime(h-2) || !isprime(h)) while (!isprime(h-2) || !isprime(h))
h += 2; h += 2;
@ -201,12 +201,12 @@ FcHashGlyphName (const FcChar8 *name)
static void static void
insert (FcGlyphName *gn, FcGlyphName **table, FcChar32 h) insert (FcGlyphName *gn, FcGlyphName **table, FcChar32 h)
{ {
int i, r = 0; unsigned int i, r = 0;
i = (int) (h % hash); i = (int) (h % hash);
while (table[i]) while (table[i])
{ {
if (!r) r = (int) (h % rehash + 1); if (!r) r = (h % rehash + 1);
i += r; i += r;
if (i >= hash) if (i >= hash)
i -= hash; i -= hash;
@ -217,8 +217,8 @@ insert (FcGlyphName *gn, FcGlyphName **table, FcChar32 h)
static void static void
dump (FcGlyphName * const *table, const char *name) dump (FcGlyphName * const *table, const char *name)
{ {
int i; unsigned int i;
printf ("static const FcGlyphId %s[%d] = {\n", name, hash); printf ("static const FcGlyphId %s[%d] = {\n", name, hash);
for (i = 0; i < hash; i++) for (i = 0; i < hash; i++)
@ -226,7 +226,7 @@ dump (FcGlyphName * const *table, const char *name)
printf (" %d,\n", rawindex(table[i])); printf (" %d,\n", rawindex(table[i]));
else else
printf (" -1,\n"); printf (" -1,\n");
printf ("};\n"); printf ("};\n");
} }
@ -237,8 +237,8 @@ main (int argc, char **argv)
char line[1024]; char line[1024];
FILE *f; FILE *f;
int i; int i;
char *type; const char *type;
i = 0; i = 0;
while (argv[i+1]) while (argv[i+1])
{ {
@ -249,7 +249,7 @@ main (int argc, char **argv)
} }
files[i] = 0; files[i] = 0;
qsort (files, i, sizeof (char *), compare_string); qsort (files, i, sizeof (char *), compare_string);
for (i = 0; files[i]; i++) for (i = 0; files[i]; i++)
{ {
f = fopen (files[i], "r"); f = fopen (files[i], "r");
if (!f) if (!f)
@ -260,27 +260,27 @@ main (int argc, char **argv)
qsort (raw, nraw, sizeof (FcGlyphName *), compare_glyphname); qsort (raw, nraw, sizeof (FcGlyphName *), compare_glyphname);
find_hash (); find_hash ();
for (i = 0; i < nraw; i++) for (i = 0; i < nraw; i++)
{ {
insert (raw[i], name_to_ucs, FcHashGlyphName (raw[i]->name)); insert (raw[i], name_to_ucs, FcHashGlyphName (raw[i]->name));
insert (raw[i], ucs_to_name, raw[i]->ucs); insert (raw[i], ucs_to_name, raw[i]->ucs);
} }
/* /*
* Scan the input until the marker is found * Scan the input until the marker is found
*/ */
while (fgets (line, sizeof (line), stdin)) while (fgets (line, sizeof (line), stdin))
{ {
if (!strncmp (line, "@@@", 3)) if (!strncmp (line, "@@@", 3))
break; break;
fputs (line, stdout); fputs (line, stdout);
} }
printf ("/* %d glyphnames in %d entries, %d%% occupancy */\n\n", printf ("/* %d glyphnames in %d entries, %d%% occupancy */\n\n",
nraw, hash, nraw * 100 / hash); nraw, hash, nraw * 100 / hash);
printf ("#define FC_GLYPHNAME_HASH %u\n", hash); printf ("#define FC_GLYPHNAME_HASH %u\n", hash);
printf ("#define FC_GLYPHNAME_REHASH %u\n", rehash); printf ("#define FC_GLYPHNAME_REHASH %u\n", rehash);
printf ("#define FC_GLYPHNAME_MAXLEN %d\n\n", max_name_len); printf ("#define FC_GLYPHNAME_MAXLEN %d\n\n", max_name_len);
@ -290,16 +290,16 @@ main (int argc, char **argv)
type = "int16_t"; type = "int16_t";
else else
type = "int32_t"; type = "int32_t";
printf ("typedef %s FcGlyphId;\n\n", type); printf ("typedef %s FcGlyphId;\n\n", type);
/* /*
* Dump out entries * Dump out entries
*/ */
printf ("static const struct { const FcChar32 ucs; const FcChar8 name[%d]; } _fc_glyph_names[%d] = {\n", printf ("static const struct { const FcChar32 ucs; const FcChar8 name[%d]; } _fc_glyph_names[%d] = {\n",
max_name_len + 1, nraw); max_name_len + 1, nraw);
for (i = 0; i < nraw; i++) for (i = 0; i < nraw; i++)
printf (" { 0x%lx, \"%s\" },\n", printf (" { 0x%lx, \"%s\" },\n",
(unsigned long) raw[i]->ucs, raw[i]->name); (unsigned long) raw[i]->ucs, raw[i]->name);
@ -311,7 +311,7 @@ main (int argc, char **argv)
*/ */
dump (name_to_ucs, "_fc_name_to_ucs"); dump (name_to_ucs, "_fc_name_to_ucs");
/* /*
* Dump out ucs_to_name table * Dump out ucs_to_name table
*/ */
@ -319,7 +319,7 @@ main (int argc, char **argv)
while (fgets (line, sizeof (line), stdin)) while (fgets (line, sizeof (line), stdin))
fputs (line, stdout); fputs (line, stdout);
fflush (stdout); fflush (stdout);
exit (ferror (stdout)); exit (ferror (stdout));
} }