[Fontconfig] fontconfig: Branch 'master' - 7 commits

Behdad Esfahbod behdad at kemper.freedesktop.org
Wed Jan 2 16:24:10 PST 2013


 Makefile.am                 |   11 ++++++++--
 configure.ac                |    5 ----
 doc/Makefile.am             |   14 ++++++++-----
 fc-case/Makefile.am         |    8 -------
 fc-glyphname/Makefile.am    |    9 +++-----
 fc-glyphname/fc-glyphname.c |   46 ++++++++++++++++++++++----------------------
 fc-lang/Makefile.am         |    9 ++------
 src/Makefile.am             |    1 
 src/fcatomic.h              |    9 ++------
 src/fccache.c               |    2 -
 src/fccfg.c                 |   19 ++++++------------
 src/fcdefault.c             |    6 ++---
 src/fcint.h                 |   16 +++------------
 src/fclist.c                |    6 ++---
 src/fcmutex.h               |    5 +---
 src/fcname.c                |    2 -
 src/fcobjs.c                |   14 +++++++++----
 src/fcobjshash.gperf.h      |    2 -
 src/fcpat.c                 |   25 ++---------------------
 src/fcstat.c                |    3 --
 src/fcstr.c                 |   14 -------------
 src/fcwindows.h             |   44 ++++++++++++++++++++++++++++++++++++++++++
 src/fcxml.c                 |   28 +++++++++++++-------------
 23 files changed, 148 insertions(+), 150 deletions(-)

New commits:
commit 538f1579e86fdcf471cea58945bf8c674d5b91e7
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Jan 2 18:07:13 2013 -0600

    Trying to fix distcheck
    
    Doesn't work though :(.  Building docs is very fragile...
    
    At least, if docbook is present, distcheck passes now.

diff --git a/Makefile.am b/Makefile.am
index cbc3df0..6aee88a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -21,10 +21,15 @@
 #  TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 #  PERFORMANCE OF THIS SOFTWARE.
 
-DOCSRC=@DOCSRC@
 SUBDIRS=fontconfig fc-case fc-lang fc-glyphname src \
 	fc-cache fc-cat fc-list fc-match fc-pattern fc-query fc-scan \
-	conf.d $(DOCSRC) test
+	conf.d test
+if ENABLE_DOCS
+SUBDIRS += doc
+DIST_SUBDIRS = $(SUBDIRS)
+else
+DIST_SUBDIRS = $(SUBDIRS) doc
+endif
 
 AUTOMAKE_OPTIONS = dist-bzip2
 ACLOCAL_AMFLAGS = -I m4
@@ -149,4 +154,6 @@ debuild-dirs: distdir
 	cp -a $(distdir) $(distdir).orig
 	$(RM) -r $(distdir).orig/debian
 
+DISTCHECK_CONFIGURE_FLAGS =
+
 -include $(top_srcdir)/git.mk
