summaryrefslogtreecommitdiffstats
path: root/src/rcclocale.c
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@dside.dyndns.org>2005-07-04 04:14:58 +0000
committerSuren A. Chilingaryan <csa@dside.dyndns.org>2005-07-04 04:14:58 +0000
commita21deef1c62467b21500f94dfb2ab3d58e69cb85 (patch)
tree742d2c1e2592fbcb580ebce9fac7f4f867e6218b /src/rcclocale.c
parent97e76f4c979d7a0c4ed296c512c3024e3c6afa18 (diff)
downloadlibrcc-a21deef1c62467b21500f94dfb2ab3d58e69cb85.tar.gz
librcc-a21deef1c62467b21500f94dfb2ab3d58e69cb85.tar.bz2
librcc-a21deef1c62467b21500f94dfb2ab3d58e69cb85.tar.xz
librcc-a21deef1c62467b21500f94dfb2ab3d58e69cb85.zip
04.07.2005
Diffstat (limited to 'src/rcclocale.c')
-rw-r--r--src/rcclocale.c34
1 files changed, 28 insertions, 6 deletions
diff --git a/src/rcclocale.c b/src/rcclocale.c
index d2ff610..d3efaa6 100644
--- a/src/rcclocale.c
+++ b/src/rcclocale.c
@@ -1,7 +1,12 @@
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <locale.h>
+#ifdef HAVE_CODESET
+# include <langinfo.h>
+#endif
+
#include "rccconfig.h"
static int rccLocaleGetClassByName(const char *locale) {
@@ -22,25 +27,27 @@ static int rccLocaleGetClassByName(const char *locale) {
return -1;
}
-static int rccLocaleGetLanguage(char *result, const char *lv, unsigned int n) {
- unsigned int i;
+int rccLocaleGetLanguage(char *result, const char *lv, unsigned int n) {
+ unsigned int i, j;
int locale_class;
const char *l;
+ printf("Locale: %p\n", lv);
if (!lv) return -1;
locale_class = rccLocaleGetClassByName(lv);
if (locale_class >= 0) {
l = setlocale(locale_class, NULL);
+ puts(l);
if (!l) return -1;
else if ((strcmp(l,"C")==0)||(strcmp(l,"POSIX")==0)) return -1;
- } return -1;
+ } else return -1;
for (i=0;((l[i])&&(l[i]!='.'));i++);
- for (i=0;rcc_default_aliases[i].alias;i++)
- if (strncmp(l,rcc_default_aliases[i].alias,i)==0) {
- l = rcc_default_aliases[i].alias;
+ for (j=0;rcc_default_aliases[j].alias;j++)
+ if (strncmp(l,rcc_default_aliases[j].alias,i)==0) {
+ l = rcc_default_aliases[j].alias;
break;
}
@@ -49,6 +56,8 @@ static int rccLocaleGetLanguage(char *result, const char *lv, unsigned int n) {
strncpy(result,l,i);
result[i]=0;
+ puts("------------------->");
+ puts(result);
return 0;
}
@@ -61,6 +70,19 @@ int rccLocaleGetCharset(char *result, const char *lv, unsigned int n) {
if (!lv) return -1;
locale_class = rccLocaleGetClassByName(lv);
+
+ if (locale_class == LC_CTYPE) {
+ l = getenv("CHARSET");
+#ifdef HAVE_CODESET
+ if (!l) l = nl_langinfo(CODESET);
+#endif
+ if (l) {
+ if (strlen(l)>=n) return -1;
+ strcpy(result, l);
+ return 0;
+ }
+ }
+
if (locale_class >= 0) {
l = setlocale(locale_class, NULL);
if (!l) return -1;