]> git.wh0rd.org - fontconfig.git/blobdiff - fc-lang/fc-lang.c
[fc-lang] Fix bug in country map generation
[fontconfig.git] / fc-lang / fc-lang.c
index 92a62ce631b27c447750b4896766a647529f917e..b0f1690e880533fc1823989148f2e9d3a0b1e500 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $RCSId: xc/lib/fontconfig/fc-lang/fc-lang.c,v 1.3 2002/08/22 07:36:43 keithp Exp $
+ * fontconfig/fc-lang/fc-lang.c
  *
  * Copyright © 2002 Keith Packard
  *
@@ -13,9 +13,9 @@
  * representations about the suitability of this software for any purpose.  It
  * is provided "as is" without express or implied warranty.
  *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * 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
@@ -138,18 +138,25 @@ scan (FILE *f, char *file, FcCharSetFreezer *freezer)
     {
        if (!strncmp (line, "include", 7))
        {
-           file = strchr (line, ' ');
-            if (!file)
-                fatal (line, lineno, 
+           FILE *included_f;
+           char *included_file;
+           included_file = strchr (line, ' ');
+            if (!included_file)
+                fatal (file, lineno,
                        "invalid syntax, expected: include filename");
-           while (isspace(*file))
-               file++;
-           f = scanopen (file);
-           if (!f)
-               fatal (file, 0, "can't open");
-           n = scan (f, file, freezer);
-           fclose (f);
-           return n;
+           while (isspace(*included_file))
+               included_file++;
+           included_f = scanopen (included_file);
+           if (!included_f)
+               fatal (included_file, 0, "can't open");
+           n = scan (included_f, included_file, freezer);
+           fclose (included_f);
+           if (!c)
+               c = FcCharSetCreate ();
+           if (!FcCharSetMerge (c, n, NULL))
+               fatal (file, lineno, "out of memory");
+           FcCharSetDestroy (n);
+           continue;
        }
        if (strchr (line, '-'))
        {
@@ -377,7 +384,7 @@ main (int argc, char **argv)
        if (j < 0)
            j = i;
 
-       printf ("    { (FcChar8 *) \"%s\", "
+       printf ("    { \"%s\", "
                " { FC_REF_CONSTANT, %d, OFF(%d,%d), NUM(%d,%d) } }, /* %d */\n",
                langs[i],
                sets[j]->num, i, off[j], i, off[j], i);
@@ -481,7 +488,7 @@ main (int argc, char **argv)
                for (d = c + 1; d < ncountry; d++)
                {
                    int j = country[d];
-                   if (j >= 0 && !strncmp (langs[j], langs[i], l))
+                   if (j >= 0 && !strncmp (langs[j], langs[i], lang + 1))
                    {
                        BitSet(map, j);
                        country[d] = -1;