summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/engine.c10
-rw-r--r--src/librcc.c39
-rw-r--r--src/lng.c2
-rw-r--r--src/lngconfig.c15
-rw-r--r--src/rcciconv.c4
-rw-r--r--src/rcclist.c2
-rw-r--r--src/rcclocale.c4
-rw-r--r--src/rccstring.c2
-rw-r--r--src/rccxml.c3
-rw-r--r--src/recode.c6
-rw-r--r--ui/gtk.c4
11 files changed, 43 insertions, 48 deletions
diff --git a/src/engine.c b/src/engine.c
index 219a098..5f7a3ff 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -14,7 +14,7 @@ int rccEngineInit(rcc_engine_context engine_ctx, rcc_context ctx) {
void rccEngineFree(rcc_engine_context engine_ctx) {
if (!engine_ctx) return;
-
+
if (engine_ctx->free_func) {
engine_ctx->free_func(engine_ctx);
engine_ctx->free_func = NULL;
@@ -34,10 +34,10 @@ int rccEngineConfigure(rcc_engine_context ctx) {
rccEngineFree(ctx);
language_id = rccGetCurrentLanguage(ctx->ctx);
- if (language_id<0) return -1;
+ if (language_id == (rcc_language_id)-1) return -1;
engine_id = rccGetCurrentEngine(ctx->ctx);
- if (engine_id<0) return -1;
+ if (engine_id == (rcc_engine_id)-1) return -1;
engine = ctx->ctx->languages[language_id]->engines[engine_id];
@@ -45,7 +45,9 @@ int rccEngineConfigure(rcc_engine_context ctx) {
ctx->func = engine->func;
ctx->language = ctx->ctx->languages[language_id];
- ctx->internal = engine->init_func(ctx);
+ if (engine->init_func) ctx->internal = engine->init_func(ctx);
+ else ctx->internal = NULL;
+
return 0;
}
diff --git a/src/librcc.c b/src/librcc.c
index 5b6a66f..5a68b5f 100644
--- a/src/librcc.c
+++ b/src/librcc.c
@@ -254,23 +254,23 @@ void rccFreeContext(rcc_context ctx) {
int rccLockConfiguration(rcc_context ctx, unsigned int lock_code) {
if (!ctx) return -1;
- if (ctx->configuration_lock) return -3;
+ if (ctx->configuration_lock) return -1;
ctx->configuration_lock = lock_code;
return 0;
}
int rccUnlockConfiguration(rcc_context ctx, unsigned int lock_code) {
if (!ctx) return -1;
- if (ctx->configuration_lock != lock_code) return -3;
+ if (ctx->configuration_lock != lock_code) return -1;
ctx->configuration_lock = 0;
return 0;
}
rcc_language_id rccRegisterLanguage(rcc_context ctx, rcc_language *language) {
- if ((!ctx)||(!language)) return -1;
- if (ctx->configuration_lock) return -3;
+ if ((!ctx)||(!language)) return (rcc_language_id)-1;
+ if (ctx->configuration_lock) return (rcc_language_id)-1;
- if (ctx->n_languages == ctx->max_languages) return -2;
+ if (ctx->n_languages == ctx->max_languages) return (rcc_language_id)-1;
ctx->languages[ctx->n_languages++] = language;
ctx->languages[ctx->n_languages] = NULL;
@@ -283,9 +283,9 @@ rcc_language_id rccRegisterLanguage(rcc_context ctx, rcc_language *language) {
rcc_charset_id rccLanguageRegisterCharset(rcc_language *language, rcc_charset charset) {
unsigned int i;
- if ((!language)||(!charset)) return -1;
+ if ((!language)||(!charset)) return (rcc_charset_id)-1;
for (i=0;language->charsets[i];i++);
- if (i>=RCC_MAX_CHARSETS) return -2;
+ if (i>=RCC_MAX_CHARSETS) return (rcc_charset_id)-1;
language->charsets[i++] = charset;
language->charsets[i] = NULL;
return i-1;
@@ -294,9 +294,9 @@ rcc_charset_id rccLanguageRegisterCharset(rcc_language *language, rcc_charset ch
rcc_engine_id rccLanguageRegisterEngine(rcc_language *language, rcc_engine *engine) {
unsigned int i;
- if ((!language)||(!engine)) return -1;
+ if ((!language)||(!engine)) return (rcc_engine_id)-1;
for (i=0;language->engines[i];i++);
- if (i>=RCC_MAX_ENGINES) return -2;
+ if (i>=RCC_MAX_ENGINES) return (rcc_engine_id)-1;
language->engines[i++] = engine;
language->engines[i] = NULL;
return i-1;
@@ -305,10 +305,10 @@ rcc_engine_id rccLanguageRegisterEngine(rcc_language *language, rcc_engine *engi
rcc_alias_id rccRegisterLanguageAlias(rcc_context ctx, rcc_language_alias *alias) {
unsigned int i;
- if ((!ctx)||(!alias)) return -1;
+ if ((!ctx)||(!alias)) return (rcc_alias_id)-1;
for (i=0;ctx->aliases[i];i++)
- if (i>=RCC_MAX_ALIASES) return -2;
+ if (i>=RCC_MAX_ALIASES) return (rcc_alias_id)-1;
ctx->aliases[i++] = alias;
ctx->aliases[i] = NULL;
@@ -317,9 +317,9 @@ rcc_alias_id rccRegisterLanguageAlias(rcc_context ctx, rcc_language_alias *alias
}
rcc_class_id rccRegisterClass(rcc_context ctx, rcc_class *cl) {
- if ((!ctx)||(!cl)) return -1;
- if (ctx->configuration_lock) return -3;
- if (ctx->n_classes == ctx->max_classes) return -2;
+ if ((!ctx)||(!cl)) return (rcc_class_id)-1;
+ if (ctx->configuration_lock) return (rcc_class_id)-1;
+ if (ctx->n_classes == ctx->max_classes) return (rcc_class_id)-1;
ctx->configure = 1;
ctx->classes[ctx->n_classes++] = cl;
@@ -336,6 +336,7 @@ rcc_class_type rccGetClassType(rcc_context ctx, rcc_class_id class_id) {
int rccConfigure(rcc_context ctx) {
+ int err;
unsigned int i;
rcc_charset *charsets;
const char *charset;
@@ -343,9 +344,11 @@ int rccConfigure(rcc_context ctx) {
if (!ctx) return -1;
if (!ctx->configure) return 0;
+ rccGetCurrentCharsetName(ctx, (rcc_class_id)0);
rccFreeIConv(ctx);
for (i=0;i<ctx->n_classes;i++) {
- charset = rccGetCurrentCharsetName(ctx, i);
+ charset = rccGetCurrentCharsetName(ctx, (rcc_class_id)i);
+ printf("Configure %i: %s\n", i, charset);
if (strcmp(charset, "UTF-8")&&strcmp(charset, "UTF8")) {
ctx->iconv_from[i] = iconv_open("UTF-8", charset);
ctx->iconv_to[i] = iconv_open(charset, "UTF-8");
@@ -354,7 +357,7 @@ int rccConfigure(rcc_context ctx) {
ctx->iconv_to[i] = (iconv_t)-2;
}
}
-
+
charsets = rccGetCurrentAutoCharsetList(ctx);
for (i=0;charsets[i];i++) {
charset = charsets[i];
@@ -364,8 +367,10 @@ int rccConfigure(rcc_context ctx) {
ctx->iconv_auto[i] = (iconv_t)-2;
}
- rccEngineConfigure(&ctx->engine_ctx);
+ err = rccEngineConfigure(&ctx->engine_ctx);
+ if (err) return err;
+ ctx->configure = 0;
return 0;
}
diff --git a/src/lng.c b/src/lng.c
index 3937cd7..a365615 100644
--- a/src/lng.c
+++ b/src/lng.c
@@ -48,7 +48,6 @@ static rcc_language_id rccGetDefaultLanguage(rcc_context ctx) {
}
rcc_language_id rccGetRealLanguage(rcc_context ctx, rcc_language_id language_id) {
- printf("CRL: %i\n", language_id);
if ((!ctx)||(language_id<0)||(language_id>=ctx->n_languages)) return -1;
if (language_id) return language_id;
return rccGetDefaultLanguage(ctx);
@@ -77,7 +76,6 @@ const char *rccGetSelectedLanguageName(rcc_context ctx) {
rcc_language_id rccGetCurrentLanguage(rcc_context ctx) {
if (!ctx) return -1;
- printf("CL: %i\n", ctx->current_language);
return rccGetRealLanguage(ctx, ctx->current_language);
}
diff --git a/src/lngconfig.c b/src/lngconfig.c
index 67b7e0b..73cf527 100644
--- a/src/lngconfig.c
+++ b/src/lngconfig.c
@@ -66,7 +66,7 @@ rcc_engine_id rccConfigGetEngineByName(rcc_language_config config, const char *n
engines = config->language->engines;
for (i=0;engines[i];i++)
- if (!strcmp(engines[i]->title,name)) return i;
+ if (!strcasecmp(engines[i]->title,name)) return i;
return -1;
}
@@ -79,7 +79,7 @@ rcc_charset_id rccConfigGetCharsetByName(rcc_language_config config, const char
charsets = config->language->charsets;
for (i=0;charsets[i];i++)
- if (!strcmp(charsets[i],name)) return i;
+ if (!strcasecmp(charsets[i],name)) return i;
return 0;
}
@@ -95,7 +95,7 @@ rcc_charset_id rccConfigGetAutoCharsetByName(rcc_language_config config, const c
charsets = engines[config->engine]->charsets;
for (i=0;charsets[i];i++)
- if (!strcmp(charsets[i],name)) return i;
+ if (!strcasecmp(charsets[i],name)) return i;
return -1;
}
@@ -230,7 +230,6 @@ const char *rccConfigGetSelectedCharsetName(rcc_language_config config, rcc_clas
rcc_charset_id rccConfigGetCurrentCharset(rcc_language_config config, rcc_class_id class_id) {
int err;
unsigned int i;
- rcc_language_id language_id;
rcc_charset_id charset_id;
rcc_language *language;
@@ -241,7 +240,7 @@ rcc_charset_id rccConfigGetCurrentCharset(rcc_language_config config, rcc_class_
char stmp[RCC_MAX_CHARSET_CHARS + 1];
const char *defvalue;
-
+
if ((!config)||(!config->ctx)||(class_id<0)||(class_id>=config->ctx->n_classes)) return -1;
charset_id = config->charset[class_id];
@@ -260,11 +259,11 @@ rcc_charset_id rccConfigGetCurrentCharset(rcc_language_config config, rcc_class_
return rccConfigGetCurrentCharset(config, i);
}
} else defvalue = config->ctx->locale_variable;
-
+
charset_id = rccConfigGetLocaleCharset(config, defvalue);
- if (charset_id > 0) return charset_id;
+ if ((charset_id != 0)&&(charset_id != (rcc_charset_id)-1)) return charset_id;
- charsets=config->ctx->languages[language_id]->charsets;
+ charsets=language->charsets;
if ((charsets[0])&&(charsets[1])) return 1;
return -1;
}
diff --git a/src/rcciconv.c b/src/rcciconv.c
index d309a5f..50f827e 100644
--- a/src/rcciconv.c
+++ b/src/rcciconv.c
@@ -67,6 +67,8 @@ loop:
return -1;
}
}
-
+
+ ctx->tmpbuffer[RCC_MAX_STRING_CHARS - out_left] = 0;
+
return RCC_MAX_STRING_CHARS - out_left;
}
diff --git a/src/rcclist.c b/src/rcclist.c
index 522077e..25e6d07 100644
--- a/src/rcclist.c
+++ b/src/rcclist.c
@@ -9,7 +9,6 @@ rcc_language_ptr *rccGetLanguageList(rcc_context ctx) {
rcc_charset *rccGetCharsetList(rcc_context ctx, rcc_language_id language_id) {
if ((!ctx)||(language_id<0)||(language_id>=ctx->n_languages)) return NULL;
if (!language_id) language_id = rccGetCurrentLanguage(ctx);
- printf("=====> LanguageID: %i\n", language_id);
return ctx->languages[language_id]->charsets;
}
@@ -17,7 +16,6 @@ rcc_charset *rccGetCharsetList(rcc_context ctx, rcc_language_id language_id) {
rcc_engine_ptr *rccGetEngineList(rcc_context ctx, rcc_language_id language_id) {
if ((!ctx)||(language_id<0)||(language_id>=ctx->n_languages)) return NULL;
if (!language_id) language_id = rccGetCurrentLanguage(ctx);
- printf("=====> LanguageID: %i\n", language_id);
return ctx->languages[language_id]->engines;
}
diff --git a/src/rcclocale.c b/src/rcclocale.c
index d3efaa6..084efa2 100644
--- a/src/rcclocale.c
+++ b/src/rcclocale.c
@@ -32,13 +32,11 @@ int rccLocaleGetLanguage(char *result, const char *lv, unsigned int n) {
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;
} else return -1;
@@ -56,8 +54,6 @@ int rccLocaleGetLanguage(char *result, const char *lv, unsigned int n) {
strncpy(result,l,i);
result[i]=0;
- puts("------------------->");
- puts(result);
return 0;
}
diff --git a/src/rccstring.c b/src/rccstring.c
index e03a22f..66cb6a9 100644
--- a/src/rccstring.c
+++ b/src/rccstring.c
@@ -14,7 +14,7 @@ rcc_string rccCreateString(rcc_language_id language_id, const char *buf, int len
if (!res) return NULL;
strncpy(res + sizeof(rcc_string_header), buf, len);
- res[sizeof(rcc_string_header) + 1 + len] = 0;
+ res[sizeof(rcc_string_header) + len] = 0;
memcpy(res, &header, sizeof(rcc_string_header));
diff --git a/src/rccxml.c b/src/rccxml.c
index 8283a39..f40853f 100644
--- a/src/rccxml.c
+++ b/src/rccxml.c
@@ -75,7 +75,6 @@ int rccXmlInit() {
if (pos == RCC_MAX_LANGUAGES) goto clear;
for (npos = 0; rcc_default_language_names[npos].sn; npos++);
- puts("+++");
nnodes = node_set->nodeNr;
@@ -85,11 +84,9 @@ int rccXmlInit() {
lang = attr->children->content;
if ((!lang)||(!lang[0])) continue;
- puts(lang);
for (cpos=1,fullname=NULL,node=pnode->children;node;node=node->next) {
if (node->type != XML_ELEMENT_NODE) continue;
- puts(node->name);
if (!xmlStrcmp(node->name, "Charsets")) {
for (cpos = 0, cnode=node->children;cnode;cnode=cnode->next) {
if (cnode->type != XML_ELEMENT_NODE) continue;
diff --git a/src/recode.c b/src/recode.c
index 80b59eb..f10221f 100644
--- a/src/recode.c
+++ b/src/recode.c
@@ -48,7 +48,8 @@ rcc_string rccFrom(rcc_context ctx, rcc_class_id class_id, const char *buf, int
// DS: Learning. check database (language_id)
charset_id = rccIConvAuto(ctx, class_id, buf, len);
- if (charset_id > 0) icnv = ctx->iconv_auto[charset_id];
+ if (charset_id != (rcc_charset_id)-1) icnv = ctx->iconv_auto[charset_id];
+
if (icnv == (iconv_t)-1) {
icnv = ctx->iconv_from[class_id];
if (icnv == (iconv_t)-1) return NULL;
@@ -61,7 +62,7 @@ rcc_string rccFrom(rcc_context ctx, rcc_class_id class_id, const char *buf, int
if (err<=0) return NULL;
result = rccCreateString(language_id, ctx->tmpbuffer, err, rlen);
}
-
+
// DS: Learning. write database
return result;
@@ -88,7 +89,6 @@ char *rccTo(rcc_context ctx, rcc_class_id class_id, const rcc_string buf, int le
class_type = rccGetClassType(ctx, class_id);
if ((class_type == RCC_CLASS_FS)&&(rccGetOption(ctx, RCC_AUTODETECT_FS_NAMES))) {
- // DS: file_names (aut odetect fspath)
prefix = NULL; name = buf + sizeof(rcc_string_header);
err = rccFS0(NULL, buf, &prefix, &name);
if (!err) {
diff --git a/ui/gtk.c b/ui/gtk.c
index 84aa7df..c8e3a59 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -113,7 +113,6 @@ int rccUiMenuConfigureWidget(rcc_ui_menu_context ctx) {
item = gtk_menu_item_new_with_label(charsets[i]);
gtk_widget_show(item);
gtk_menu_append(GTK_MENU(list), item);
- puts(charsets[i]);
}
if (ctx->widget) menu = ctx->widget;
@@ -139,7 +138,6 @@ int rccUiMenuConfigureWidget(rcc_ui_menu_context ctx) {
item = gtk_menu_item_new_with_label(engines[i]->title);
gtk_widget_show(item);
gtk_menu_append(GTK_MENU(list), item);
- puts(engines[i]->title);
}
if (ctx->widget) menu = ctx->widget;
@@ -152,7 +150,7 @@ int rccUiMenuConfigureWidget(rcc_ui_menu_context ctx) {
gtk_option_menu_set_menu(GTK_OPTION_MENU(menu), list);
config = rccGetConfig(rccctx, language_id);
- engine_id = rccConfigGetSelectedEngine(config);
+ engine_id = rccConfigGetCurrentEngine(config);
if (engine_id < 0) engine_id = 0;
gtk_option_menu_set_history(GTK_OPTION_MENU(menu), engine_id);