Re: fix for unaligned accesses

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Patrick Lam <plam@xxxxxxx> さんは書きました:

> Mike FABIAN wrote:
>> 
>> I think there are still problems with the normalizing of the font
>> directory names.
>> 
>> I posted a patch to this list recently to fix the problem that
>> 
>>     fc-cache /usr/share/fonts
>>     fc-cache /usr/share/fonts/
>>     cd /usr/share/fonts; fc-cache .
>> 
>> generate different cache files, but this patch had the problem that
>> it neede to call FcInitLoadConfigAndFonts () instead of
>> FcInitLoadConfig () to be able to use FcConfigNormalizeFontDir().
>> 
>> But this has the severe disadvantage that  FcInitLoadConfigAndFonts ()
>> is very expensive, therefore this is not a good solution.
>
> I don't think that's true: I think that we *can* call
> FcConfigNormalizeFontDir if we make sure to call things in the proper
> order.  I haven't had time recently to investigate this in detail, but
> hopefully next week.

Have you looked into this issue?

I still believe that the current approach is flawed because
FcInitLoadConfig () doesn't recurse through the subdirectories and
therefore doesn't initialise the list of font directories used by
FcConfigNormalizeFontDir () completely, it fills only the directories
directly mentioned in the .conf files into the list.

There is another problem:

It used to be possible to create a cache file in a directory
with

     fc-cache directory

even if this directory was not a subdirectory of a font directory
listed in a .conf file.  I think this behaviour should not be changed,
it should be possible to create a cache in /var/cache/fontconfig for
an arbitrary directory by giving it as an argument on the fc-cache
commandline.  It would be confusing if a cache is only generated if
that directory is a subdirectory of a directory listed in a .conf
file.

But that means that this directory has to be added using
FcConfigAddFontDir () in fc-cache, it will never be added
automatically no matter which init function is called (neither
FcInitLoadConfig () nor FcConfigNormalizeFontDir () will do it).

If such a directory is given on the commandline, normalizing
it by comparing with the directories in the list is impossible.

The only possibility left is to normalize it while adding it.

I.e. it would be best if the function FcConfigAddFontDir () would
normalize directories while adding them so that they appear in the
list always in a standard form.

Then we need something like realpath () again.

Takashi Iwai <tiwai@xxxxxxx> had the idea that realpath () can be
emulated portably using chdir () and getcwd ().

I made a patch to use this idea in FcConfigAddFontDir () (patch is
attached).

Unfortunately we noticed later that this might cause problems
because chdir () is process global and therefore not thread-safe.

Maybe it is the best to implement portable version of realpath () in
fontconfig?

libiberty from binutils also implements it's own version of realpath (),
maybe that can be used.

diff -ru fontconfig-2.3.93.20060120.orig/fc-cache/Makefile.am fontconfig-2.3.93.20060120/fc-cache/Makefile.am
--- fontconfig-2.3.93.20060120.orig/fc-cache/Makefile.am	2005-12-21 16:47:42.000000000 +0100
+++ fontconfig-2.3.93.20060120/fc-cache/Makefile.am	2006-01-20 19:01:00.000000000 +0100
@@ -42,7 +42,7 @@
 stamp:
 	touch $@
 
-INCLUDES=-I${top_srcdir} $(FREETYPE_CFLAGS)
+INCLUDES=-I${top_srcdir}/src -I${top_srcdir} $(FREETYPE_CFLAGS)
 
 bin_PROGRAMS=fc-cache
 
diff -ru fontconfig-2.3.93.20060120.orig/fc-cache/fc-cache.c fontconfig-2.3.93.20060120/fc-cache/fc-cache.c
--- fontconfig-2.3.93.20060120.orig/fc-cache/fc-cache.c	2006-01-16 12:47:55.000000000 +0100
+++ fontconfig-2.3.93.20060120/fc-cache/fc-cache.c	2006-01-20 19:54:11.000000000 +0100
@@ -45,6 +45,8 @@
 #define HAVE_GETOPT_LONG 0
 #endif
 
+#include "fcint.h"
+
 #if HAVE_GETOPT_LONG
 #undef  _GNU_SOURCE
 #define _GNU_SOURCE
