* PERFORMANCE OF THIS SOFTWARE.
*/
+#include "fcint.h"
#include <fcntl.h>
#include <stdarg.h>
-#include "fcint.h"
#include <dirent.h>
-#if ENABLE_LIBXML2
+#ifdef ENABLE_LIBXML2
#include <libxml/parser.h>
FcElementNone,
FcElementFontconfig,
FcElementDir,
+ FcElementCacheDir,
FcElementCache,
FcElementInclude,
FcElementConfig,
FcElementUnknown
} FcElement;
-static struct {
+static const struct {
const char name[16];
FcElement element;
} fcElementMap[] = {
{ "fontconfig", FcElementFontconfig },
{ "dir", FcElementDir },
+ { "cachedir", FcElementCacheDir },
{ "cache", FcElementCache },
{ "include", FcElementInclude },
{ "config", FcElementConfig },
if (!FcVStackPushExpr (parse, tag, expr))
{
FcConfigMessage (parse, FcSevereError, "out of memory");
- if (expr)
- FcExprDestroy (expr);
+ FcExprDestroy (expr);
}
}
}
FcConfigMessage (parse, FcSevereError, "out of memory");
FcExprDestroy (left);
FcExprDestroy (expr);
- break;
+ return 0;
}
expr = new;
}
if (!name)
{
FcConfigMessage (parse, FcSevereWarning, "missing pattern element name");
+ FcPatternDestroy (pattern);
return;
}
}
}
- FcVStackPushPattern (parse, FcPatternFreeze(pattern));
- FcPatternDestroy (pattern);
+ FcVStackPushPattern (parse, pattern);
}
static void
if (!FcPatternAppend (pattern, vstack->u.pattern))
{
FcConfigMessage (parse, FcSevereError, "out of memory");
+ FcPatternDestroy (pattern);
return;
}
break;
}
FcStrFree (data);
break;
+ case FcElementCacheDir:
+ data = FcStrBufDone (&parse->pstack->str);
+ if (!data)
+ {
+ FcConfigMessage (parse, FcSevereError, "out of memory");
+ break;
+ }
+ if (!FcStrUsesHome (data) || FcConfigHome ())
+ {
+ if (!FcConfigAddCacheDir (parse->config, data))
+ FcConfigMessage (parse, FcSevereError, "out of memory; cannot add cache directory %s", data);
+ }
+ FcStrFree (data);
+ break;
+
case FcElementCache:
data = FcStrBufDone (&parse->pstack->str);
if (!data)
FcConfigMessage (parse, FcSevereError, "invalid doctype \"%s\"", doctypeName);
}
-#if ENABLE_LIBXML2
+#ifdef ENABLE_LIBXML2
static void
FcInternalSubsetDecl (void *userData,
FcConfigParse parse;
FcBool error = FcTrue;
-#if ENABLE_LIBXML2
+#ifdef ENABLE_LIBXML2
xmlSAXHandler sax;
char buf[BUFSIZ];
#else
goto bail0;
}
-#if ENABLE_LIBXML2
+#ifdef ENABLE_LIBXML2
memset(&sax, 0, sizeof(sax));
sax.internalSubset = FcInternalSubsetDecl;
if (!FcConfigInit (&parse, name, config, p))
goto bail2;
-#if !ENABLE_LIBXML2
+#ifndef ENABLE_LIBXML2
XML_SetUserData (p, &parse);
#endif /* ENABLE_LIBXML2 */
do {
-#if !ENABLE_LIBXML2
+#ifndef ENABLE_LIBXML2
buf = XML_GetBuffer (p, BUFSIZ);
if (!buf)
{
goto bail3;
}
-#if ENABLE_LIBXML2
+#ifdef ENABLE_LIBXML2
if (xmlParseChunk (p, buf, len, len == 0))
#else
if (!XML_ParseBuffer (p, len, len == 0))