Add better error reporting when loading config file
This commit is contained in:
parent
c4bd0638c5
commit
80c053b725
|
@ -112,7 +112,7 @@ main (int argc, char **argv)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (argv[i])
|
if (argv[i])
|
||||||
pat = FcNameParse ((const FcChar8 *)argv[i]);
|
pat = FcNameParse ((FcChar8 *) argv[i]);
|
||||||
else
|
else
|
||||||
pat = FcPatternCreate ();
|
pat = FcPatternCreate ();
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* $XFree86: xc/lib/fontconfig/fontconfig/fontconfig.h,v 1.2 2002/02/15 06:01:27 keithp Exp $
|
* $XFree86: xc/lib/fontconfig/fontconfig/fontconfig.h,v 1.3 2002/02/19 07:50:43 keithp Exp $
|
||||||
*
|
*
|
||||||
* Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc.
|
* Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc.
|
||||||
*
|
*
|
||||||
|
@ -399,12 +399,26 @@ FcObjectSetVaBuild (const char *first, va_list va);
|
||||||
FcObjectSet *
|
FcObjectSet *
|
||||||
FcObjectSetBuild (const char *first, ...);
|
FcObjectSetBuild (const char *first, ...);
|
||||||
|
|
||||||
|
FcFontSet *
|
||||||
|
FcFontSetList (FcConfig *config,
|
||||||
|
FcFontSet **sets,
|
||||||
|
int nsets,
|
||||||
|
FcPattern *p,
|
||||||
|
FcObjectSet *os);
|
||||||
|
|
||||||
FcFontSet *
|
FcFontSet *
|
||||||
FcFontList (FcConfig *config,
|
FcFontList (FcConfig *config,
|
||||||
FcPattern *p,
|
FcPattern *p,
|
||||||
FcObjectSet *os);
|
FcObjectSet *os);
|
||||||
|
|
||||||
/* fcmatch.c */
|
/* fcmatch.c */
|
||||||
|
FcPattern *
|
||||||
|
FcFontSetMatch (FcConfig *config,
|
||||||
|
FcFontSet **sets,
|
||||||
|
int nsets,
|
||||||
|
FcPattern *p,
|
||||||
|
FcResult *result);
|
||||||
|
|
||||||
FcPattern *
|
FcPattern *
|
||||||
FcFontMatch (FcConfig *config,
|
FcFontMatch (FcConfig *config,
|
||||||
FcPattern *p,
|
FcPattern *p,
|
||||||
|
|
32
src/fclist.c
32
src/fclist.c
|
@ -356,14 +356,16 @@ bail0:
|
||||||
}
|
}
|
||||||
|
|
||||||
FcFontSet *
|
FcFontSet *
|
||||||
FcFontList (FcConfig *config,
|
FcFontSetList (FcConfig *config,
|
||||||
|
FcFontSet **sets,
|
||||||
|
int nsets,
|
||||||
FcPattern *p,
|
FcPattern *p,
|
||||||
FcObjectSet *os)
|
FcObjectSet *os)
|
||||||
{
|
{
|
||||||
FcFontSet *ret;
|
FcFontSet *ret;
|
||||||
FcFontSet *s;
|
FcFontSet *s;
|
||||||
int f;
|
int f;
|
||||||
FcSetName set;
|
int set;
|
||||||
FcListHashTable table;
|
FcListHashTable table;
|
||||||
int i;
|
int i;
|
||||||
FcListBucket *bucket;
|
FcListBucket *bucket;
|
||||||
|
@ -379,9 +381,9 @@ FcFontList (FcConfig *config,
|
||||||
* Walk all available fonts adding those that
|
* Walk all available fonts adding those that
|
||||||
* match to the hash table
|
* match to the hash table
|
||||||
*/
|
*/
|
||||||
for (set = FcSetSystem; set <= FcSetApplication; set++)
|
for (set = 0; set < nsets; set++)
|
||||||
{
|
{
|
||||||
s = config->fonts[set];
|
s = sets[set];
|
||||||
if (!s)
|
if (!s)
|
||||||
continue;
|
continue;
|
||||||
for (f = 0; f < s->nfont; f++)
|
for (f = 0; f < s->nfont; f++)
|
||||||
|
@ -440,3 +442,25 @@ bail1:
|
||||||
bail0:
|
bail0:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FcFontSet *
|
||||||
|
FcFontList (FcConfig *config,
|
||||||
|
FcPattern *p,
|
||||||
|
FcObjectSet *os)
|
||||||
|
{
|
||||||
|
FcFontSet *sets[2];
|
||||||
|
int nsets;
|
||||||
|
|
||||||
|
if (!config)
|
||||||
|
{
|
||||||
|
config = FcConfigGetCurrent ();
|
||||||
|
if (!config)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
nsets = 0;
|
||||||
|
if (config->fonts[FcSetSystem])
|
||||||
|
sets[nsets++] = config->fonts[FcSetSystem];
|
||||||
|
if (config->fonts[FcSetApplication])
|
||||||
|
sets[nsets++] = config->fonts[FcSetApplication];
|
||||||
|
return FcFontSetList (config, sets, nsets, p, os);
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* $XFree86: $
|
* $XFree86: xc/lib/fontconfig/src/fcmatch.c,v 1.2 2002/02/15 06:01:28 keithp Exp $
|
||||||
*
|
*
|
||||||
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
|
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
|
||||||
*
|
*
|
||||||
|
@ -239,7 +239,9 @@ FcCompare (FcPattern *pat,
|
||||||
}
|
}
|
||||||
|
|
||||||
FcPattern *
|
FcPattern *
|
||||||
FcFontMatch (FcConfig *config,
|
FcFontSetMatch (FcConfig *config,
|
||||||
|
FcFontSet **sets,
|
||||||
|
int nsets,
|
||||||
FcPattern *p,
|
FcPattern *p,
|
||||||
FcResult *result)
|
FcResult *result)
|
||||||
{
|
{
|
||||||
|
@ -267,9 +269,9 @@ FcFontMatch (FcConfig *config,
|
||||||
if (!config)
|
if (!config)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
for (set = FcSetSystem; set <= FcSetApplication; set++)
|
for (set = 0; set < nsets; set++)
|
||||||
{
|
{
|
||||||
s = config->fonts[set];
|
s = sets[set];
|
||||||
if (!s)
|
if (!s)
|
||||||
continue;
|
continue;
|
||||||
for (f = 0; f < s->nfont; f++)
|
for (f = 0; f < s->nfont; f++)
|
||||||
|
@ -346,3 +348,25 @@ FcFontMatch (FcConfig *config,
|
||||||
FcConfigSubstitute (config, new, FcMatchFont);
|
FcConfigSubstitute (config, new, FcMatchFont);
|
||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FcPattern *
|
||||||
|
FcFontMatch (FcConfig *config,
|
||||||
|
FcPattern *p,
|
||||||
|
FcResult *result)
|
||||||
|
{
|
||||||
|
FcFontSet *sets[2];
|
||||||
|
int nsets;
|
||||||
|
|
||||||
|
if (!config)
|
||||||
|
{
|
||||||
|
config = FcConfigGetCurrent ();
|
||||||
|
if (!config)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
nsets = 0;
|
||||||
|
if (config->fonts[FcSetSystem])
|
||||||
|
sets[nsets++] = config->fonts[FcSetSystem];
|
||||||
|
if (config->fonts[FcSetApplication])
|
||||||
|
sets[nsets++] = config->fonts[FcSetApplication];
|
||||||
|
return FcFontSetMatch (config, sets, nsets, p, result);
|
||||||
|
}
|
||||||
|
|
12
src/fcxml.c
12
src/fcxml.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* $XFree86: xc/lib/fontconfig/src/fcxml.c,v 1.4 2002/02/20 00:32:30 keithp Exp $
|
* $XFree86: xc/lib/fontconfig/src/fcxml.c,v 1.5 2002/02/22 18:54:07 keithp Exp $
|
||||||
*
|
*
|
||||||
* Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
|
* Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
|
||||||
*
|
*
|
||||||
|
@ -1596,12 +1596,22 @@ FcConfigParseAndLoad (FcConfig *config,
|
||||||
do {
|
do {
|
||||||
buf = XML_GetBuffer (p, BUFSIZ);
|
buf = XML_GetBuffer (p, BUFSIZ);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
|
{
|
||||||
|
FcConfigError (&parse, "cannot get parse buffer");
|
||||||
goto bail3;
|
goto bail3;
|
||||||
|
}
|
||||||
len = fread (buf, 1, BUFSIZ, f);
|
len = fread (buf, 1, BUFSIZ, f);
|
||||||
if (len < 0)
|
if (len < 0)
|
||||||
|
{
|
||||||
|
FcConfigError (&parse, "failed reading config file");
|
||||||
goto bail3;
|
goto bail3;
|
||||||
|
}
|
||||||
if (!XML_ParseBuffer (p, len, len == 0))
|
if (!XML_ParseBuffer (p, len, len == 0))
|
||||||
|
{
|
||||||
|
FcConfigError (&parse, "%s",
|
||||||
|
XML_ErrorString (XML_GetErrorCode (p)));
|
||||||
goto bail3;
|
goto bail3;
|
||||||
|
}
|
||||||
} while (len != 0);
|
} while (len != 0);
|
||||||
error = parse.error;
|
error = parse.error;
|
||||||
bail3:
|
bail3:
|
||||||
|
|
Loading…
Reference in New Issue