@@ -122,7 +124,7 @@
      * Now scan all of the directories into separate databases
      * and write out the results
      */
-    while ((dir = FcStrListNext (list)))
+    while ((dir = FcConfigNormalizeFontDir(config, FcStrListNext (list))))
     {
 	if (verbose)
 	{
@@ -294,9 +296,10 @@
 	}
 	while (argv[i])
 	{
-	    if (!FcStrSetAdd (dirs, (FcChar8 *) argv[i]))
+	    if (!FcStrSetAdd (dirs, (FcChar8 *) argv[i]) ||
+		!FcConfigAddFontDir (config, (FcChar8 *) argv[i]))
 	    {
-		fprintf (stderr, "%s: Can't add directory\n", argv[0]);
+		fprintf (stderr, "%s: Can't add directory %s\n", argv[0], argv[i]);
 		return 1;
 	    }
 	    i++;
fontconfig-2.3.93.20060120/fc-cacheã? ã??ã?«ç?ºè¦?: fc-cache.c.orig
diff -ru fontconfig-2.3.93.20060120.orig/src/fccfg.c fontconfig-2.3.93.20060120/src/fccfg.c
--- fontconfig-2.3.93.20060120.orig/src/fccfg.c	2006-01-16 12:47:55.000000000 +0100
+++ fontconfig-2.3.93.20060120/src/fccfg.c	2006-01-20 22:33:21.000000000 +0100
@@ -385,7 +385,51 @@
 FcConfigAddFontDir (FcConfig	    *config,
 		    const FcChar8   *d)
 {
-    return FcStrSetAddFilename (config->fontDirs, d);
+    FcBool ret;
+    FcChar8 *newwd;
+    FcChar8 *oldwd;
+    FcChar8 *buf;
+    size_t size = 1024;
+    size_t max_size = 32768;
+    
+    if (!(oldwd = (FcChar8 *) malloc (size)))
+        return FcFalse;
+    while (!getcwd (oldwd, size))
+    {
+        size *= 2;
+	if (size > max_size ||
+	    !(buf = (FcChar8 *) realloc (oldwd, size)))
+	{
+	    free (oldwd);
+	    return FcFalse;
+	}
+	oldwd = buf;
+    }
+    if (chdir (d))
+    {
+	free (oldwd);
+        return FcTrue; /* silently ignore nonexistant directories */
+    }
+    if (!(newwd = (FcChar8 *) malloc (size)))
+        return FcFalse;
+    while (!getcwd (newwd, size))
+    {
+        size *= 2;
+	if (size > max_size ||
+	    !(buf = (FcChar8 *) realloc (newwd, size)))
+	{
+	    chdir (oldwd);
+   	    free (oldwd);
+	    free (newwd);
+	    return FcFalse;
+	}
+	newwd = buf;
+    }
+    ret = FcStrSetAddFilename (config->fontDirs, newwd);
+    chdir (oldwd);
+    free (oldwd);
+    free (newwd);
+    return ret;
 }
 
 const FcChar8 *
diff -ru fontconfig-2.3.93.20060120.orig/src/fcint.h fontconfig-2.3.93.20060120/src/fcint.h
--- fontconfig-2.3.93.20060120.orig/src/fcint.h	2006-01-16 12:47:55.000000000 +0100
+++ fontconfig-2.3.93.20060120/src/fcint.h	2006-01-20 19:18:03.000000000 +0100
@@ -32,6 +32,7 @@
 #include <ctype.h>
 #include <errno.h>
 #include <unistd.h>
+#include <limits.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <time.h>

-- 
Mike FABIAN   <mfabian@xxxxxxx>   http://www.suse.de/~mfabian
睡眠不足はいい仕事の敵だ。
_______________________________________________
Fontconfig mailing list
Fontconfig@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/fontconfig

[Index of Archives]     [Fedora Fonts]     [Fedora Users]     [Fedora Cloud]     [Kernel]     [Fedora Packaging]     [Fedora Desktop]     [PAM]     [Gimp Graphics Editor]     [Yosemite News]

  Powered by Linux