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 #define R_OK 4
#endif #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 * FcConfig *
FcConfigCreate (void) FcConfigCreate (void)
@ -406,7 +428,7 @@ FcConfig *
FcConfigGetCurrent (void) FcConfigGetCurrent (void)
{ {
if (!_fcConfig) if (!_fcConfig)
if (!FcInit ()) if (!FcConfigInit ())
return 0; return 0;
return _fcConfig; return _fcConfig;
} }

View File

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

View File

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

View File

@ -1107,7 +1107,7 @@ FcPStackPop (FcConfigParse *parse)
} }
static FcBool 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 = 0;
parse->pstack_static_used = 0; parse->pstack_static_used = 0;
@ -2984,7 +2984,7 @@ FcConfigParseAndLoad (FcConfig *config,
if (!p) if (!p)
goto bail1; goto bail1;
if (!FcConfigInit (&parse, name, config, p)) if (!FcConfigParseInit (&parse, name, config, p))
goto bail2; goto bail2;
#ifndef ENABLE_LIBXML2 #ifndef ENABLE_LIBXML2