]> git.wh0rd.org - fontconfig.git/blobdiff - src/fcxml.c
Add nynorsk and bokml, remove double angle quotes from other languages
[fontconfig.git] / src / fcxml.c
index 09aa79ebaaed79f86984720bafdbe3a2858e5fa3..c769ddd958106c970a78cbcda607b40b8d4b46a7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $XFree86: xc/lib/fontconfig/src/fcxml.c,v 1.8 2002/05/22 04:12:35 keithp Exp $
+ * $XFree86: xc/lib/fontconfig/src/fcxml.c,v 1.14 2002/06/21 07:01:11 keithp Exp $
  *
  * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
  *
 #include <stdarg.h>
 #include "fcint.h"
 
+#ifndef HAVE_EXPAT
+#define HAVE_EXPAT 1
+#endif
+
+#ifndef HAVE_XML2
+#define HAVE_XML2 0
+#endif
+
 #if HAVE_EXPAT
+#ifndef HAVE_XMLPARSE_H
+#define HAVE_XMLPARSE_H 0
+#endif
 #if HAVE_XMLPARSE_H
 #include <xmlparse.h>
 #else
@@ -868,6 +879,61 @@ FcParseInt (FcConfigParse *parse)
     FcStrFree (s);
 }
 
+/*
+ * idea copied from glib g_ascii_strtod with 
+ * permission of the author (Alexander Larsson) 
+ */
+
+#include <locale.h>
+
+static double 
+FcStrtod (char *s, char **end)
+{
+    struct lconv    *locale_data;
+    char           *dot;
+    double         v;
+
+    /*
+     * Have to swap the decimal point to match the current locale
+     * if that locale doesn't use 0x2e
+     */
+    if ((dot = strchr (s, 0x2e)) &&
+       (locale_data = localeconv ()) &&
+       (locale_data->decimal_point[0] != 0x2e ||
+        locale_data->decimal_point[1] != 0))
+    {
+       char    buf[128];
+       int     slen = strlen (s);
+       int     dlen = strlen (locale_data->decimal_point);
+       
+       if (slen + dlen > sizeof (buf))
+       {
+           if (end)
+               *end = s;
+           v = 0;
+       }
+       else
+       {
+           char        *buf_end;
+           /* mantissa */
+           strncpy (buf, s, dot - s);
+           /* decimal point */
+           strcpy (buf + (dot - s), locale_data->decimal_point);
+           /* rest of number */
+           strcpy (buf + (dot - s) + dlen, dot + 1);
+           buf_end = 0;
+           v = strtod (buf, &buf_end);
+           if (buf_end)
+               buf_end = s + (buf_end - buf);
+           if (end)
+               *end = buf_end;
+       }
+    }
+    else
+       v = strtod (s, end);
+    return v;
+}
+
 static void
 FcParseDouble (FcConfigParse *parse)
 {
@@ -883,7 +949,7 @@ FcParseDouble (FcConfigParse *parse)
        return;
     }
     end = 0;
-    d = strtod ((char *) s, (char **)&end);
+    d = FcStrtod ((char *) s, (char **)&end);
     if (end != s + strlen ((char *) s))
        FcConfigMessage (parse, FcSevereError, "\"%s\": not a valid double", s);
     else
@@ -1135,7 +1201,7 @@ FcParseAlias (FcConfigParse *parse)
     if (edit)
     {
        test = FcTestCreate (FcQualAny,
-                            FcStrCopy ((FcChar8 *) "family"),
+                            (FcChar8 *) FC_FAMILY,
                             FcOpEqual,
                             family);
        if (test)
@@ -1305,6 +1371,10 @@ FcParseTest (FcConfigParse *parse)
            qual = FcQualAny;
        else if (!strcmp ((char *) qual_string, "all"))
            qual = FcQualAll;
+       else if (!strcmp ((char *) qual_string, "first"))
+           qual = FcQualFirst;
+       else if (!strcmp ((char *) qual_string, "not_first"))
+           qual = FcQualNotFirst;
        else
        {
            FcConfigMessage (parse, FcSevereWarning, "invalid test qual \"%s\"", qual_string);
@@ -1640,6 +1710,10 @@ FcConfigParseAndLoad (FcConfig       *config,
     filename = FcConfigFilename (name);
     if (!filename)
        goto bail0;
+    
+    if (!FcStrSetAdd (config->configFiles, filename))
+       goto bail0;
+
     f = fopen ((char *) filename, "r");
     free (filename);
     if (!f)