summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2015-06-26 17:02:13 -0700
committerBehdad Esfahbod <behdad@behdad.org>2015-06-26 17:02:13 -0700
commit46ec6a52d4cc447cc3ff4a13b2067ecb76c9db2e (patch)
treec4b202cddf5a71eafd3f1cbe6dc5fc98ad7451fc
parenta8096dfa5965bfb1953fe829ff13eea23b4233c7 (diff)
downloadfontconfig-46ec6a52d4cc447cc3ff4a13b2067ecb76c9db2e.tar.gz
Revert changes made to FcConfigAppFontAddDir() recently
In 32ac7c75e8db0135ef37cf86f92d8b9be000c8bb the behavior of FcConfigAppFontAddFile/Dir() were changed to return false if not fonts were found. While this is welldefined and useful for AddFile(), it's quite problematic for AddDir(). For example, if the directory is empty, is that a failure or success? Worse, the false value from AddDir() was being propagated all the way to FcInit() returning false now. This only happened upon memory allocation failure before, and some clients assert that FcInit() is successful. With this change, AddDir() is reverted back to what it was. AddFont() change (which was actually in fcdir.c) from the original commit is left in.
-rw-r--r--doc/fcconfig.fncs2
-rw-r--r--src/fccfg.c29
-rw-r--r--src/fcint.h3
-rw-r--r--src/fcstr.c8
4 files changed, 12 insertions, 30 deletions
diff --git a/doc/fcconfig.fncs b/doc/fcconfig.fncs
index af328fc..a2ce5c8 100644
--- a/doc/fcconfig.fncs
+++ b/doc/fcconfig.fncs
@@ -232,7 +232,7 @@ the current configuration is used.
@DESC@
Scans the specified directory for fonts, adding each one found to the
application-specific set of fonts. Returns FcFalse
-if the fonts cannot be added (due to allocation failure or no fonts found).
+if the fonts cannot be added (due to allocation failure).
Otherwise returns FcTrue. If <parameter>config</parameter> is NULL,
the current configuration is used.
@@
diff --git a/src/fccfg.c b/src/fccfg.c
index abf539c..5f8f644 100644
--- a/src/fccfg.c
+++ b/src/fccfg.c
@@ -368,13 +368,10 @@ FcConfigAddDirList (FcConfig *config, FcSetName set, FcStrSet *dirSet)
FcStrList *dirlist;
FcChar8 *dir;
FcCache *cache;
- FcBool ret = FcFalse;
dirlist = FcStrListCreate (dirSet);
if (!dirlist)
return FcFalse;
- if (FcStrListGetLength (dirlist) == 0)
- ret = FcTrue;
while ((dir = FcStrListNext (dirlist)))
{
@@ -385,10 +382,9 @@ FcConfigAddDirList (FcConfig *config, FcSetName set, FcStrSet *dirSet)
continue;
FcConfigAddCache (config, cache, set, dirSet);
FcDirCacheUnload (cache);
- ret = FcTrue;
}
FcStrListDone (dirlist);
- return ret;
+ return FcTrue;
}
/*
@@ -2201,7 +2197,6 @@ FcConfigAppFontAddFile (FcConfig *config,
FcStrSet *subdirs;
FcStrList *sublist;
FcChar8 *subdir;
- FcBool ret = FcFalse;
if (!config)
{
@@ -2231,19 +2226,16 @@ FcConfigAppFontAddFile (FcConfig *config,
FcStrSetDestroy (subdirs);
return FcFalse;
}
- if (subdirs->num == 0)
- ret = FcTrue;
- else if ((sublist = FcStrListCreate (subdirs)))
+ if ((sublist = FcStrListCreate (subdirs)))
{
while ((subdir = FcStrListNext (sublist)))
{
- if (FcConfigAppFontAddDir (config, subdir))
- ret = FcTrue;
+ FcConfigAppFontAddDir (config, subdir);
}
FcStrListDone (sublist);
}
FcStrSetDestroy (subdirs);
- return ret;
+ return FcTrue;
}
FcBool
@@ -2252,7 +2244,6 @@ FcConfigAppFontAddDir (FcConfig *config,
{
FcFontSet *set;
FcStrSet *dirs;
- FcBool ret = FcTrue;
if (!config)
{
@@ -2271,8 +2262,8 @@ FcConfigAppFontAddDir (FcConfig *config,
set = FcFontSetCreate ();
if (!set)
{
- ret = FcFalse;
- goto bail;
+ FcStrSetDestroy (dirs);
+ return FcFalse;
}
FcConfigSetFonts (config, set, FcSetApplication);
}
@@ -2280,10 +2271,12 @@ FcConfigAppFontAddDir (FcConfig *config,
FcStrSetAddFilename (dirs, dir);
if (!FcConfigAddDirList (config, FcSetApplication, dirs))
- ret = FcFalse;
-bail:
+ {
+ FcStrSetDestroy (dirs);
+ return FcFalse;
+ }
FcStrSetDestroy (dirs);
- return ret;
+ return FcTrue;
}
void
diff --git a/src/fcint.h b/src/fcint.h
index ca6f8ef..15e22fd 100644
--- a/src/fcint.h
+++ b/src/fcint.h
@@ -1176,9 +1176,6 @@ FcStrSerializeAlloc (FcSerialize *serialize, const FcChar8 *str);
FcPrivate FcChar8 *
FcStrSerialize (FcSerialize *serialize, const FcChar8 *str);
-FcPrivate int
-FcStrListGetLength (const FcStrList *list);
-
/* fcobjs.c */
FcPrivate void
diff --git a/src/fcstr.c b/src/fcstr.c
index 71e033a..29a577d 100644
--- a/src/fcstr.c
+++ b/src/fcstr.c
@@ -1347,14 +1347,6 @@ FcStrListDone (FcStrList *list)
free (list);
}
-int
-FcStrListGetLength (const FcStrList *list)
-{
- if (!list)
- return 0;
- return list->set->num;
-}
-
#define __fcstr__
#include "fcaliastail.h"
#undef __fcstr__