Fix fc-lang to use new charset freezer API.
Charset freezer api now uses allocated object. Also required minor fixes to charset freezer code to remove assumption that all input charsets are persistant.
This commit is contained in:
parent
bc5e487f2a
commit
18b6857c64
|
@ -48,6 +48,8 @@ FcMemFree (int kind, int size)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int FcDebugVal;
|
||||||
|
|
||||||
FcChar8 *
|
FcChar8 *
|
||||||
FcConfigHome (void)
|
FcConfigHome (void)
|
||||||
{
|
{
|
||||||
|
@ -114,14 +116,14 @@ scanopen (char *file)
|
||||||
* Comments begin with '#'
|
* Comments begin with '#'
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static FcCharSet *
|
static const FcCharSet *
|
||||||
scan (FILE *f, char *file)
|
scan (FILE *f, char *file, FcCharSetFreezer *freezer)
|
||||||
{
|
{
|
||||||
FcCharSet *c = 0;
|
FcCharSet *c = 0;
|
||||||
FcCharSet *n;
|
const FcCharSet *n;
|
||||||
int start, end, ucs4;
|
int start, end, ucs4;
|
||||||
char line[1024];
|
char line[1024];
|
||||||
int lineno = 0;
|
int lineno = 0;
|
||||||
|
|
||||||
while (get_line (f, line, &lineno))
|
while (get_line (f, line, &lineno))
|
||||||
{
|
{
|
||||||
|
@ -136,9 +138,9 @@ scan (FILE *f, char *file)
|
||||||
f = scanopen (file);
|
f = scanopen (file);
|
||||||
if (!f)
|
if (!f)
|
||||||
fatal (file, 0, "can't open");
|
fatal (file, 0, "can't open");
|
||||||
c = scan (f, file);
|
n = scan (f, file, freezer);
|
||||||
fclose (f);
|
fclose (f);
|
||||||
return c;
|
return n;
|
||||||
}
|
}
|
||||||
if (strchr (line, '-'))
|
if (strchr (line, '-'))
|
||||||
{
|
{
|
||||||
|
@ -159,7 +161,7 @@ scan (FILE *f, char *file)
|
||||||
fatal (file, lineno, "out of memory");
|
fatal (file, lineno, "out of memory");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
n = FcCharSetFreeze (c);
|
n = FcCharSetFreeze (freezer, c);
|
||||||
FcCharSetDestroy (c);
|
FcCharSetDestroy (c);
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
@ -222,7 +224,7 @@ int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
static char *files[MAX_LANG];
|
static char *files[MAX_LANG];
|
||||||
static FcCharSet *sets[MAX_LANG];
|
static const FcCharSet *sets[MAX_LANG];
|
||||||
static int duplicate[MAX_LANG];
|
static int duplicate[MAX_LANG];
|
||||||
static int country[MAX_LANG];
|
static int country[MAX_LANG];
|
||||||
static char *names[MAX_LANG];
|
static char *names[MAX_LANG];
|
||||||
|
@ -242,7 +244,11 @@ main (int argc, char **argv)
|
||||||
int setRangeStart[26];
|
int setRangeStart[26];
|
||||||
int setRangeEnd[26];
|
int setRangeEnd[26];
|
||||||
FcChar8 setRangeChar;
|
FcChar8 setRangeChar;
|
||||||
|
FcCharSetFreezer *freezer;
|
||||||
|
|
||||||
|
freezer = FcCharSetFreezerCreate ();
|
||||||
|
if (!freezer)
|
||||||
|
fatal (argv[0], 0, "out of memory");
|
||||||
argi = 1;
|
argi = 1;
|
||||||
while (argv[argi])
|
while (argv[argi])
|
||||||
{
|
{
|
||||||
|
@ -264,7 +270,7 @@ main (int argc, char **argv)
|
||||||
f = scanopen (files[i]);
|
f = scanopen (files[i]);
|
||||||
if (!f)
|
if (!f)
|
||||||
fatal (files[i], 0, strerror (errno));
|
fatal (files[i], 0, strerror (errno));
|
||||||
sets[i] = scan (f, files[i]);
|
sets[i] = scan (f, files[i], freezer);
|
||||||
names[i] = get_name (files[i]);
|
names[i] = get_name (files[i]);
|
||||||
langs[i] = get_lang(names[i]);
|
langs[i] = get_lang(names[i]);
|
||||||
if (strchr (langs[i], '-'))
|
if (strchr (langs[i], '-'))
|
||||||
|
|
|
@ -1169,7 +1169,7 @@ FcCharSetFindFrozen (FcCharSetFreezer *freezer, const FcCharSet *orig)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const FcCharSet *
|
const FcCharSet *
|
||||||
FcCharSetFreeze (FcCharSetFreezer *freezer, const FcCharSet *fcs)
|
FcCharSetFreeze (FcCharSetFreezer *freezer, const FcCharSet *fcs)
|
||||||
{
|
{
|
||||||
FcCharSet *b;
|
FcCharSet *b;
|
||||||
|
@ -1177,10 +1177,6 @@ FcCharSetFreeze (FcCharSetFreezer *freezer, const FcCharSet *fcs)
|
||||||
FcCharLeaf *l;
|
FcCharLeaf *l;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
n = FcCharSetFindFrozen (freezer, fcs);
|
|
||||||
if (n)
|
|
||||||
return n;
|
|
||||||
|
|
||||||
b = FcCharSetCreate ();
|
b = FcCharSetCreate ();
|
||||||
if (!b)
|
if (!b)
|
||||||
goto bail0;
|
goto bail0;
|
||||||
|
@ -1217,7 +1213,7 @@ bail0:
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FcCharSetFreezer *
|
FcCharSetFreezer *
|
||||||
FcCharSetFreezerCreate (void)
|
FcCharSetFreezerCreate (void)
|
||||||
{
|
{
|
||||||
FcCharSetFreezer *freezer;
|
FcCharSetFreezer *freezer;
|
||||||
|
@ -1279,6 +1275,9 @@ FcCharSetSerializeAlloc (FcSerialize *serialize, const FcCharSet *cs)
|
||||||
if (!serialize->cs_freezer)
|
if (!serialize->cs_freezer)
|
||||||
return FcFalse;
|
return FcFalse;
|
||||||
}
|
}
|
||||||
|
if (FcCharSetFindFrozen (serialize->cs_freezer, cs))
|
||||||
|
return FcTrue;
|
||||||
|
|
||||||
cs = FcCharSetFreeze (serialize->cs_freezer, cs);
|
cs = FcCharSetFreeze (serialize->cs_freezer, cs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -623,6 +623,12 @@ FcLangSetSerialize(FcSerialize *serialize, const FcLangSet *l);
|
||||||
void
|
void
|
||||||
FcLangCharSetPopulate (void);
|
FcLangCharSetPopulate (void);
|
||||||
|
|
||||||
|
FcCharSetFreezer *
|
||||||
|
FcCharSetFreezerCreate (void);
|
||||||
|
|
||||||
|
const FcCharSet *
|
||||||
|
FcCharSetFreeze (FcCharSetFreezer *freezer, const FcCharSet *fcs);
|
||||||
|
|
||||||
void
|
void
|
||||||
FcCharSetFreezerDestroy (FcCharSetFreezer *freezer);
|
FcCharSetFreezerDestroy (FcCharSetFreezer *freezer);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue