Refactor; contain default config in fccfg.c

This commit is contained in:
Behdad Esfahbod 2012-10-07 16:37:03 -04:00
parent 32b0d88923
commit 7ae24b4554
4 changed files with 34 additions and 18 deletions

View File

@ -36,7 +36,29 @@
#define R_OK 4
#endif
FcConfig *_fcConfig;
static FcConfig *_fcConfig;
FcBool
FcConfigInit (void)
{
FcConfig *config;
if (_fcConfig)
return FcTrue;
config = FcInitLoadConfigAndFonts ();
if (!config)
return FcFalse;
FcConfigSetCurrent (config);
return FcTrue;
}
void
FcConfigFini (void)
{
if (_fcConfig)
FcConfigDestroy (_fcConfig);
}
FcConfig *
FcConfigCreate (void)
@ -406,7 +428,7 @@ FcConfig *
FcConfigGetCurrent (void)
{
if (!_fcConfig)
if (!FcInit ())
if (!FcConfigInit ())
return 0;
return _fcConfig;
}

View File

@ -135,15 +135,7 @@ FcInitLoadConfigAndFonts (void)
FcBool
FcInit (void)
{
FcConfig *config;
if (_fcConfig)
return FcTrue;
config = FcInitLoadConfigAndFonts ();
if (!config)
return FcFalse;
FcConfigSetCurrent (config);
return FcTrue;
return FcConfigInit ();
}
/*
@ -152,9 +144,7 @@ FcInit (void)
void
FcFini (void)
{
if (_fcConfig)
FcConfigDestroy (_fcConfig);
FcConfigFini ();
FcCacheFini ();
FcDefaultFini ();
}

View File

@ -505,8 +505,6 @@ struct _FcConfig {
FcExprPage *expr_pool; /* pool of FcExpr's */
};
extern FcPrivate FcConfig *_fcConfig;
typedef struct _FcFileTime {
time_t time;
FcBool set;
@ -569,6 +567,12 @@ FcDirCacheReference (FcCache *cache, int nref);
/* fccfg.c */
FcPrivate FcBool
FcConfigInit (void);
FcPrivate void
FcConfigFini (void);
FcPrivate FcChar8 *
FcConfigXdgCacheHome (void);

View File

@ -1107,7 +1107,7 @@ FcPStackPop (FcConfigParse *parse)
}
static FcBool
FcConfigInit (FcConfigParse *parse, const FcChar8 *name, FcConfig *config, XML_Parser parser)
FcConfigParseInit (FcConfigParse *parse, const FcChar8 *name, FcConfig *config, XML_Parser parser)
{
parse->pstack = 0;
parse->pstack_static_used = 0;
@ -2984,7 +2984,7 @@ FcConfigParseAndLoad (FcConfig *config,
if (!p)
goto bail1;
if (!FcConfigInit (&parse, name, config, p))
if (!FcConfigParseInit (&parse, name, config, p))
goto bail2;
#ifndef ENABLE_LIBXML2