aboutsummaryrefslogtreecommitdiff
path: root/fontconfig/src/fcdefault.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-06-11 08:22:24 +0200
committermarha <marha@users.sourceforge.net>2012-06-11 08:22:24 +0200
commit080d1527a5358dd66ac927acbe0ec61cba7aa7e1 (patch)
tree6d54a6409a4627162bddaad63186327e1ecdbad1 /fontconfig/src/fcdefault.c
parent990bc3f015a4f8fce2eb918375defcd44980a845 (diff)
downloadvcxsrv-080d1527a5358dd66ac927acbe0ec61cba7aa7e1.tar.gz
vcxsrv-080d1527a5358dd66ac927acbe0ec61cba7aa7e1.tar.bz2
vcxsrv-080d1527a5358dd66ac927acbe0ec61cba7aa7e1.zip
fontconfig glproto mesa pixman git update 11 Jun 2012
Diffstat (limited to 'fontconfig/src/fcdefault.c')
-rw-r--r--fontconfig/src/fcdefault.c106
1 files changed, 33 insertions, 73 deletions
diff --git a/fontconfig/src/fcdefault.c b/fontconfig/src/fcdefault.c
index 170a8a4d8..c6b5669ed 100644
--- a/fontconfig/src/fcdefault.c
+++ b/fontconfig/src/fcdefault.c
@@ -23,7 +23,7 @@
*/
#include "fcint.h"
-#include <locale.h>
+#include <string.h>
static const struct {
FcObject field;
@@ -39,81 +39,45 @@ static const struct {
#define NUM_FC_BOOL_DEFAULTS (int) (sizeof FcBoolDefaults / sizeof FcBoolDefaults[0])
-FcChar8 *
-FcGetDefaultLang (void)
+FcStrSet *
+FcGetDefaultLangs (void)
{
- static char lang_local [128] = {0};
- char *ctype;
- char *territory;
- char *after;
- int lang_len, territory_len;
-
- if (lang_local [0])
- return (FcChar8 *) lang_local;
-
- ctype = setlocale (LC_CTYPE, NULL);
-
- /*
- * Check if setlocale (LC_ALL, "") has been called
- */
- if (!ctype || !strcmp (ctype, "C"))
+ FcStrSet *result = FcStrSetCreate ();
+ char *langs;
+
+ langs = getenv ("FC_LANG");
+ if (!langs || !langs[0])
+ langs = getenv ("LC_ALL");
+ if (!langs || !langs[0])
+ langs = getenv ("LC_CTYPE");
+ if (!langs || !langs[0])
+ langs = getenv ("LANG");
+ if (langs && langs[0])
{
- ctype = getenv ("LC_ALL");
- if (!ctype)
- {
- ctype = getenv ("LC_CTYPE");
- if (!ctype)
- ctype = getenv ("LANG");
- }
+ if (!FcStrSetAddLangs (result, langs))
+ FcStrSetAdd (result, (const FcChar8 *) "en");
}
+ else
+ FcStrSetAdd (result, (const FcChar8 *) "en");
- /* ignore missing or empty ctype */
- if (ctype && *ctype != '\0')
+ return result;
+}
+
+FcChar8 *
+FcGetDefaultLang (void)
+{
+ static FcChar8 lang_local[128] = {0};
+ FcStrSet *langs;
+
+ if (!lang_local[0])
{
- territory = strchr (ctype, '_');
- if (territory)
- {
- lang_len = territory - ctype;
- territory = territory + 1;
- after = strchr (territory, '.');
- if (!after)
- {
- after = strchr (territory, '@');
- if (!after)
- after = territory + strlen (territory);
- }
- territory_len = after - territory;
- if (lang_len + 1 + territory_len + 1 <= (int) sizeof (lang_local))
- {
- strncpy (lang_local, ctype, lang_len);
- lang_local[lang_len] = '-';
- strncpy (lang_local + lang_len + 1, territory, territory_len);
- 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';
- }
- }
+ langs = FcGetDefaultLangs ();
+ strncpy ((char *)lang_local, (const char *)langs->strs[0], 127);
+ lang_local[127] = 0;
+ FcStrSetDestroy (langs);
}
- /* set default lang to en */
- if (!lang_local [0])
- strcpy (lang_local, "en");
-
- return (FcChar8 *) lang_local;
+ return lang_local;
}
void
@@ -162,10 +126,6 @@ FcDefaultSubstitute (FcPattern *pattern)
FcPatternObjectAddDouble (pattern, FC_PIXEL_SIZE_OBJECT, size);
}
- if (FcPatternObjectGet (pattern, FC_LANG_OBJECT, 0, &v) == FcResultNoMatch)
- {
- FcPatternObjectAddString (pattern, FC_LANG_OBJECT, FcGetDefaultLang ());
- }
if (FcPatternObjectGet (pattern, FC_FONTVERSION_OBJECT, 0, &v) == FcResultNoMatch)
{
FcPatternObjectAddInteger (pattern, FC_FONTVERSION_OBJECT, 0x7fffffff);