diff --git a/configure.ac b/configure.ac
index 3a89e7e..3f0ffbf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -633,7 +633,6 @@ AC_ARG_ENABLE(docs,
 AM_CONDITIONAL(ENABLE_DOCS, test "x$enable_docs" = xyes)
 
 if test "x$enable_docs" = xyes; then
-	DOCSRC="doc"
 	tmp=funcs.$$
 	cat $srcdir/doc/*.fncs | awk '
 	/^@TITLE@/	{ if (!done) { printf ("%s\n", $2); done = 1; } }
@@ -643,11 +642,8 @@ if test "x$enable_docs" = xyes; then
 	echo DOCMAN3 $DOCMAN3
 	rm -f $tmp
 else
-	DOCSRC=""
 	DOCMAN3=""
 fi
-
-AC_SUBST(DOCSRC)
 AC_SUBST(DOCMAN3)
 
 
diff --git a/doc/Makefile.am b/doc/Makefile.am
index cf1fb89..c6b095c 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -199,10 +199,18 @@ all-local: $(BUILT_DOCS) $(HTML_DIR)/*
 clean-local:
 	$(RM) -r $(HTML_DIR) devel-man
 	[ "x$(builddir)" != "x$(srcdir)" ] && $(RM) $(builddir)/*.sgml || :
+dist-local-check-docs-enabled:
+	@true
 else
 htmldoc_DATA += $(srcdir)/$(HTML_DIR)/*
 all-local:
 clean-local:
+dist-local-check-docs-enabled:
+	@echo "*** --enable-man must be used in order to make dist"
+	@false
 endif
 
+# force doc rebulid after configure
+dist-hook-local: dist-local-check-docs-enabled
+
 -include $(top_srcdir)/git.mk
commit 46ab96b8fa029fbc8ccf69a6f2fda89866e3ac9c
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Jan 2 17:52:00 2013 -0600

    Fix more warnings.
    
    Linux build and mingw32 cross build warning-free now.

diff --git a/src/fcobjs.c b/src/fcobjs.c
index b3bb200..1aa4a77 100644
--- a/src/fcobjs.c
+++ b/src/fcobjs.c
@@ -24,15 +24,21 @@
 
 #include "fcint.h"
 
+static unsigned int
+FcObjectTypeHash (register const char *str, register unsigned int len);
+
+static const struct FcObjectTypeInfo *
+FcObjectTypeLookup (register const char *str, register unsigned int len);
+
 #include "fcobjshash.h"
 
 #include <string.h>
 
-static int next_id = FC_MAX_BASE_OBJECT + 1;
+static fc_atomic_int_t next_id = FC_MAX_BASE_OBJECT + 1;
 struct FcObjectOtherTypeInfo {
     struct FcObjectOtherTypeInfo *next;
     FcObjectType object;
-    int id;
+    FcObject id;
 } *other_types;
 
 static FcObjectType *
diff --git a/src/fcobjshash.gperf.h b/src/fcobjshash.gperf.h
index 94002b1..dafac1b 100644
--- a/src/fcobjshash.gperf.h
+++ b/src/fcobjshash.gperf.h
@@ -4,7 +4,7 @@ CUT_OUT_BEGIN
 CUT_OUT_END
 %}
 %struct-type
-%language=C
+%language=ANSI-C
 %includes
 %enum
 %readonly-tables
commit 558b3c65f91b4b2dd65ce2242e1a21ace621e44b
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Jan 2 17:49:41 2013 -0600

    Use CC_FOR_BUILD to generate source files
    
    Previously we were failing if CROSS_COMPILING and the generated headers
    were not present.  It works just fine now.
    
    One caveat: the fix is not fully correct since config.h is being
    included in the files built with CC_FOR_BUILD, but config.h has config
    for the host system, not the build system.  Should be fine though.

diff --git a/configure.ac b/configure.ac
index fda5650..3a89e7e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -105,6 +105,7 @@ AC_SUBST(WARN_CFLAGS)
 
 dnl ==========================================================================
 
+AC_ARG_VAR(CC_FOR_BUILD, [build system C compiler])
 AM_CONDITIONAL(CROSS_COMPILING, test $cross_compiling = yes)
 AM_CONDITIONAL(ENABLE_SHARED, test "$enable_shared" = "yes")
 
diff --git a/doc/Makefile.am b/doc/Makefile.am
index ad68c09..cf1fb89 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -118,6 +118,7 @@ noinst_PROGRAMS =	\
 edit_sgml_SOURCES =	\
 	edit-sgml.c	\
 	$(NULL)
+edit_sgml_CC = $(CC_FOR_BUILD)
 #
 check_SCRIPTS =			\
 	check-missing-doc	\
@@ -150,14 +151,9 @@ noinst_PROGRAMS +=	\
 htmldoc_DATA += $(HTML_DIR)/*
 
 ##
-if CROSS_COMPILING
-.fncs.sgml:
-	@echo Warning: cannot rebuild $@ when cross-compiling
-else
 .fncs.sgml:
 	$(AM_V_GEN) $(RM) $@; \
 	$(builddir)/edit-sgml$(EXEEXT) $(srcdir)/func.sgml < '$(srcdir)/$*.fncs' > $*.sgml
-endif
 .sgml.txt:
 	$(AM_V_GEN) $(RM) $@; \
 	$(DOC2TXT) $*.sgml
diff --git a/fc-case/Makefile.am b/fc-case/Makefile.am
index 9bab1c7..c56e657 100644
--- a/fc-case/Makefile.am
+++ b/fc-case/Makefile.am
@@ -33,18 +33,13 @@ noinst_PROGRAMS=fc-case
 
 noinst_HEADERS=$(TARG)
 
-fc_case_SOURCES= \
-	fc-case.c
+fc_case_CC = $(CC_FOR_BUILD)
 
 CASEFOLDING=CaseFolding.txt
 SCASEFOLDING=${top_srcdir}/fc-case/CaseFolding.txt
 
 EXTRA_DIST = $(TARG) $(TMPL) $(CASEFOLDING)
 
-if CROSS_COMPILING
-$(TARG): $(STMPL) fc-case.c $(SCASEFOLDING)
-	@echo Warning: cannot rebuild $(TARG) when cross-compiling
-else
 ## BUILT_SOURCES doesn't effect to 'distcheck'
 ## so $(ALIAS_FILES) has to be appeared prior to fc-case$(EXEEXT)
 ## to make sure availability.
@@ -52,7 +47,6 @@ $(TARG): $(STMPL) $(ALIAS_FILES) fc-case$(EXEEXT) $(SCASEFOLDING)
 	$(AM_V_GEN) $(RM) $(TARG); \
 	./fc-case$(EXEEXT) $(SCASEFOLDING) < $(STMPL) > $(TARG).tmp && \
 	mv $(TARG).tmp $(TARG)
-endif
 
 ALIAS_FILES = fcalias.h fcaliastail.h
 
diff --git a/fc-glyphname/Makefile.am b/fc-glyphname/Makefile.am
index f6aeea7..3ddd53a 100644
--- a/fc-glyphname/Makefile.am
+++ b/fc-glyphname/Makefile.am
@@ -31,15 +31,15 @@ TARG=fcglyphname.h
 
 noinst_PROGRAMS=fc-glyphname
 
+noinst_HEADERS=$(TARG)
+
+fc_glyphname_CC = $(CC_FOR_BUILD)
+
 GLYPHNAME=zapfdingbats.txt
 SGLYPHNAME=${top_srcdir}/fc-glyphname/zapfdingbats.txt
 
 EXTRA_DIST = $(TARG) $(TMPL) $(GLYPHNAME)
 
-if CROSS_COMPILING
-$(TARG): $(STMPL) fc-glyphname.c $(SGLYPHNAME)
-	@echo Warning: cannot rebuild $(TARG) when cross-compiling
-else
 ## BUILT_SOURCES doesn't effect to 'distcheck'
 ## so $(ALIAS_FILES) has to be appeared prior to fc-glyphname$(EXEEXT)
 ## to make sure availability.
@@ -47,7 +47,6 @@ $(TARG): $(STMPL) $(ALIAS_FILES) fc-glyphname$(EXEEXT) $(SGLYPHNAME)
 	$(AM_V_GEN) $(RM) $(TARG); \
 	./fc-glyphname$(EXEEXT) $(SGLYPHNAME) < $(STMPL) > $(TARG).tmp && \
 	mv $(TARG).tmp $(TARG)
-endif
 
 ALIAS_FILES = fcalias.h fcaliastail.h
 
diff --git a/fc-lang/Makefile.am b/fc-lang/Makefile.am
index 35e94e5..536cff2 100644
--- a/fc-lang/Makefile.am
+++ b/fc-lang/Makefile.am
@@ -31,14 +31,12 @@ TARG=fclang.h
 
 noinst_PROGRAMS=fc-lang
 
-noinst_MANS=fc-lang.man
+noinst_HEADERS=$(TARG)
+
+fc_lang_CC = $(CC_FOR_BUILD)
 
 EXTRA_DIST = $(TARG) $(TMPL) $(ORTH)
 
-if CROSS_COMPILING
-$(TARG):$(ORTH) fc-lang.c $(STMPL)
-	@echo Warning: cannot rebuild $(TARG) when cross-compiling
-else
 ## BUILT_SOURCES doesn't effect to 'distcheck'
 ## so $(ALIAS_FILES) has to be appeared prior to fc-lang$(EXEEXT)
 ## to make sure availability.
@@ -46,7 +44,6 @@ $(TARG):$(ORTH) $(ALIAS_FILES) fc-lang${EXEEXT} $(STMPL)
 	$(AM_V_GEN) $(RM) $(TARG); \
 	./fc-lang${EXEEXT} -d ${srcdir} $(ORTH) < $(STMPL) > $(TARG).tmp && \
 	mv $(TARG).tmp $(TARG)
-endif
 
 ALIAS_FILES = fcalias.h fcaliastail.h
 
commit ec8a40d2381014ad2e72b5da0e6357a85f078f9f
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Jan 2 17:35:56 2013 -0600

    Fix build and warnings on win32

diff --git a/src/Makefile.am b/src/Makefile.am
index da1358c..c32c6f3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -148,6 +148,7 @@ libfontconfig_la_SOURCES = \
 	fcserialize.c \
 	fcstat.c \
 	fcstr.c \
+	fcwindows.h \
 	fcxml.c \
 	ftglue.h \
 	ftglue.c
diff --git a/src/fcatomic.h b/src/fcatomic.h
index 71c0491..073809e 100644
--- a/src/fcatomic.h
+++ b/src/fcatomic.h
@@ -3,9 +3,7 @@
  *
  * Copyright © 2007  Chris Wilson
  * Copyright © 2009,2010  Red Hat, Inc.
- * Copyright © 2011,2012  Google, Inc.
- *
- *  This is part of HarfBuzz, a text shaping library.
+ * Copyright © 2011,2012,2013  Google, Inc.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
@@ -48,8 +46,7 @@
 
 #elif !defined(FC_NO_MT) && defined(_MSC_VER) || defined(__MINGW32__)
 
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
+#include "fcwindows.h"
 
 /* mingw32 does not have MemoryBarrier.
  * MemoryBarrier may be defined as a macro or a function.
@@ -63,7 +60,7 @@ static inline void HBMemoryBarrier (void) {
 }
 #endif
 
-typedef int fc_atomic_int_t;
+typedef LONG fc_atomic_int_t;
 #define fc_atomic_int_add(AI, V)	InterlockedExchangeAdd (&(AI), (V))
 
 #define fc_atomic_ptr_get(P)		(HBMemoryBarrier (), (void *) *(P))
diff --git a/src/fccache.c b/src/fccache.c
index 2f0f5d7..2f1104f 100644
--- a/src/fccache.c
+++ b/src/fccache.c
@@ -77,7 +77,7 @@ FcCacheIsMmapSafe (int fd)
 	    status =  use ? MMAP_USE : MMAP_DONT_USE;
 	else
 	    status = MMAP_CHECK_FS;
-	fc_atomic_ptr_cmpexch (&static_status, NULL, (void *) status);
+	(void) fc_atomic_ptr_cmpexch (&static_status, NULL, (void *) status);
     }
 
     if (status == MMAP_CHECK_FS)
diff --git a/src/fccfg.c b/src/fccfg.c
index bc408db..877a4f5 100644
--- a/src/fccfg.c
+++ b/src/fccfg.c
@@ -28,12 +28,6 @@
 #include <dirent.h>
 #include <sys/types.h>
 
-#if defined (_WIN32) && (defined (PIC) || defined (DLL_EXPORT))
-#define STRICT
-#include <windows.h>
-#undef STRICT
-#endif
-
 #if defined (_WIN32) && !defined (R_OK)
 #define R_OK 4
 #endif
@@ -270,7 +264,7 @@ FcConfigDestroy (FcConfig *config)
     if (FcRefDec (&config->ref) != 1)
 	return;
 
-    fc_atomic_ptr_cmpexch (&_fcConfig, config, NULL);
+    (void) fc_atomic_ptr_cmpexch (&_fcConfig, config, NULL);
 
     FcStrSetDestroy (config->configDirs);
     FcStrSetDestroy (config->fontDirs);
@@ -1737,10 +1731,6 @@ FcConfigSubstitute (FcConfig	*config,
 
 #if defined (_WIN32)
 
-#  define WIN32_LEAN_AND_MEAN
-#  define WIN32_EXTRA_LEAN
-#  include <windows.h>
-
 static FcChar8 fontconfig_path[1000] = ""; /* MT-dontcare */
 
 #  if (defined (PIC) || defined (DLL_EXPORT))
@@ -1748,6 +1738,11 @@ static FcChar8 fontconfig_path[1000] = ""; /* MT-dontcare */
 BOOL WINAPI
 DllMain (HINSTANCE hinstDLL,
 	 DWORD     fdwReason,
+	 LPVOID    lpvReserved);
+
+BOOL WINAPI
+DllMain (HINSTANCE hinstDLL,
+	 DWORD     fdwReason,
 	 LPVOID    lpvReserved)
 {
   FcChar8 *p;
diff --git a/src/fcint.h b/src/fcint.h
index 9520be3..38bd9bb 100644
--- a/src/fcint.h
+++ b/src/fcint.h
@@ -53,12 +53,7 @@
 #endif
 
 #ifdef _WIN32
-#  ifndef _WIN32_WINNT
-#    define _WIN32_WINNT 0x0500
-#  endif
-#  define WIN32_LEAN_AND_MEAN
-#  define STRICT
-#  include <windows.h>
+#  include "fcwindows.h"
 typedef UINT (WINAPI *pfnGetSystemWindowsDirectory)(LPSTR, UINT);
 typedef HRESULT (WINAPI *pfnSHGetFolderPathA)(HWND, int, HANDLE, DWORD, LPSTR);
 extern pfnGetSystemWindowsDirectory pGetSystemWindowsDirectory;
diff --git a/src/fcmutex.h b/src/fcmutex.h
index b10572c..556a05e 100644
--- a/src/fcmutex.h
+++ b/src/fcmutex.h
@@ -3,7 +3,7 @@
  *
  * Copyright © 2007  Chris Wilson
  * Copyright © 2009,2010  Red Hat, Inc.
- * Copyright © 2011,2012  Google, Inc.
+ * Copyright © 2011,2012,2013  Google, Inc.
  *
  * Permission is hereby granted, without written agreement and without
  * license or royalty fees, to use, copy, modify, and distribute this
@@ -48,8 +48,7 @@
 
 #elif !defined(FC_NO_MT) && defined(_MSC_VER) || defined(__MINGW32__)
 
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
+#include "fcwindows.h"
 typedef CRITICAL_SECTION fc_mutex_impl_t;
 #define FC_MUTEX_IMPL_INIT	{ NULL, 0, 0, NULL, NULL, 0 }
 #define fc_mutex_impl_init(M)	InitializeCriticalSection (M)
diff --git a/src/fcstat.c b/src/fcstat.c
index d1730fd..9763c21 100644
--- a/src/fcstat.c
+++ b/src/fcstat.c
@@ -44,9 +44,6 @@
 #endif
 
 #ifdef _WIN32
-
-#include <windows.h>
-
 #ifdef __GNUC__
 typedef long long INT64;
 #define EPOCH_OFFSET 11644473600ll
diff --git a/src/fcstr.c b/src/fcstr.c
index 34093a0..cdab383 100644
--- a/src/fcstr.c
+++ b/src/fcstr.c
@@ -29,9 +29,6 @@
 #ifdef HAVE_REGEX_H
 #include <regex.h>
 #endif
-#ifdef _WIN32
-#include <windows.h>
-#endif
 
 /* Objects MT-safe for readonly access. */
 
diff --git a/src/fcwindows.h b/src/fcwindows.h
new file mode 100644
index 0000000..02489d9
--- /dev/null
+++ b/src/fcwindows.h
@@ -0,0 +1,44 @@
+/*
+ * fontconfig/src/fcwindows.h
+ *
+ * Copyright © 2013  Google, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of the author(s) not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  The authors make no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Google Author(s): Behdad Esfahbod
+ */
+
+#ifndef _FCWINDOWS_H_
+#define _FCWINDOWS_H_
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef _WIN32
+#  ifndef _WIN32_WINNT
+#    define _WIN32_WINNT 0x0500
+#  endif
+#  define WIN32_LEAN_AND_MEAN
+#  define WIN32_EXTRA_LEAN
+#  define STRICT
+#  include <windows.h>
+#endif
+
+#endif /* _FCWINDOWS_H_ */
diff --git a/src/fcxml.c b/src/fcxml.c
index 1f068ce..b234e43 100644
--- a/src/fcxml.c
+++ b/src/fcxml.c
@@ -1419,7 +1419,7 @@ static void
 FcParseRange (FcConfigParse *parse)
 {
     FcVStack	*vstack;
-    FcRange	r;
+    FcRange	r = {0, 0};
     FcChar32	n;
     int		count = 1;
 
@@ -1961,7 +1961,7 @@ FcParseDir (FcConfigParse *parse)
 #ifdef _WIN32
     if (strcmp ((const char *) data, "CUSTOMFONTDIR") == 0)
     {
-	char *p;
+	FcChar8 *p;
 	data = buffer;
 	if (!GetModuleFileName (NULL, (LPCH) buffer, sizeof (buffer) - 20))
 	{
@@ -1976,11 +1976,11 @@ FcParseDir (FcConfigParse *parse)
 	 */
 	p = _mbsrchr (data, '\\');
 	if (p) *p = '\0';
-	strcat (data, "\\fonts");
+	strcat ((char *) data, "\\fonts");
     }
     else if (strcmp ((const char *) data, "APPSHAREFONTDIR") == 0)
     {
-	char *p;
+	FcChar8 *p;
 	data = buffer;
 	if (!GetModuleFileName (NULL, (LPCH) buffer, sizeof (buffer) - 20))
 	{
@@ -1989,7 +1989,7 @@ FcParseDir (FcConfigParse *parse)
 	}
 	p = _mbsrchr (data, '\\');
 	if (p) *p = '\0';
-	strcat (data, "\\..\\share\\fonts");
+	strcat ((char *) data, "\\..\\share\\fonts");
     }
     else if (strcmp ((const char *) data, "WINDOWSFONTDIR") == 0)
     {
@@ -2002,8 +2002,8 @@ FcParseDir (FcConfigParse *parse)
 	    goto bail;
 	}
 	if (data [strlen ((const char *) data) - 1] != '\\')
-	    strcat (data, "\\");
-	strcat (data, "fonts");
+	    strcat ((char *) data, "\\");
+	strcat ((char *) data, "fonts");
     }
 #endif
     if (strlen ((char *) data) == 0)
@@ -2072,8 +2072,8 @@ FcParseCacheDir (FcConfigParse *parse)
 	    goto bail;
 	}
 	if (data [strlen ((const char *) data) - 1] != '\\')
-	    strcat (data, "\\");
-	strcat (data, "fontconfig\\cache");
+	    strcat ((char *) data, "\\");
+	strcat ((char *) data, "fontconfig\\cache");
     }
     else if (strcmp ((const char *) data, "LOCAL_APPDATA_FONTCONFIG_CACHE") == 0)
     {
commit 5c0a4f2726fd1440bf3ec4bb375e5e4d146bd989
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Jan 2 02:27:57 2013 -0600

    Minor

diff --git a/fc-glyphname/fc-glyphname.c b/fc-glyphname/fc-glyphname.c
index b790d98..9085f2d 100644
--- a/fc-glyphname/fc-glyphname.c
+++ b/fc-glyphname/fc-glyphname.c
@@ -58,12 +58,12 @@ FcAllocGlyphName (FcChar32 ucs, FcChar8 *name)
     return gn;
 }
 
-static void 
+static void
 fatal (const char *file, int lineno, const char *msg)
 {
     if (lineno)
         fprintf (stderr, "%s:%d: %s\n", file, lineno, msg);
-    else 
+    else
 	fprintf (stderr, "%s: %s\n", file, msg);
 
     exit (1);
@@ -100,7 +100,7 @@ scan (FILE *f, char *filename)
     FcGlyphName	    *gn;
     int		    lineno = 0;
     int		    len;
-    
+
     while (fgets (buf, sizeof (buf), f))
     {
 	lineno++;
@@ -177,7 +177,7 @@ find_hash (void)
     int	h;
 
     h = nraw + nraw / 4;
-    if ((h & 1) == 0) 
+    if ((h & 1) == 0)
 	h++;
     while (!isprime(h-2) || !isprime(h))
 	h += 2;
@@ -201,12 +201,12 @@ FcHashGlyphName (const FcChar8 *name)
 static void
 insert (FcGlyphName *gn, FcGlyphName **table, FcChar32 h)
 {
-    int		i, r = 0;
+    unsigned int	i, r = 0;
 
     i = (int) (h % hash);
     while (table[i])
     {
-	if (!r) r = (int) (h % rehash + 1);
+	if (!r) r = (h % rehash + 1);
 	i += r;
 	if (i >= hash)
 	    i -= hash;
@@ -217,8 +217,8 @@ insert (FcGlyphName *gn, FcGlyphName **table, FcChar32 h)
 static void
 dump (FcGlyphName * const *table, const char *name)
 {
-    int	    i;
-    
+    unsigned int	    i;
+
     printf ("static const FcGlyphId %s[%d] = {\n", name, hash);
 
     for (i = 0; i < hash; i++)
@@ -226,7 +226,7 @@ dump (FcGlyphName * const *table, const char *name)
 	    printf ("    %d,\n", rawindex(table[i]));
 	else
 	    printf ("    -1,\n");
-    
+
     printf ("};\n");
 }
 
@@ -237,8 +237,8 @@ main (int argc, char **argv)
     char	line[1024];
     FILE	*f;
     int		i;
-    char	*type;
-    
+    const char	*type;
+
     i = 0;
     while (argv[i+1])
     {
@@ -249,7 +249,7 @@ main (int argc, char **argv)
     }
     files[i] = 0;
     qsort (files, i, sizeof (char *), compare_string);
-    for (i = 0; files[i]; i++) 
+    for (i = 0; files[i]; i++)
     {
 	f = fopen (files[i], "r");
 	if (!f)
@@ -260,27 +260,27 @@ main (int argc, char **argv)
     qsort (raw, nraw, sizeof (FcGlyphName *), compare_glyphname);
 
     find_hash ();
-    
+
     for (i = 0; i < nraw; i++)
     {
 	insert (raw[i], name_to_ucs, FcHashGlyphName (raw[i]->name));
 	insert (raw[i], ucs_to_name, raw[i]->ucs);
     }
-    
+
     /*
      * Scan the input until the marker is found
      */
-    
+
     while (fgets (line, sizeof (line), stdin))
     {
 	if (!strncmp (line, "@@@", 3))
 	    break;
 	fputs (line, stdout);
     }
-    
+
     printf ("/* %d glyphnames in %d entries, %d%% occupancy */\n\n",
 	    nraw, hash, nraw * 100 / hash);
-	      
+
     printf ("#define FC_GLYPHNAME_HASH %u\n", hash);
     printf ("#define FC_GLYPHNAME_REHASH %u\n", rehash);
     printf ("#define FC_GLYPHNAME_MAXLEN %d\n\n", max_name_len);
@@ -290,16 +290,16 @@ main (int argc, char **argv)
 	type = "int16_t";
     else
 	type = "int32_t";
-    
+
     printf ("typedef %s FcGlyphId;\n\n", type);
-    
+
     /*
      * Dump out entries
      */
-    
+
     printf ("static const struct { const FcChar32 ucs; const FcChar8 name[%d]; } _fc_glyph_names[%d] = {\n",
 	    max_name_len + 1, nraw);
-    
+
     for (i = 0; i < nraw; i++)
 	printf ("    { 0x%lx, \"%s\" },\n",
 		(unsigned long) raw[i]->ucs, raw[i]->name);
@@ -311,7 +311,7 @@ main (int argc, char **argv)
      */
 
     dump (name_to_ucs, "_fc_name_to_ucs");
-    
+
     /*
      * Dump out ucs_to_name table
      */
@@ -319,7 +319,7 @@ main (int argc, char **argv)
 
     while (fgets (line, sizeof (line), stdin))
 	fputs (line, stdout);
-    
+
     fflush (stdout);
     exit (ferror (stdout));
 }
commit 766bed901f7f4c648387fb403ef6e253be1c45e9
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Jan 2 02:19:04 2013 -0600

    Fix compiler warnings

diff --git a/src/fcobjs.c b/src/fcobjs.c
index 4a1b0a8..b3bb200 100644
--- a/src/fcobjs.c
+++ b/src/fcobjs.c
@@ -53,7 +53,7 @@ retry:
 	if (!ot)
 	    return NULL;
 
-	ot->object.object = FcStrdup (str);
+	ot->object.object = (const char *) FcStrdup (str);
 	ot->object.type = -1;
 	ot->id = fc_atomic_int_add (next_id, +1);
 	ot->next = ots;
@@ -74,7 +74,7 @@ FcObject
 FcObjectLookupBuiltinIdByName (const char *str)
 {
     const struct FcObjectTypeInfo *o = FcObjectTypeLookup (str, strlen (str));
-    FcObject id;
+
     if (o)
 	return o->id;
 
commit 93fb1d4bab5fefb73393141bb3e96c9dc279e615
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Jan 2 02:06:15 2013 -0600

    Remove FcSharedStr*

diff --git a/src/fccfg.c b/src/fccfg.c
index 1069cd2..bc408db 100644
--- a/src/fccfg.c
+++ b/src/fccfg.c
@@ -1081,7 +1081,7 @@ FcConfigEvaluate (FcPattern *p, FcPattern *p_pat, FcMatchKind kind, FcExpr *e)
 		case FcOpPlus:
 		    v.type = FcTypeString;
 		    str = FcStrPlus (vl.u.s, vr.u.s);
-		    v.u.s = FcSharedStr (str);
+		    v.u.s = FcStrdup (str);
 		    FcStrFree (str);
 			
 		    if (!v.u.s)
diff --git a/src/fcdefault.c b/src/fcdefault.c
index 0069db2..6937994 100644
--- a/src/fcdefault.c
+++ b/src/fcdefault.c
@@ -92,7 +92,7 @@ retry:
     if (!lang)
     {
 	FcStrSet *langs = FcGetDefaultLangs ();
-	lang = (FcChar8 *) strdup ((const char *) langs->strs[0]);
+	lang = FcStrdup (langs->strs[0]);
 	FcStrSetDestroy (langs);
 
 	if (!fc_atomic_ptr_cmpexch (&default_lang, NULL, lang)) {
@@ -195,7 +195,7 @@ FcDefaultSubstitute (FcPattern *pattern)
      * exact matched "en" has higher score than ll-cc.
      */
     v2.type = FcTypeString;
-    v2.u.s = FcSharedStr ((FcChar8 *)"en-us");
+    v2.u.s = FcStrdup ("en-us");
     if (FcPatternObjectGet (pattern, FC_FAMILYLANG_OBJECT, 0, &v) == FcResultNoMatch)
     {
 	FcPatternObjectAdd (pattern, FC_FAMILYLANG_OBJECT, namelang, FcTrue);
@@ -211,7 +211,7 @@ FcDefaultSubstitute (FcPattern *pattern)
 	FcPatternObjectAdd (pattern, FC_FULLNAMELANG_OBJECT, namelang, FcTrue);
 	FcPatternObjectAddWithBinding (pattern, FC_FULLNAMELANG_OBJECT, v2, FcValueBindingWeak, FcTrue);
     }
-    FcSharedStrFree ((FcChar8 *) v2.u.s);
+    FcFree (v2.u.s);
 }
 #define __fcdefault__
 #include "fcaliastail.h"
diff --git a/src/fcint.h b/src/fcint.h
index 17298f7..9520be3 100644
--- a/src/fcint.h
+++ b/src/fcint.h
@@ -115,6 +115,9 @@ typedef enum _FcValueBinding {
     FcValueBindingWeak, FcValueBindingStrong, FcValueBindingSame
 } FcValueBinding;
 
+#define FcStrdup(s) ((FcChar8 *) strdup ((const char *) (s)))
+#define FcFree(s) (free ((FcChar8 *) (s)))
+
 /*
  * Serialized data structures use only offsets instead of pointers
  * A low bit of 1 indicates an offset.
@@ -969,12 +972,6 @@ FcPatternObjectGetLangSet (const FcPattern *p, FcObject object, int n, FcLangSet
 FcPrivate FcBool
 FcPatternAppend (FcPattern *p, FcPattern *s);
 
-FcPrivate const FcChar8 *
-FcSharedStr (const FcChar8 *name);
-
-FcPrivate FcBool
-FcSharedStrFree (FcChar8 *name);
-
 FcPrivate FcChar32
 FcStringHash (const FcChar8 *s);
 
diff --git a/src/fclist.c b/src/fclist.c
index ba68d68..b7ae899 100644
--- a/src/fclist.c
+++ b/src/fclist.c
@@ -63,14 +63,14 @@ FcObjectSetAdd (FcObjectSet *os, const char *object)
     low = 0;
     mid = 0;
     c = 1;
-    object = (char *)FcSharedStr ((FcChar8 *)object);
+    object = strdup (object);
     while (low <= high)
     {
 	mid = (low + high) >> 1;
 	c = os->objects[mid] - object;
 	if (c == 0)
 	{
-	    FcSharedStrFree ((FcChar8 *)object);
+	    FcFree (object);
 	    return FcTrue;
 	}
 	if (c < 0)
@@ -95,7 +95,7 @@ FcObjectSetDestroy (FcObjectSet *os)
     if (os->objects)
     {
 	for (i = 0; i < os->nobject; i++)
-	    FcSharedStrFree ((FcChar8 *)os->objects[i]);
+	    FcFree (os->objects[i]);
 
 	free ((void *) os->objects);
     }
diff --git a/src/fcname.c b/src/fcname.c
index 1bfc3b7..2418189 100644
--- a/src/fcname.c
+++ b/src/fcname.c
@@ -279,7 +279,7 @@ FcNameConvert (FcType type, FcChar8 *string)
 	    v.u.i = atoi ((char *) string);
 	break;
     case FcTypeString:
-	v.u.s = FcSharedStr (string);
+	v.u.s = FcStrdup (string);
 	if (!v.u.s)
 	    v.type = FcTypeVoid;
 	break;
diff --git a/src/fcobjs.c b/src/fcobjs.c
index 9336068..4a1b0a8 100644
--- a/src/fcobjs.c
+++ b/src/fcobjs.c
@@ -53,7 +53,7 @@ retry:
 	if (!ot)
 	    return NULL;
 
-	ot->object.object = strdup (str);
+	ot->object.object = FcStrdup (str);
 	ot->object.type = -1;
 	ot->id = fc_atomic_int_add (next_id, +1);
 	ot->next = ots;
diff --git a/src/fcpat.c b/src/fcpat.c
index c3b90d6..b3b155d 100644
--- a/src/fcpat.c
+++ b/src/fcpat.c
@@ -45,8 +45,7 @@ FcValueDestroy (FcValue v)
 {
     switch ((int) v.type) {
     case FcTypeString:
-	if (!FcSharedStrFree (v.u.s))
-            FcStrFree ((FcChar8 *) v.u.s);
+	FcFree (v.u.s);
 	break;
     case FcTypeMatrix:
 	FcMatrixFree ((FcMatrix *) v.u.m);
@@ -93,7 +92,7 @@ FcValueSave (FcValue v)
 {
     switch ((int) v.type) {
     case FcTypeString:
-	v.u.s = FcSharedStr (v.u.s);
+	v.u.s = FcStrdup (v.u.s);
 	if (!v.u.s)
 	    v.type = FcTypeVoid;
 	break;
@@ -132,8 +131,7 @@ FcValueListDestroy (FcValueListPtr l)
     {
 	switch ((int) l->value.type) {
 	case FcTypeString:
-	    if (!FcSharedStrFree ((FcChar8 *)l->value.u.s))
-                FcStrFree ((FcChar8 *)l->value.u.s);
+	    FcFree (l->value.u.s);
 	    break;
 	case FcTypeMatrix:
 	    FcMatrixFree ((FcMatrix *)l->value.u.m);
@@ -1147,23 +1145,6 @@ bail0:
 }
 
 
-/* We used to have a shared-str pool.  Removed to make thread-safety
- * work easier.  My measurements show that the extra overhead is not
- * significant by any means. */
-
-FcBool
-FcSharedStrFree (FcChar8 *name)
-{
-  free (name);
-  return FcTrue;
-}
-
-const FcChar8 *
-FcSharedStr (const FcChar8 *name)
-{
-  return strdup ((const char *) name);
-}
-
 FcBool
 FcPatternSerializeAlloc (FcSerialize *serialize, const FcPattern *pat)
 {
diff --git a/src/fcstr.c b/src/fcstr.c
index f278022..34093a0 100644
--- a/src/fcstr.c
+++ b/src/fcstr.c
@@ -38,16 +38,7 @@
 FcChar8 *
 FcStrCopy (const FcChar8 *s)
 {
-    int     len;
-    FcChar8 *r;
-    if (!s)
-	return 0;
-    len = strlen ((char *) s) + 1;
-    r = (FcChar8 *) malloc (len);
-    if (!r)
-	return 0;
-    memcpy (r, s, len);
-    return r;
+    return FcStrdup (s);
 }
 
 FcChar8 *
diff --git a/src/fcxml.c b/src/fcxml.c
index 1963cba..1f068ce 100644
--- a/src/fcxml.c
+++ b/src/fcxml.c
@@ -99,7 +99,7 @@ FcExprCreateString (FcConfig *config, const FcChar8 *s)
     if (e)
     {
 	e->op = FcOpString;
-	e->u.sval = FcSharedStr (s);
+	e->u.sval = FcStrdup (s);
     }
     return e;
 }
@@ -205,7 +205,7 @@ FcExprCreateConst (FcConfig *config, const FcChar8 *constant)
     if (e)
     {
 	e->op = FcOpConst;
-	e->u.constant = FcSharedStr (constant);
+	e->u.constant = FcStrdup (constant);
     }
     return e;
 }
@@ -234,7 +234,7 @@ FcExprDestroy (FcExpr *e)
     case FcOpDouble:
 	break;
     case FcOpString:
-	FcSharedStrFree (e->u.sval);
+	FcFree (e->u.sval);
 	break;
     case FcOpMatrix:
 	FcExprMatrixFree (e->u.mexpr);
@@ -252,7 +252,7 @@ FcExprDestroy (FcExpr *e)
     case FcOpField:
 	break;
     case FcOpConst:
-	FcSharedStrFree (e->u.constant);
+	FcFree (e->u.constant);
 	break;
     case FcOpAssign:
     case FcOpAssignReplace:
@@ -2478,7 +2478,7 @@ FcPopValue (FcConfigParse *parse)
 
     switch ((int) vstack->tag) {
     case FcVStackString:
-	value.u.s = FcSharedStr (vstack->u.string);
+	value.u.s = FcStrdup (vstack->u.string);
 	if (value.u.s)
 	    value.type = FcTypeString;
 	break;


More information about the Fontconfig mailing list