]> git.wh0rd.org - fontconfig.git/commitdiff
Accept locale environment variables that do not contain territory.
authorKeith Packard <keithp@neko.keithp.com>
Sat, 9 Sep 2006 17:04:42 +0000 (10:04 -0700)
committerKeith Packard <keithp@neko.keithp.com>
Sat, 9 Sep 2006 17:04:42 +0000 (10:04 -0700)
Locale environment variables (LC_ALL, LC_CTYPE, LANG) must contain language,
and may contain territory and encoding. Don't accidentally require territory
as that will cause fontconfig to fall back to 'en'.

src/fcdefault.c

index ddf4237e1bbfe6b4c0101eeda1e9c7a8690d3727..4e5823bb13406762b5c9fc3e2e5a2bf8a5fd6405 100644 (file)
@@ -91,6 +91,22 @@ FcGetDefaultLang (void)
                lang_local[lang_len + 1 + territory_len] = '\0';
            }
        }
+       else
+       {
+           after = strchr (ctype, '.');
+           if (!after)
+           {
+               after = strchr (ctype, '@');
+               if (!after)
+                   after = ctype + strlen (ctype);
+           }
+           lang_len = after - ctype;
+           if (lang_len + 1 <= (int) sizeof (lang_local))
+           {
+               strncpy (lang_local, ctype, lang_len);
+               lang_local[lang_len] = '\0';
+           }
+       }
     }
 
     /* set default lang to en */