summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@dside.dyndns.org>2005-07-12 15:56:03 +0000
committerSuren A. Chilingaryan <csa@dside.dyndns.org>2005-07-12 15:56:03 +0000
commitfad788d3f02564486039886b1de1cbf976776ac3 (patch)
treefc81add05e45e6de4e2e656fb0f08ed6e292dcf6 /src
parente598a2372179812389a702b78d5f8537eb6827d9 (diff)
downloadlibrcc-fad788d3f02564486039886b1de1cbf976776ac3.tar.gz
librcc-fad788d3f02564486039886b1de1cbf976776ac3.tar.bz2
librcc-fad788d3f02564486039886b1de1cbf976776ac3.tar.xz
librcc-fad788d3f02564486039886b1de1cbf976776ac3.zip
Language/Charset autodetection fixes
Diffstat (limited to 'src')
-rw-r--r--src/fs.c2
-rw-r--r--src/internal.h2
-rw-r--r--src/librcc.c1
-rw-r--r--src/lng.c21
-rw-r--r--src/lngconfig.c34
-rw-r--r--src/lngconfig.h3
-rw-r--r--src/rccconfig.c4
-rw-r--r--src/rccxml.c2
8 files changed, 56 insertions, 13 deletions
diff --git a/src/fs.c b/src/fs.c
index 2906850..1f61a9e 100644
--- a/src/fs.c
+++ b/src/fs.c
@@ -152,7 +152,6 @@ int rccFS1(rcc_context ctx, const char *fspath, char **prefix, char **name) {
}
}
- puts("--");
if (rccFS0(ctx, fspath, result, prefix, name)) {
*prefix = NULL;
*name = result;
@@ -160,7 +159,6 @@ int rccFS1(rcc_context ctx, const char *fspath, char **prefix, char **name) {
if ((path)&&(filename)) return 0;
return 2;
}
- puts("++");
if ((path)&&(filename)) free(result);
diff --git a/src/internal.h b/src/internal.h
index 8a99ca0..258e6b0 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -44,6 +44,8 @@ struct rcc_context_t {
unsigned char configure;
rcc_language_config current_config;
rcc_language_id current_language;
+
+ rcc_language_id default_language;
db4_context db4ctx;
diff --git a/src/librcc.c b/src/librcc.c
index 2e2a49e..34e0e3d 100644
--- a/src/librcc.c
+++ b/src/librcc.c
@@ -164,6 +164,7 @@ rcc_context rccCreateContext(const char *locale_variable, unsigned int max_langu
}
ctx->current_language = 0;
+ ctx->default_language = 0;
if (locale_variable) {
if (strlen(locale_variable)>=RCC_MAX_VARIABLE_CHARS) {
diff --git a/src/lng.c b/src/lng.c
index e6b5a73..8625fb8 100644
--- a/src/lng.c
+++ b/src/lng.c
@@ -39,14 +39,31 @@ rcc_language_id rccGetLanguageByName(rcc_context ctx, const char *name) {
static rcc_language_id rccGetDefaultLanguage(rcc_context ctx) {
int err;
unsigned int i;
+ rcc_option_value clo;
+ rcc_engine_ptr *engines;
+ rcc_language_config config;
char stmp[RCC_MAX_LANGUAGE_CHARS+1];
+ printf("DL: %lu\n", ctx->default_language);
+ if (ctx->default_language) return ctx->default_language;
+
if (!rccLocaleGetLanguage(stmp, ctx->locale_variable, RCC_MAX_LANGUAGE_CHARS)) {
for (i=0;ctx->languages[i];i++) {
if (!strcmp(ctx->languages[i]->sn, stmp)) {
- if (rccGetOption(ctx, RCC_CONFIGURED_LANGUAGES_ONLY)) {
- if (!rccCheckConfig(ctx, (rcc_language_id)i)) break;
+ clo = rccGetOption(ctx, RCC_CONFIGURED_LANGUAGES_ONLY);
+ printf("CLO: %lu\n", clo);
+ if (clo) {
+ config = rccCheckConfig(ctx, (rcc_language_id)i);
+ if ((!config)||(!config->configured)) {
+ if (clo == 1) {
+ engines = ctx->languages[i]->engines;
+ printf("%p",engines[0]);
+ printf("%p",engines[1]);
+ if ((!engines[0])||(!engines[1])) break;
+ } else break;
+ }
}
+ ctx->default_language = (rcc_language_id)i;
return (rcc_language_id)i;
}
}
diff --git a/src/lngconfig.c b/src/lngconfig.c
index 4ac16c1..eded9da 100644
--- a/src/lngconfig.c
+++ b/src/lngconfig.c
@@ -157,6 +157,8 @@ int rccConfigInit(rcc_language_config config, rcc_context ctx) {
config->language = NULL;
config->charset = charsets;
config->engine = -1;
+ config->default_charset = 0;
+ config->configured = 0;
return 0;
}
@@ -308,12 +310,20 @@ rcc_charset_id rccConfigGetCurrentCharset(rcc_language_config config, rcc_class_
}
} else defvalue = config->ctx->locale_variable;
+ if (config->default_charset) return config->default_charset;
+
charset_id = rccConfigGetLocaleCharset(config, defvalue);
- if ((charset_id != 0)&&(charset_id != (rcc_charset_id)-1)) return charset_id;
+ if ((charset_id != 0)&&(charset_id != (rcc_charset_id)-1)) {
+ config->default_charset = charset_id;
+ return charset_id;
+ }
if (cl->defvalue) {
charset_id = rccConfigGetCharsetByName(config, defvalue);
- if ((charset_id != 0)&&(charset_id != (rcc_charset_id)-1)) return charset_id;
+ if ((charset_id != 0)&&(charset_id != (rcc_charset_id)-1)) {
+ config->default_charset = charset_id;
+ return charset_id;
+ }
}
defcharset = cl->defcharset;
@@ -321,13 +331,21 @@ rcc_charset_id rccConfigGetCurrentCharset(rcc_language_config config, rcc_class_
lang = config->language->sn;
for (i = 0; cl->defcharset[i].lang; i++) {
- if (!strcasecmp(lang, defcharset[i].lang))
- return rccConfigGetCharsetByName(config, defcharset[i].charset);
+ if (!strcasecmp(lang, defcharset[i].lang)) {
+ charset_id = rccConfigGetCharsetByName(config, defcharset[i].charset);
+ if ((charset_id != 0)&&(charset_id != (rcc_charset_id)-1)) {
+ config->default_charset = charset_id;
+ return charset_id;
+ } else break;
+ }
}
}
charsets=language->charsets;
- if ((charsets[0])&&(charsets[1])) return (rcc_charset_id)1;
+ if ((charsets[0])&&(charsets[1])) {
+ config->default_charset=(rcc_charset_id)1;
+ return (rcc_charset_id)1;
+ }
return (rcc_charset_id)-1;
}
@@ -346,6 +364,8 @@ int rccConfigSetEngine(rcc_language_config config, rcc_engine_id engine_id) {
if ((!config)||(!config->language)||(engine_id < -1)) return -1;
+ config->configured = 1;
+
if (engine_id != (rcc_engine_id)-1) {
for (i=0;config->language->engines[i];i++);
if (engine_id >= i) return -1;
@@ -362,7 +382,7 @@ int rccConfigSetEngineByName(rcc_language_config config, const char *name) {
rcc_engine_id engine_id;
if (!config) return -1;
-
+
if ((!name)||(!strcasecmp(name,rcc_engine_nonconfigured)))
return rccConfigSetEngine(config, (rcc_engine_id)-1);
@@ -377,6 +397,8 @@ int rccConfigSetCharset(rcc_language_config config, rcc_class_id class_id, rcc_c
if ((!config)||(!config->language)||(class_id < 0)||(class_id >= config->ctx->n_classes)||(charset_id<0)) return -1;
+ config->configured = 1;
+
for (i=0;config->language->charsets[i];i++);
if (charset_id >= i) return -1;
diff --git a/src/lngconfig.h b/src/lngconfig.h
index 64ca523..d583ab6 100644
--- a/src/lngconfig.h
+++ b/src/lngconfig.h
@@ -8,6 +8,9 @@ struct rcc_language_config_t {
rcc_engine_id engine;
rcc_charset_id *charset;
+
+ rcc_charset_id default_charset;
+ unsigned char configured;
};
typedef struct rcc_language_config_t rcc_language_config_s;
diff --git a/src/rccconfig.c b/src/rccconfig.c
index 100a7fc..e2a0740 100644
--- a/src/rccconfig.c
+++ b/src/rccconfig.c
@@ -101,10 +101,10 @@ rcc_option_value_name rcc_sn_learning[] = { "OFF", "ON", "RELEARN", "LEARN", NUL
rcc_option_value_name rcc_sn_clo[] = { "ALL", "CONFIGURED_AND_AUTO", "CONFIGURED_ONLY", NULL };
rcc_option_description rcc_option_descriptions[] = {
- {RCC_LEARNING_MODE, 0, { RCC_OPTION_RANGE_TYPE_MENU, 0, 3, 1 }, RCC_OPTION_TYPE_STANDARD, "LEARNING_MODE", rcc_sn_learning },
+ {RCC_LEARNING_MODE, 1, { RCC_OPTION_RANGE_TYPE_MENU, 0, 3, 1 }, RCC_OPTION_TYPE_STANDARD, "LEARNING_MODE", rcc_sn_learning },
{RCC_AUTODETECT_FS_NAMES, 1, { RCC_OPTION_RANGE_TYPE_BOOLEAN, 0, 0, 0}, RCC_OPTION_TYPE_STANDARD, "AUTODETECT_FS_NAMES", rcc_sn_boolean},
{RCC_AUTODETECT_FS_TITLES, 1, { RCC_OPTION_RANGE_TYPE_BOOLEAN, 0, 0, 0}, RCC_OPTION_TYPE_INVISIBLE, "AUTODETECT_FS_TITLES", rcc_sn_boolean},
- {RCC_CONFIGURED_LANGUAGES_ONLY, 0, { RCC_OPTION_RANGE_TYPE_MENU, 0, 2, 1}, RCC_OPTION_TYPE_INVISIBLE, "CONFIGURED_LANGUAGES_ONLY", rcc_sn_clo},
+ {RCC_CONFIGURED_LANGUAGES_ONLY, 1, { RCC_OPTION_RANGE_TYPE_MENU, 0, 2, 1}, RCC_OPTION_TYPE_INVISIBLE, "CONFIGURED_LANGUAGES_ONLY", rcc_sn_clo},
{RCC_MAX_OPTIONS}
};
diff --git a/src/rccxml.c b/src/rccxml.c
index 7fc9430..bbeff42 100644
--- a/src/rccxml.c
+++ b/src/rccxml.c
@@ -294,7 +294,7 @@ int rccSave(rcc_context ctx, const char *name) {
for (i=1;languages[i];i++) {
language = languages[i];
cfg = rccCheckConfig(ctx, (rcc_language_id)i);
- if (!cfg) continue;
+ if ((!cfg)||(!cfg->configured)) continue;
if (llflag) lnode = rccNodeFind(xpathctx, XPATH_SELECTED_LANG, language->sn);
else lnode = NULL;