diff options
author | Suren A. Chilingaryan <csa@suren.me> | 2021-03-12 03:55:34 +0100 |
---|---|---|
committer | Suren A. Chilingaryan <csa@suren.me> | 2021-03-12 03:55:34 +0100 |
commit | 60bd665e74cfeeaf70882173a0dd56c883e2014a (patch) | |
tree | 8a0066bb9f0259becac5605641e8e1eed1ae0e89 /fixes | |
download | rusxmms2-60bd665e74cfeeaf70882173a0dd56c883e2014a.tar.gz rusxmms2-60bd665e74cfeeaf70882173a0dd56c883e2014a.tar.bz2 rusxmms2-60bd665e74cfeeaf70882173a0dd56c883e2014a.tar.xz rusxmms2-60bd665e74cfeeaf70882173a0dd56c883e2014a.zip |
Added to git tree
Diffstat (limited to 'fixes')
18 files changed, 1301 insertions, 0 deletions
diff --git a/fixes/libguess-fixes/README b/fixes/libguess-fixes/README new file mode 100644 index 0000000..bad7594 --- /dev/null +++ b/fixes/libguess-fixes/README @@ -0,0 +1 @@ +This patch adds BIG5 encoding detection into the Chinese detection engine. diff --git a/fixes/libguess-fixes/libguess-ds-cn.patch b/fixes/libguess-fixes/libguess-ds-cn.patch new file mode 100644 index 0000000..7c2384b --- /dev/null +++ b/fixes/libguess-fixes/libguess-ds-cn.patch @@ -0,0 +1,62 @@ +diff -dPNur libguess-0.2.0-d7/guess.c libguess-0.2.0-d7-new/guess.c +--- libguess-0.2.0-d7/guess.c 2006-12-05 17:59:32.000000000 +0100 ++++ libguess-0.2.0-d7-new/guess.c 2007-06-26 19:56:59.000000000 +0200 +@@ -44,7 +44,7 @@ + /* ORDER_** &highest, &second, ... &lowest */ + #define ORDER_JP &utf8, &sjis, &eucj + #define ORDER_TW &utf8, &big5 +-#define ORDER_CN &utf8, &gb2312, &gb18030 ++#define ORDER_CN &utf8, &gb2312, &gb18030, &big5 + #define ORDER_KR &utf8, &euck, &johab + + /* workaround for that glib's g_convert can't convert +@@ -252,6 +252,8 @@ + guess_dfa gb2312 = DFA_INIT(guess_gb2312_st, guess_gb2312_ar); + guess_dfa utf8 = DFA_INIT(guess_utf8_st, guess_utf8_ar); + guess_dfa gb18030 = DFA_INIT(guess_gb18030_st, guess_gb18030_ar); ++ guess_dfa big5 = DFA_INIT(guess_big5_st, guess_big5_ar); ++ + guess_dfa *top = NULL; + + guess_dfa *order[] = { ORDER_CN, NULL }; +@@ -287,22 +289,27 @@ + } + + if (DFA_ALIVE(gb2312)) { +- if (!DFA_ALIVE(utf8) && !DFA_ALIVE(gb18030)) ++ if (!DFA_ALIVE(utf8) && !DFA_ALIVE(gb18030) && !DFA_ALIVE(big5)) + return "GB2312"; + DFA_NEXT(gb2312, c); + } + if (DFA_ALIVE(utf8)) { +- if (!DFA_ALIVE(gb2312) && !DFA_ALIVE(gb18030)) ++ if (!DFA_ALIVE(gb2312) && !DFA_ALIVE(gb18030) && !DFA_ALIVE(big5)) + return "UTF-8"; + DFA_NEXT(utf8, c); + } + if (DFA_ALIVE(gb18030)) { +- if (!DFA_ALIVE(utf8) && !DFA_ALIVE(gb2312)) ++ if (!DFA_ALIVE(utf8) && !DFA_ALIVE(gb2312) && !DFA_ALIVE(big5)) + return "GB18030"; + DFA_NEXT(gb18030, c); + } ++ if (DFA_ALIVE(big5)) { ++ if (!DFA_ALIVE(utf8) && !DFA_ALIVE(gb2312) && !DFA_ALIVE(gb18030)) ++ return "big5"; ++ DFA_NEXT(big5, c); ++ } + +- if (!DFA_ALIVE(gb2312) && !DFA_ALIVE(utf8) && !DFA_ALIVE(gb18030)) { ++ if (!DFA_ALIVE(gb2312) && !DFA_ALIVE(utf8) && !DFA_ALIVE(gb18030) && !DFA_ALIVE(big5)) { + /* we ran out the possibilities */ + return NULL; + } +@@ -323,6 +330,8 @@ + return "UTF-8"; + if (top == &gb18030) + return "GB18030"; ++ if (top == &big5) ++ return "BIG5"; + return NULL; + } + diff --git a/fixes/libtranslate-fixes/README b/fixes/libtranslate-fixes/README new file mode 100644 index 0000000..814a2ee --- /dev/null +++ b/fixes/libtranslate-fixes/README @@ -0,0 +1,38 @@ +It is highly recommended to apply all attached patches to libtranslate. They +are fixing several serious bugs and providing better support of various +translation services. Additionaly, it is highly recommended to obtain latest +valid service description file (services.xml) from http://RusXMMS.sf.net. + +*** IMPORTANT *** +Please, not you should apply "libtranslate-ds-fixcharset.patch" patch after +"libtranslate-ds-timed.patch" otherwise the process would fail. + + +Official Patches +================ +charsetparse: Patch fixing HTTP charset parsing +condfix: Patch fixing occasional translate_session_translate_text() + lockup + +DarkSoft Patches +================ +memory: Fixes memory exhaustion on 64bit platforms. +empty: Fixes segmentation in the case if the Web Server closes + connection prior to sending any data. +promt: Allows "entities" keyword to send ISO8859-1 source text in the + HTML Entities encoding as required by translate.ru service + (Look usage example in services.xml) +fixcharset: This patch enables support for translation services returning + wrong charset in Content-Type header (pereklad.ua for example). + The "response-charset" attribute could be used to declare + correct charset. + (Look usage example in services.xml) +timed: Provides time limited translation API functions. + + + +Configuration +============= +services.xml Example services.xml including translate.ru and pereklad.ua + services. This is an example only. Please, find the latest + version of the service.xml on the http://rusxmms.sf.net diff --git a/fixes/libtranslate-fixes/libtranslate-0.99-charsetparse.diff b/fixes/libtranslate-fixes/libtranslate-0.99-charsetparse.diff new file mode 100644 index 0000000..1626f25 --- /dev/null +++ b/fixes/libtranslate-fixes/libtranslate-0.99-charsetparse.diff @@ -0,0 +1,47 @@ +--- src/modules/translate-generic-service.c.orig Mon Apr 11 23:08:47 2005 ++++ src/modules/translate-generic-service.c Mon Apr 11 23:15:54 2005 +@@ -484,7 +484,7 @@ + + if (SOUP_STATUS_IS_SUCCESSFUL(message->status_code)) + { +- const char *charset = NULL; ++ char *charset = NULL; + + if (flags & TRANSFER_CONVERT) + { +@@ -493,14 +493,31 @@ + content_type = translate_generic_service_get_header(message, &info, "Content-Type"); + if (content_type) + { +- charset = translate_ascii_strcasestr(content_type, "charset="); +- if (charset) +- charset += 8; ++ const char *tmp; ++ ++ tmp = translate_ascii_strcasestr(content_type, "charset="); ++ if (tmp) ++ { ++ int len; ++ ++ tmp += 8; ++ if (*tmp == '\'' || *tmp == '"') ++ tmp++; ++ ++ len = strlen(tmp); ++ if (len > 0 && (tmp[len - 1] == '\'' || tmp[len - 1] == '"')) ++ len--; ++ ++ charset = g_strndup(tmp, len); ++ } + } + } + + if (charset) +- response = g_convert(message->response.body, message->response.length, "UTF-8", charset, NULL, NULL, err); ++ { ++ response = g_convert(message->response.body, message->response.length, "UTF-8", charset, NULL, NULL, err); ++ g_free(charset); ++ } + else + { + if ((flags & TRANSFER_CONVERT) && ! g_utf8_validate(message->response.body, message->response.length, NULL)) diff --git a/fixes/libtranslate-fixes/libtranslate-0.99-condfix.diff b/fixes/libtranslate-fixes/libtranslate-0.99-condfix.diff new file mode 100644 index 0000000..4011dcd --- /dev/null +++ b/fixes/libtranslate-fixes/libtranslate-0.99-condfix.diff @@ -0,0 +1,38 @@ +--- src/translate-session.c.orig Mon Apr 11 22:44:53 2005 ++++ src/translate-session.c Mon Apr 11 22:51:48 2005 +@@ -703,7 +703,14 @@ + GError *tmp_err = NULL; + + g_mutex_lock(info->mutex); +- ret = info->err != NULL; ++ if (info->err) ++ { ++ ret = TRUE; ++ if (info->progress_cond) ++ g_cond_signal(info->progress_cond); ++ } ++ else ++ ret = FALSE; + g_mutex_unlock(info->mutex); + + if (ret) +@@ -728,6 +735,9 @@ + else + g_propagate_error(&info->err, tmp_err); + ++ if (info->progress_cond) ++ g_cond_signal(info->progress_cond); ++ + g_mutex_unlock(info->mutex); + + return; +@@ -759,6 +769,9 @@ + info->err = g_error_new(TRANSLATE_SESSION_ERROR, + TRANSLATE_SESSION_ERROR_NO_SERVICE, + _("no service could translate chunk")); ++ ++ if (info->progress_cond) ++ g_cond_signal(info->progress_cond); + } + + g_mutex_unlock(info->mutex); diff --git a/fixes/libtranslate-fixes/libtranslate-ds-empty.patch b/fixes/libtranslate-fixes/libtranslate-ds-empty.patch new file mode 100644 index 0000000..1a6a25d --- /dev/null +++ b/fixes/libtranslate-fixes/libtranslate-ds-empty.patch @@ -0,0 +1,17 @@ +diff -dPNur libtranslate-0.99/src/modules/translate-generic-service.c libtranslate-0.99-new/src/modules/translate-generic-service.c +--- libtranslate-0.99/src/modules/translate-generic-service.c 2007-06-27 17:26:10.000000000 +0200 ++++ libtranslate-0.99-new/src/modules/translate-generic-service.c 2007-06-27 17:23:55.000000000 +0200 +@@ -1042,6 +1042,13 @@ + + g_free(response); + } ++ ++ if (!answer) { ++ g_set_error(err, ++ TRANSLATE_GENERIC_SERVICE_ERROR, ++ TRANSLATE_GENERIC_SERVICE_ERROR_PARSE, ++ _("empty server response")); ++ } + + return answer ? g_string_free(answer, FALSE) : NULL; + } diff --git a/fixes/libtranslate-fixes/libtranslate-ds-fixcharset.patch b/fixes/libtranslate-fixes/libtranslate-ds-fixcharset.patch new file mode 100644 index 0000000..0665d2f --- /dev/null +++ b/fixes/libtranslate-fixes/libtranslate-ds-fixcharset.patch @@ -0,0 +1,93 @@ +diff -dPNur libtranslate-0.99-new/src/modules/translate-generic-parser.c libtranslate-0.99-new-uk/src/modules/translate-generic-parser.c +--- libtranslate-0.99-new/src/modules/translate-generic-parser.c 2005-01-17 17:46:24.000000000 +0100 ++++ libtranslate-0.99-new-uk/src/modules/translate-generic-parser.c 2007-06-27 22:40:04.000000000 +0200 +@@ -726,6 +726,7 @@ + { + const char *url; + const char *post; ++ const char *charset; + const char *content_type; + + g_return_if_fail(info != NULL); +@@ -740,6 +741,7 @@ + "url", REQUIRED, &url, + "post", OPTIONAL, &post, + "content-type", OPTIONAL, &content_type, ++ "response-charset", OPTIONAL, &charset, + NULL); + + if (! *err) +@@ -748,6 +750,7 @@ + (*location)->url = g_strdup(url); + (*location)->post = g_strdup(post); + (*location)->content_type = g_strdup(content_type ? content_type : "application/x-www-form-urlencoded"); ++ (*location)->response_charset = g_strdup(charset); + } + } + +@@ -759,6 +762,7 @@ + g_free(location->url); + g_free(location->post); + g_free(location->content_type); ++ g_free(location->response_charset); + g_slist_foreach(location->http_headers, (GFunc) translate_generic_http_header_free, NULL); + g_slist_free(location->http_headers); + g_free(location); +diff -dPNur libtranslate-0.99-new/src/modules/translate-generic-parser.h libtranslate-0.99-new-uk/src/modules/translate-generic-parser.h +--- libtranslate-0.99-new/src/modules/translate-generic-parser.h 2005-01-17 17:46:30.000000000 +0100 ++++ libtranslate-0.99-new-uk/src/modules/translate-generic-parser.h 2007-06-27 22:34:13.000000000 +0200 +@@ -51,6 +51,7 @@ + char *url; + char *post; + char *content_type; ++ char *response_charset; + GSList *http_headers; + } TranslateGenericLocation; + +diff -dPNur libtranslate-0.99-new/src/modules/translate-generic-service.c libtranslate-0.99-new-uk/src/modules/translate-generic-service.c +--- libtranslate-0.99-new/src/modules/translate-generic-service.c 2007-06-27 17:23:55.000000000 +0200 ++++ libtranslate-0.99-new-uk/src/modules/translate-generic-service.c 2007-06-27 22:40:29.000000000 +0200 +@@ -129,6 +129,7 @@ + static char *translate_generic_service_get (const char *uri, + const char *post, + const char *post_content_type, ++ const char *response_charset, + const GSList *headers, + TransferFlags flags, + GTimeVal *deadline, +@@ -407,6 +408,7 @@ + translate_generic_service_get (const char *uri, + const char *post, + const char *post_content_type, ++ const char *response_charset, + const GSList *headers, + TransferFlags flags, + GTimeVal *deadline, +@@ -550,9 +552,9 @@ + } + } + +- if (charset) ++ if ((charset)||(response_charset)) + { +- response = g_convert(message->response.body, message->response.length, "UTF-8", charset, NULL, NULL, err); ++ response = g_convert(message->response.body, message->response.length, "UTF-8", response_charset?response_charset:charset, NULL, NULL, err); + g_free(charset); + } + else +@@ -941,6 +943,7 @@ + response = translate_generic_service_get(url, + post, + group->text_location->content_type, ++ group->text_location->response_charset, + headers, + TRANSFER_FOLLOW_REFRESH | TRANSFER_CONVERT, + deadline, +@@ -1339,6 +1342,7 @@ + response = translate_generic_service_get(translation_url, + post, + group->web_page_location->content_type, ++ group->web_page_location->response_charset, + headers, + 0, + NULL, diff --git a/fixes/libtranslate-fixes/libtranslate-ds-memory.patch b/fixes/libtranslate-fixes/libtranslate-ds-memory.patch new file mode 100644 index 0000000..e05c7b4 --- /dev/null +++ b/fixes/libtranslate-fixes/libtranslate-ds-memory.patch @@ -0,0 +1,12 @@ +diff -dPNur libtranslate-0.99/src/translate-util.c libtranslate-0.99-new/src/translate-util.c +--- libtranslate-0.99/src/translate-util.c 2005-01-17 16:45:45.000000000 +0000 ++++ libtranslate-0.99-new/src/translate-util.c 2005-12-29 18:35:04.000000000 +0000 +@@ -136,7 +136,7 @@ + g_return_val_if_fail(big != NULL, NULL); + g_return_val_if_fail(little != NULL, NULL); + +- lower_big = g_ascii_strdown(big, big_len); ++ lower_big = g_ascii_strdown(big, (int)big_len); + lower_little = g_ascii_strdown(little, -1); + + s = strstr(lower_big, lower_little); diff --git a/fixes/libtranslate-fixes/libtranslate-ds-promt.patch b/fixes/libtranslate-fixes/libtranslate-ds-promt.patch new file mode 100644 index 0000000..6b30145 --- /dev/null +++ b/fixes/libtranslate-fixes/libtranslate-ds-promt.patch @@ -0,0 +1,27 @@ +diff -dPNur libtranslate-0.99/src/modules/translate-generic-service.c libtranslate-0.99-new/src/modules/translate-generic-service.c +--- libtranslate-0.99/src/modules/translate-generic-service.c 2007-06-27 17:26:10.000000000 +0200 ++++ libtranslate-0.99-new/src/modules/translate-generic-service.c 2007-06-27 17:23:55.000000000 +0200 +@@ -1238,7 +1245,22 @@ + { + if (modifier_value) + g_warning(_("%s: value specified for \"escape\" modifier"), warning_prefix); +- modified = soup_uri_encode(value, NULL); ++ modified = soup_uri_encode(value, "&"); ++ } ++ else if (! strcmp(modifier_name, "entities")) ++ { ++ int i; ++ char *ptr; ++ ++ modified = g_malloc(strlen(value)*6 + 1); ++ for (i=0,ptr=modified;value[i];i++) { ++ if ((unsigned char)(value[i])<160) *(ptr++)=value[i]; ++ else { ++ sprintf(ptr, "&#%u;", (unsigned char)(value[i])); ++ ptr+=6; ++ } ++ } ++ *ptr = 0; + } + else if (! strcmp(modifier_name, "charset")) + { diff --git a/fixes/libtranslate-fixes/libtranslate-ds-timed.patch b/fixes/libtranslate-fixes/libtranslate-ds-timed.patch new file mode 100644 index 0000000..c98868a --- /dev/null +++ b/fixes/libtranslate-fixes/libtranslate-ds-timed.patch @@ -0,0 +1,352 @@ +diff -dPNur libtranslate-0.99/src/modules/translate-generic-service.c libtranslate-0.99-new/src/modules/translate-generic-service.c +--- libtranslate-0.99/src/modules/translate-generic-service.c 2005-01-17 17:46:38.000000000 +0100 ++++ libtranslate-0.99-new/src/modules/translate-generic-service.c 2005-07-27 22:13:33.000000000 +0200 +@@ -131,6 +131,7 @@ + const char *post_content_type, + const GSList *headers, + TransferFlags flags, ++ GTimeVal *deadline, + TranslateProgressFunc progress_func, + gpointer user_data, + GError **err); +@@ -181,6 +182,15 @@ + gpointer user_data, + GError **err); + ++static char *translate_generic_service_timed_translate_text (TranslateService *service, ++ const char *text, ++ const char *from, ++ const char *to, ++ GTimeVal *deadline, ++ TranslateProgressFunc progress_func, ++ gpointer user_data, ++ GError **err); ++ + char *translate_generic_service_expand (const char *warning_prefix, + const char *str, + ...); +@@ -248,6 +258,7 @@ + + service_class->get_pairs = translate_generic_service_get_pairs; + service_class->translate_text = translate_generic_service_translate_text; ++ service_class->timed_translate_text = translate_generic_service_timed_translate_text; + service_class->translate_web_page = translate_generic_service_translate_web_page; + + g_object_class_install_property(object_class, +@@ -387,12 +398,18 @@ + return TRUE; /* continue */ + } + ++static void send_message_cb(SoupMessage *req, gpointer user_data) { ++ g_object_ref(req); ++ *(gboolean*)user_data = TRUE; ++} ++ + static char * + translate_generic_service_get (const char *uri, + const char *post, + const char *post_content_type, + const GSList *headers, + TransferFlags flags, ++ GTimeVal *deadline, + TranslateProgressFunc progress_func, + gpointer user_data, + GError **err) +@@ -400,6 +417,8 @@ + TransferInfo info; + SoupMessage *message; + const GSList *l; ++ GTimeVal tv; ++ gboolean completed = 0, canceled = 0; + char *response = NULL; + + g_return_val_if_fail(uri != NULL, FALSE); +@@ -479,9 +498,27 @@ + if (translate_generic_debug_flags & TRANSLATE_GENERIC_DEBUG_LOG_TRANSFERS) + translate_generic_service_log_connect(message); + ++ if (deadline) { ++ soup_session_queue_message(info.session, message, send_message_cb, &completed); ++ ++ do { ++ g_main_iteration (FALSE); ++ if (completed) break; ++ ++ g_get_current_time(&tv); ++ } while ((tv.tv_sec < deadline->tv_sec)||((tv.tv_sec == deadline->tv_sec)&&(tv.tv_usec < deadline->tv_usec))); ++ ++ if (!completed) { ++ soup_session_cancel_message(info.session, message); ++ canceled = 1; ++ } ++ } else + soup_session_send_message(info.session, message); + g_object_unref(info.session); + ++ if (canceled) ++ g_set_error(err, TRANSLATE_ERROR, TRANSLATE_ERROR_CANCELLED, _("Timeout")); ++ else + if (SOUP_STATUS_IS_SUCCESSFUL(message->status_code)) + { + const char *charset = NULL; +@@ -833,10 +870,11 @@ + } + + static char * +-translate_generic_service_translate_text (TranslateService *service, ++translate_generic_service_timed_translate_text (TranslateService *service, + const char *text, + const char *from, + const char *to, ++ GTimeVal *deadline, + TranslateProgressFunc progress_func, + gpointer user_data, + GError **err) +@@ -882,16 +920,16 @@ + + headers = g_slist_copy(group->http_headers); + headers = g_slist_concat(headers, g_slist_copy(group->text_location->http_headers)); +- ++ + response = translate_generic_service_get(url, + post, + group->text_location->content_type, + headers, + TRANSFER_FOLLOW_REFRESH | TRANSFER_CONVERT, ++ deadline, + progress_func, + user_data, + err); +- + g_free(url); + g_free(post); + g_slist_free(headers); +@@ -991,6 +1029,18 @@ + return answer ? g_string_free(answer, FALSE) : NULL; + } + ++static char * ++translate_generic_service_translate_text (TranslateService *service, ++ const char *text, ++ const char *from, ++ const char *to, ++ TranslateProgressFunc progress_func, ++ gpointer user_data, ++ GError **err) ++{ ++ return translate_generic_service_timed_translate_text(service, text, from, to, NULL, progress_func, user_data, err); ++} ++ + char * + translate_generic_service_expand (const char *warning_prefix, + const char *str, +@@ -1252,6 +1302,7 @@ + group->web_page_location->content_type, + headers, + 0, ++ NULL, + progress_func, + user_data, + err); +@@ -1311,7 +1362,7 @@ + g_free(proxy_text_uri); + } + +- session = soup_session_sync_new_with_options(SOUP_SESSION_PROXY_URI, proxy_uri, NULL); ++ session = soup_session_async_new_with_options(SOUP_SESSION_PROXY_URI, proxy_uri, NULL); + + if (proxy_uri) + soup_uri_free(proxy_uri); +diff -dPNur libtranslate-0.99/src/translate-service.c libtranslate-0.99-new/src/translate-service.c +--- libtranslate-0.99/src/translate-service.c 2005-01-17 17:45:23.000000000 +0100 ++++ libtranslate-0.99-new/src/translate-service.c 2005-07-27 17:18:07.000000000 +0200 +@@ -372,6 +372,28 @@ + } + + char * ++translate_service_timed_translate_text (TranslateService *service, ++ const char *text, ++ const char *from, ++ const char *to, ++ GTimeVal *deadline, ++ TranslateProgressFunc progress_func, ++ gpointer user_data, ++ GError **err) ++{ ++ g_return_val_if_fail(TRANSLATE_IS_SERVICE(service), NULL); ++ g_return_val_if_fail(TRANSLATE_SERVICE_GET_CLASS(service)->translate_text != NULL, NULL); ++ g_return_val_if_fail(text != NULL, NULL); ++ g_return_val_if_fail(from != NULL, NULL); ++ g_return_val_if_fail(to != NULL, NULL); ++ ++ if (TRANSLATE_SERVICE_GET_CLASS(service)->timed_translate_text) ++ return TRANSLATE_SERVICE_GET_CLASS(service)->timed_translate_text(service, text, from, to, deadline, progress_func, user_data, err); ++ ++ return TRANSLATE_SERVICE_GET_CLASS(service)->translate_text(service, text, from, to, progress_func, user_data, err); ++} ++ ++char * + translate_service_translate_web_page (TranslateService *service, + const char *url, + const char *from, +diff -dPNur libtranslate-0.99/src/translate-service.h libtranslate-0.99-new/src/translate-service.h +--- libtranslate-0.99/src/translate-service.h 2005-01-17 17:45:29.000000000 +0100 ++++ libtranslate-0.99-new/src/translate-service.h 2005-07-27 16:54:46.000000000 +0200 +@@ -73,6 +73,14 @@ + TranslateProgressFunc progress_func, + gpointer user_data, + GError **err); ++ char *(*timed_translate_text)(TranslateService *service, ++ const char *text, ++ const char *from, ++ const char *to, ++ GTimeVal *deadline, ++ TranslateProgressFunc progress_func, ++ gpointer user_data, ++ GError **err); + char *(*translate_web_page) (TranslateService *service, + const char *url, + const char *from, +diff -dPNur libtranslate-0.99/src/translate-service-private.h libtranslate-0.99-new/src/translate-service-private.h +--- libtranslate-0.99/src/translate-service-private.h 2005-01-17 17:45:17.000000000 +0100 ++++ libtranslate-0.99-new/src/translate-service-private.h 2005-07-27 17:30:00.000000000 +0200 +@@ -41,6 +41,14 @@ + TranslateProgressFunc progress_func, + gpointer user_data, + GError **err); ++char *translate_service_timed_translate_text (TranslateService *service, ++ const char *text, ++ const char *from, ++ const char *to, ++ GTimeVal *deadline, ++ TranslateProgressFunc progress_func, ++ gpointer user_data, ++ GError **err); + char *translate_service_translate_web_page (TranslateService *service, + const char *url, + const char *from, +diff -dPNur libtranslate-0.99/src/translate-session.c libtranslate-0.99-new/src/translate-session.c +--- libtranslate-0.99/src/translate-session.c 2005-01-17 17:45:35.000000000 +0100 ++++ libtranslate-0.99-new/src/translate-session.c 2005-07-27 16:52:46.000000000 +0200 +@@ -62,6 +62,8 @@ + { + GMutex *mutex; + GCond *progress_cond; ++ ++ GTimeVal *deadline; + + TranslateSession *session; + GSList *services; +@@ -487,6 +489,7 @@ + * @text: a nul-terminated string. + * @from: a RFC 3066 language tag. + * @to: a RFC 3066 language tag. ++ * @timeout: timeout in microseconds. + * @progress_func: a function to call when progressing, or %NULL. + * @user_data: data to pass to @progress_func, or %NULL. + * @err: a location to report errors, or %NULL. Any of the errors in +@@ -505,10 +508,11 @@ + * when no longer needed. + **/ + char * +-translate_session_translate_text (TranslateSession *session, ++translate_session_timed_translate_text (TranslateSession *session, + const char *text, + const char *from, + const char *to, ++ gulong timeout, + TranslateProgressFunc progress_func, + gpointer user_data, + GError **err) +@@ -519,6 +523,7 @@ + unsigned int max_threads; + GThreadPool *pool; + GSList *l; ++ GTimeVal deadline; + unsigned int max_chunk_len = 0; + char *translated = NULL; + +@@ -527,6 +532,11 @@ + g_return_val_if_fail(from != NULL, NULL); + g_return_val_if_fail(to != NULL, NULL); + ++ if (timeout) { ++ g_get_current_time(&deadline); ++ g_time_val_add(&deadline, timeout); ++ } ++ + LOCK(session); + info.services = translate_session_get_services_for_translation(session, + TRANSLATE_PAIR_TEXT, +@@ -560,7 +570,8 @@ + chunks = translate_session_split(text, max_chunk_len); + + info.mutex = g_mutex_new(); +- info.progress_cond = progress_func ? g_cond_new() : NULL; ++ info.progress_cond = (progress_func||timeout) ? g_cond_new() : NULL; ++ info.deadline = timeout ? &deadline : NULL; + info.session = session; + info.chunks = NULL; + info.from = from; +@@ -614,6 +625,11 @@ + GSList *l; + int n_chunks; + ++ if (timeout) { ++ if (!g_cond_timed_wait(info.progress_cond, info.mutex, info.deadline)) ++ info.err = g_error_new(TRANSLATE_ERROR,TRANSLATE_ERROR_CANCELLED,_("timeout")); ++ break; ++ } else + g_cond_wait(info.progress_cond, info.mutex); + + if (info.err) +@@ -680,6 +696,18 @@ + return translated; + } + ++char * ++translate_session_translate_text (TranslateSession *session, ++ const char *text, ++ const char *from, ++ const char *to, ++ TranslateProgressFunc progress_func, ++ gpointer user_data, ++ GError **err) ++{ ++ return translate_session_timed_translate_text(session, text, from, to, 0, progress_func, user_data, err); ++} ++ + static void + translate_session_translate_thread (gpointer data, gpointer user_data) + { +@@ -709,10 +737,11 @@ + if (ret) + return; + +- chunk_info->translated = translate_service_translate_text(service, ++ chunk_info->translated = translate_service_timed_translate_text(service, + chunk_info->chunk, + info->from, + info->to, ++ info->deadline, + info->progress_cond ? translate_session_translate_progress_cb : NULL, + info->progress_cond ? chunk_info : NULL, + &tmp_err); +diff -dPNur libtranslate-0.99/src/translate-session.h libtranslate-0.99-new/src/translate-session.h +--- libtranslate-0.99/src/translate-session.h 2005-01-17 17:45:40.000000000 +0100 ++++ libtranslate-0.99-new/src/translate-session.h 2005-07-27 14:41:05.000000000 +0200 +@@ -93,6 +93,14 @@ + unsigned int translate_session_get_max_threads (TranslateSession *session); + int translate_session_get_max_retries (TranslateSession *session); + ++char *translate_session_timed_translate_text (TranslateSession *session, ++ const char *text, ++ const char *from, ++ const char *to, ++ gulong timeout, ++ TranslateProgressFunc progress_func, ++ gpointer user_data, ++ GError **err); + char *translate_session_translate_text (TranslateSession *session, + const char *text, + const char *from, diff --git a/fixes/libtranslate-fixes/services.xml b/fixes/libtranslate-fixes/services.xml new file mode 100644 index 0000000..c27dd2e --- /dev/null +++ b/fixes/libtranslate-fixes/services.xml @@ -0,0 +1,260 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE services SYSTEM "services.dtd"> +<services> + <custom-language tag="zh-TW" name="Chinese (Taiwan)"/> + + <service nick="Google" name="google"> + <group> + <language to="*" tag="en"/> + <language to="en,de" tag="fr"/> + <language to="en,fr" tag="de"/> + <language to="en" tag="it"/> + <language to="en" tag="pt"/> + <language to="en" tag="es"/> + <language to="en" tag="pt"/> + <language to="en" tag="ru"/> + <language to="en" tag="zh"/> + <language to="en" tag="zh-TW"/> + <language to="en" tag="ja"/> + <language to="en" tag="ko"/> + <language to="en" tag="ar"/> + <text-translation url="http://www.google.com/translate_t?text=${text:escape}&langpair=${from}|${to}&ie=utf8&oe=utf8"> + <pre-marker text="id=result_box"/> + <pre-marker text=">"/> + <post-marker text="</div>"/> + </text-translation> + <web-page-translation url="http://www.google.com/translate_c?u=${url:escape}&langpair=${from}|${to}"/> + </group> + </service> + + <service nick="FreeTranslation" name="freetranslation" max-chunk-len="600"> + <group> + <language to="en" tag="nl" service-tag="dutch"/> + <language to="*" tag="en" service-tag="english"/> + <language to="en" tag="fr" service-tag="french"/> + <language to="en" tag="de" service-tag="german"/> + <language to="en" tag="it" service-tag="italian"/> + <language tag="no" service-tag="norwegian"/> + <language to="en" tag="pt" service-tag="portuguese"/> + <language to="en" tag="es" service-tag="spanish"/> + <text-translation url="http://ets.freetranslation.com/?sequence=core&srctext=${text:escape}&language=${from}/${to}&charset=utf-8"/> + <web-page-translation url="http://fets5.freetranslation.com/?sequence=core&url=${url:escape}&language=${from}/${to}"/> + </group> + <group> + <language tag="zh" service-tag="simplifiedchinese"/> + <language tag="zh-TW" service-tag="traditionalchinese"/> + <language to="*" tag="en" service-tag="english"/> + <language to="en" tag="ru" service-tag="russian"/> + <text-translation url="http://ets6.freetranslation.com/?sequence=core&srctext=${text:escape}&language=${from}/${to}&charset=utf-8"/> + </group> + <group> + <language to="*" tag="en" service-tag="english"/> + <language to="en" tag="ja" service-tag="japanese"/> + <text-translation url="http://tets9.freetranslation.com/?sequence=core&srctext=${text:escape}&language=${from}/${to}&charset=utf-8"/> + </group> + </service> + + <service nick="Pereklad" name="pereklad"> + <group> + <language to="*" tag="ru" service-tag="Rus"/> + <language to="*" tag="uk" service-tag="Ukr"/> + <text-translation + url="http://pereklad.online.ua/" + post="TranFrom=${from}&TranTo=${to}&SrcTxt=${text:charset=CP1251,escape}"> + <pre-marker text="id="DstTxt""/> + <pre-marker text=">"/> + <post-marker text="</textarea>"/> + </text-translation> + </group> + <group> + <language to="*" tag="en" service-tag="Eng"/> + <language to="*" tag="de" service-tag="Ger"/> + <language to="*" tag="fr" service-tag="Fra"/> + <text-translation + url="http://pereklad.online.ua/" + post="TranFrom=${from}&TranTo=${to}&SrcTxt=${text:charset=ISO-8859-1,escape}" + response-charset="ISO-8859-1"> + <pre-marker text="id="DstTxt""/> + <pre-marker text=">"/> + <post-marker text="</textarea>"/> + </text-translation> + </group> + <group> + <language to="en,de,fr" tag="ru" service-tag="Rus"/> + <language to="en,de,fr" tag="uk" service-tag="Ukr"/> + <language to="" tag="en" service-tag="Eng"/> + <language to="" tag="de" service-tag="Ger"/> + <language to="" tag="fr" service-tag="Fra"/> + <text-translation + url="http://pereklad.online.ua/" + post="TranFrom=${from}&TranTo=${to}&SrcTxt=${text:charset=CP1251,escape}" + response-charset="ISO-8859-1"> + <pre-marker text="id="DstTxt""/> + <pre-marker text=">"/> + <post-marker text="</textarea>"/> + </text-translation> + </group> + <group> + <language to="" tag="ru" service-tag="Rus"/> + <language to="" tag="uk" service-tag="Ukr"/> + <language to="ru,uk" tag="en" service-tag="Eng"/> + <language to="ru,uk" tag="de" service-tag="Ger"/> + <language to="ru,uk" tag="fr" service-tag="Fra"/> + <text-translation + url="http://pereklad.online.ua/" + post="TranFrom=${from}&TranTo=${to}&SrcTxt=${text:charset=ISO-8859-1,escape}"> + <pre-marker text="id="DstTxt""/> + <pre-marker text=">"/> + <post-marker text="</textarea>"/> + </text-translation> + </group> + <group> + <language to="" tag="ru" service-tag="Rus"/> + <language to="" tag="uk" service-tag="Ukr"/> + <language to="ru,uk" tag="lv" service-tag="Lat"/> + <text-translation + url="http://pereklad.online.ua/" + post="TranFrom=${from}&TranTo=${to}&SrcTxt=${text:charset=ISO-8859-4,escape}"> + <pre-marker text="id="DstTxt""/> + <pre-marker text=">"/> + <post-marker text="</textarea>"/> + </text-translation> + </group> + <group> + <language to="*" tag="lv" service-tag="Lat"/> + <language to="" tag="en" service-tag="Eng"/> + <language to="" tag="de" service-tag="Ger"/> + <language to="" tag="fr" service-tag="Fra"/> + <text-translation + url="http://pereklad.online.ua/" + post="TranFrom=${from}&TranTo=${to}&SrcTxt=${text:charset=ISO-8859-4,escape}" + response-charset="ISO-8859-1"> + <pre-marker text="id="DstTxt""/> + <pre-marker text=">"/> + <post-marker text="</textarea>"/> + </text-translation> + </group> + <group> + <language to="" tag="lv" service-tag="Lat"/> + <language to="lv" tag="ru" service-tag="Rus"/> + <language to="lv" tag="uk" service-tag="Ukr"/> + <text-translation + url="http://pereklad.online.ua/" + post="TranFrom=${from}&TranTo=${to}&SrcTxt=${text:charset=CP1251,escape}" + response-charset="ISO-8859-4"> + <pre-marker text="id="DstTxt""/> + <pre-marker text=">"/> + <post-marker text="</textarea>"/> + </text-translation> + </group> + <group> + <language to="" tag="lv" service-tag="Lat"/> + <language to="lv" tag="en" service-tag="Eng"/> + <language to="lv" tag="de" service-tag="Ger"/> + <language to="lv" tag="fr" service-tag="Fra"/> + <text-translation + url="http://pereklad.online.ua/" + post="TranFrom=${from}&TranTo=${to}&SrcTxt=${text:charset=ISO-8859-1,escape}" + response-charset="ISO-8859-4"> + <pre-marker text="id="DstTxt""/> + <pre-marker text=">"/> + <post-marker text="</textarea>"/> + </text-translation> + </group> + </service> + + <service nick="Promt" name="promt"> + <group> + <language to="" tag="ru" service-tag="r"/> + <language to="ru,de,fr,es" tag="en" service-tag="e"/> + <language to="ru,en,fr,es" tag="de" service-tag="g"/> + <language to="ru,en,de,es" tag="fr" service-tag="f"/> + <language to="ru,en" tag="it" service-tag="i"/> + <language to="ru,en,de,fr" tag="es" service-tag="s"/> + <language to="en" tag="pt" service-tag="p"/> + <text-translation + url="http://www.translate.ru/text.asp" + post="lang=en&transliterate=ON&direction=${from}${to}&source=${text:charset=ISO8859-1,entities,escape}&status=translate"> + <pre-marker text="id="r_text""/> + <pre-marker text=">"/> + <post-marker text="</span>"/> + </text-translation> + </group> + <group> + <language to="*" tag="ru" service-tag="r"/> + <language to="" tag="de" service-tag="g"/> + <language to="" tag="fr" service-tag="f"/> + <language to="" tag="it" service-tag="i"/> + <language to="" tag="es" service-tag="s"/> + <text-translation url="http://www.translate.ru/text.asp?lang=ru&transliterate=ON&direction=r${to}&source=${text:charset=CP1251,escape}&status=translate"> + <pre-marker text="id="r_text""/> + <pre-marker text=">"/> + <post-marker text="</span>"/> + </text-translation> + </group> + </service> + + <service nick="SYSTRAN" name="systran"> + <group> + <language to="en" tag="ar"/> + <language to="en" tag="zh"/> + <language to="en" tag="zh-TW" service-tag="zt"/> + <language to="en,fr" tag="nl"/> + <language to="*" tag="en"/> + <language to="nl,en,de,it,pt,es" tag="fr"/> + <language to="en,fr" tag="de"/> + <language to="en,fr" tag="it"/> + <language to="en" tag="ja"/> + <language to="en" tag="ko"/> + <language to="en,fr" tag="pt"/> + <language to="en" tag="ru"/> + <language to="en,fr" tag="es"/> + <language to="en" tag="sv"/> + <http-header value="http://www.systransoft.com/" name="Referer"/> + <text-translation url="http://www.systranbox.com/systran/box?systran_charset=utf-8&ttype=text&systran_text=${text:escape}&systran_lp=${from}_${to}"> + <pre-marker text="<textarea name="translation""/> + <pre-marker text=">"/> + <post-marker text="</textarea>"/> + </text-translation> + <web-page-translation url="http://www.systranbox.com/systran/box?systran_id=SystranSoft-en&systran_url=${url:escape}&systran_lp=${from}_${to}&systran_f=${time}"/> + </group> + </service> + + <service nick="Babel Fish" name="babelfish"> + <group> + <language to="en" tag="zh"/> + <language to="en" tag="zh-TW" service-tag="zt"/> + <language to="*" tag="en"/> + <language to="en,fr" tag="nl"/> + <language to="en,de,el,it,pt,nl,es" tag="fr"/> + <language to="en,fr" tag="de"/> + <language to="en,fr" tag="el"/> + <language to="en,fr" tag="it"/> + <language to="en" tag="ja"/> + <language to="en" tag="ko"/> + <language to="en,fr" tag="pt"/> + <language to="en" tag="ru"/> + <language to="en,fr" tag="es"/> + <text-translation url="http://babelfish.altavista.com/babelfish/tr?urltext=${text:escape}&lp=${from}_${to}&enc=utf8"> + <pre-marker text="<form action="http://www.altavista.com/web/results"/> + <pre-marker text="px;>"/> + <post-marker text="</div>"/> + </text-translation> + <web-page-translation url="http://babelfish.altavista.com/babelfish/trurl_load?url=${url:escape}&lp=${from}_${to}&enc=utf8"/> + </group> + </service> + + <service nick="Kataku" name="kataku"> + <group> + <language to="*" tag="en"/> + <language to="*" tag="id" service-tag="in"/> + <text-translation url="http://www.toggletext.com/kataku_trial.php" post="input_text=${text:charset=ISO8859-1,escape}&langset_text=${from}_${to}"> + <pre-marker text="Translation:"/> + <pre-marker text="<pre"/> + <pre-marker text=">"/> + <post-marker text=" </pre>"/> + </text-translation> + <web-page-translation url="http://www.toggletext.com/kataku_webpage_translate.php?input=${url:escape}&langset=${from}_${to}"/> + </group> + </service> +</services>
\ No newline at end of file diff --git a/fixes/mac-fixes/README b/fixes/mac-fixes/README new file mode 100644 index 0000000..072233e --- /dev/null +++ b/fixes/mac-fixes/README @@ -0,0 +1,41 @@ +mac is unsupported port for Monkey Audio Loseless Codec (ape) Acutally, it is +known for lot of problems on 64bit platforms. Here is patch fixing another one. + + +Some description for future use +=============================== + The problems is actully related to converting pointers to/from int type. +The portability requires intptr_t to be used for that purposes. However, +in many places 'int' still specified. Therefore, if acutal pointer is +above int size on AMD64, the crashes occurs. + +It looks new/malloc on my Gentoo system in the beginning allocates memory +in the lower segments and everything goes smoothly. However, after a while +the allocation from higher regions is started. This could be traced by +monitoring the result of + mac_info = (PlayerInfo *)g_malloc0(sizeof(PlayerInfo)); + decompress = CreateIAPEDecompress(pUTF16, &nRetVal); +in function 'decompress_init' of mac.cpp (xmms-mac). After few iterations they +would return high address ptr. Actually, the good method of accelerating +crashes, is usage of following code (within decompress_init): + + rep: + decompress = CreateIAPEDecompress(pUTF16, &nRetVal); + if (decompress < (void*)0x7FFFFFFF) { + void *a=malloc((int)1000*rand()); + delete decompress; + free(a); + goto rep; + } + +Few notes on mac +================ +MACLib.cpp - C(stdcall) functions for class construction +APEDecompress - main working class which widly utilizes +UnBitArray - classes to work with actual data (many int usages within) + pIO - after a lot of black magick is initialiozed by function + call: + CAPEDecompress::GetInfo + which in his order calls: + CAPEInfo::GetInfo + diff --git a/fixes/mac-fixes/mac-3.99-u4-b5-s4-ds-fix.patch b/fixes/mac-fixes/mac-3.99-u4-b5-s4-ds-fix.patch new file mode 100644 index 0000000..aba0379 --- /dev/null +++ b/fixes/mac-fixes/mac-3.99-u4-b5-s4-ds-fix.patch @@ -0,0 +1,12 @@ +diff -dPNur mac-3.99-u4-b5-s4/src/MACLib/APEDecompress.cpp mac-3.99-u4-b5-s4-new/src/MACLib/APEDecompress.cpp +--- mac-3.99-u4-b5-s4/src/MACLib/APEDecompress.cpp 2006-06-01 11:00:58.000000000 +0200 ++++ mac-3.99-u4-b5-s4-new/src/MACLib/APEDecompress.cpp 2008-04-12 17:39:39.000000000 +0200 +@@ -369,7 +369,7 @@ + *****************************************************************************************/ + intptr_t CAPEDecompress::GetInfo(APE_DECOMPRESS_FIELDS Field, intptr_t nParam1, intptr_t nParam2) + { +- int nRetVal = 0; ++ intptr_t nRetVal = 0; + BOOL bHandled = TRUE; + + switch (Field) diff --git a/fixes/taglib-fixes/taglib-1.4_wchar.diff b/fixes/taglib-fixes/taglib-1.4_wchar.diff new file mode 100644 index 0000000..b84a614 --- /dev/null +++ b/fixes/taglib-fixes/taglib-1.4_wchar.diff @@ -0,0 +1,31 @@ +diff -ruN taglib-1.4.org/taglib/toolkit/tstring.cpp taglib-1.4/taglib/toolkit/tstring.cpp +--- taglib-1.4.org/taglib/toolkit/tstring.cpp 2005-07-26 06:31:15.000000000 +0900 ++++ taglib-1.4/taglib/toolkit/tstring.cpp 2006-05-26 12:02:55.000000000 +0900 +@@ -202,12 +202,22 @@ + s.resize(d->data.size()); + + if(!unicode) { +- std::string::iterator targetIt = s.begin(); +- for(wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++) { +- *targetIt = char(*it); +- ++targetIt; ++ bool cjk = false; ++ //pre-scan: is there any cjk unicode character? if so, convert the string into utf-8. ++ for(unsigned int i=0; i< d->data.size(); i++){ ++ if(d->data[i] > 0xff){ ++ cjk = true; ++ break; ++ } ++ } ++ if(!cjk){ ++ std::string::iterator targetIt = s.begin(); ++ for(wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++) { ++ *targetIt = char(*it); ++ ++targetIt; ++ } ++ return s; + } +- return s; + } + + const int outputBufferSize = d->data.size() * 3 + 1; diff --git a/fixes/xmms-fixes/gcc41/xmms-1.2.10-gcc41.patch b/fixes/xmms-fixes/gcc41/xmms-1.2.10-gcc41.patch new file mode 100644 index 0000000..0041851 --- /dev/null +++ b/fixes/xmms-fixes/gcc41/xmms-1.2.10-gcc41.patch @@ -0,0 +1,10 @@ +--- xmms-1.2.10.orig/Output/esd/esdout.h 2005-11-22 19:53:38.000000000 +0600 ++++ xmms-1.2.10/Output/esd/esdout.h 2005-11-22 19:56:04.197329014 +0600 +@@ -58,6 +58,7 @@ + ESDConfig; + + extern ESDConfig esd_cfg; ++extern void esdout_reset_playerid(void); + + void esdout_init(void); + void esdout_about(void); diff --git a/fixes/xmms-fixes/gcc41/xmms-1.2.10-locale_fix.patch b/fixes/xmms-fixes/gcc41/xmms-1.2.10-locale_fix.patch new file mode 100644 index 0000000..cfb1cd1 --- /dev/null +++ b/fixes/xmms-fixes/gcc41/xmms-1.2.10-locale_fix.patch @@ -0,0 +1,11 @@ +diff -ruN xmms-1.2.10.orig/xmms/playlist.c xmms-1.2.10/xmms/playlist.c +--- xmms-1.2.10.orig/xmms/playlist.c 2005-11-25 05:14:47.000000000 +0600 ++++ xmms-1.2.10/xmms/playlist.c 2005-11-25 05:18:59.894581237 +0600 +@@ -23,6 +23,7 @@ + #include "libxmms/rcc.h" + #include <sys/stat.h> + #include <unistd.h> ++#include <locale.h> + + GList *playlist = NULL; + GList *shuffle_list = NULL; diff --git a/fixes/zinf-fixes/zinf-ds-noutfrecoding.patch b/fixes/zinf-fixes/zinf-ds-noutfrecoding.patch new file mode 100644 index 0000000..6100a1d --- /dev/null +++ b/fixes/zinf-fixes/zinf-ds-noutfrecoding.patch @@ -0,0 +1,20 @@ +diff -dPNur zinf-2.2.5/plm/metadata/id3lib/id3lib.cpp zinf-2.2.5-new/plm/metadata/id3lib/id3lib.cpp +--- zinf-2.2.5/plm/metadata/id3lib/id3lib.cpp 2004-01-30 13:06:02.000000000 +0100 ++++ zinf-2.2.5-new/plm/metadata/id3lib/id3lib.cpp 2005-07-19 23:08:05.000000000 +0200 +@@ -321,16 +321,8 @@ + if (field) + if (field->Get (buffer, sizeof buffer) > 0) { + #ifdef HAVE_GLIB +- if (g_utf8_validate (buffer, -1 , NULL)){ + result = buffer; + return true; +- } +- else { +- utfbuffer=g_convert(buffer, sizeof buffer, "UTF-8", charset.c_str(), NULL, NULL, NULL); +- result=utfbuffer; +- g_free(utfbuffer); +- return true; +- } + #else + result=buffer; + return true; diff --git a/fixes/zinf-fixes/zinf-ds.patch b/fixes/zinf-fixes/zinf-ds.patch new file mode 100644 index 0000000..4e4b839 --- /dev/null +++ b/fixes/zinf-fixes/zinf-ds.patch @@ -0,0 +1,229 @@ +diff -dPNur zinf-2.2.5/plm/metadata/id3lib/id3lib.cpp zinf-2.2.5-new/plm/metadata/id3lib/id3lib.cpp +--- zinf-2.2.5/plm/metadata/id3lib/id3lib.cpp 2004-01-30 13:06:02.000000000 +0100 ++++ zinf-2.2.5-new/plm/metadata/id3lib/id3lib.cpp 2005-07-19 23:37:11.000000000 +0200 +@@ -304,10 +304,45 @@ + } + + ++static int rccGetCurrentEncoding(char *result, unsigned int n) { ++ unsigned int i; ++ char *l; ++ ++ if ((!result)||(!n)) return -1; ++ ++ 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; ++ } ++ ++ l = setlocale(LC_CTYPE, NULL); ++ if (!l) return -1; ++ ++ for (i=0;((l[i])&&(l[i]!='.')&&(l[i]!='_'));i++); ++ if (i>=n) return -1; ++ ++ l = strrchr(l, '.'); ++ if (!l) return -1; ++ ++ for (i=0;((l[i])&&(l[i]!='@'));i++); ++ if (i>=n) return -1; ++ ++ strncpy(result,l+1,i-1); ++ result[i]=0; ++ ++ return 0; ++} ++ + static + bool getTag(ID3_Tag&tag, ID3_FrameID frameid, string &result) + { +- static char buffer[1024]; ++ int err; ++ static char buffer[1024], locale[64]; + #ifdef HAVE_GLIB + gchar *utfbuffer; + #endif +@@ -326,7 +361,8 @@ + return true; + } + else { +- utfbuffer=g_convert(buffer, sizeof buffer, "UTF-8", charset.c_str(), NULL, NULL, NULL); ++ err = rccGetCurrentEncoding(locale, 64); ++ utfbuffer=g_convert(buffer, sizeof buffer, "UTF-8", err?charset.c_str():locale, NULL, NULL, NULL); + result=utfbuffer; + g_free(utfbuffer); + return true; +diff -dPNur zinf-2.2.5/ui/ncurses/Makefile.am zinf-2.2.5-new/ui/ncurses/Makefile.am +--- zinf-2.2.5/ui/ncurses/Makefile.am 2003-09-16 19:35:31.000000000 +0200 ++++ zinf-2.2.5-new/ui/ncurses/Makefile.am 2005-07-19 23:51:02.000000000 +0200 +@@ -3,11 +3,11 @@ + plugin_LTLIBRARIES = ncurses-ui.la + + ncurses_ui_la_SOURCES = ncursesUI.cpp +-ncurses_ui_la_LIBADD = $(NCURSES_LIBS) ++ncurses_ui_la_LIBADD = $(NCURSES_LIBS) $(GLIB_LIBS) + ncurses_ui_la_LDFLAGS = $(plugin_ldflags) + + noinst_HEADERS = ncursesUI.h + +-AM_CPPFLAGS = $(THREAD_CFLAGS) $(base_includes) ++AM_CPPFLAGS = $(THREAD_CFLAGS) $(base_includes) $(GLIB_CFLAGS) + + # arch-tag: 19b44c0b-0802-4cfc-9d47-519f9049c888 +diff -dPNur zinf-2.2.5/ui/ncurses/Makefile.in zinf-2.2.5-new/ui/ncurses/Makefile.in +--- zinf-2.2.5/ui/ncurses/Makefile.in 2004-02-09 01:48:25.000000000 +0100 ++++ zinf-2.2.5-new/ui/ncurses/Makefile.in 2005-07-20 00:23:03.823574339 +0200 +@@ -231,7 +231,7 @@ + + noinst_HEADERS = ncursesUI.h + +-AM_CPPFLAGS = $(THREAD_CFLAGS) $(base_includes) ++AM_CPPFLAGS = $(THREAD_CFLAGS) $(base_includes) $(GLIB_CFLAGS) + subdir = ui/ncurses + ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 + mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs +diff -dPNur zinf-2.2.5/ui/ncurses/ncursesUI.cpp zinf-2.2.5-new/ui/ncurses/ncursesUI.cpp +--- zinf-2.2.5/ui/ncurses/ncursesUI.cpp 2003-09-16 19:35:31.000000000 +0200 ++++ zinf-2.2.5-new/ui/ncurses/ncursesUI.cpp 2005-07-20 00:03:31.000000000 +0200 +@@ -32,6 +32,7 @@ + #include <termios.h> + #include <signal.h> + ++ + using namespace std; + #include "config.h" + #include "i18n.h" +@@ -41,6 +42,10 @@ + #include "thread.h" + #include "eventdata.h" + ++#ifdef HAVE_GLIB ++#include <glib.h> ++#endif ++ + #define stdinfd 0 + + extern "C" { +@@ -262,6 +267,40 @@ + + } + ++static int rccGetCurrentEncoding(char *result, unsigned int n) { ++ unsigned int i; ++ char *l; ++ ++ if ((!result)||(!n)) return -1; ++ ++ 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; ++ } ++ ++ l = setlocale(LC_CTYPE, NULL); ++ if (!l) return -1; ++ ++ for (i=0;((l[i])&&(l[i]!='.')&&(l[i]!='_'));i++); ++ if (i>=n) return -1; ++ ++ l = strrchr(l, '.'); ++ if (!l) return -1; ++ ++ for (i=0;((l[i])&&(l[i]!='@'));i++); ++ if (i>=n) return -1; ++ ++ strncpy(result,l+1,i-1); ++ result[i]=0; ++ ++ return 0; ++} ++ + Error ncursesUI::AcceptEvent(Event *e) { + if (e) { + switch (e->Type()) { +@@ -342,36 +381,69 @@ + break; + md = pItem->GetMetaData(); + ++ char *recoded; ++ char locale[64]; ++#ifdef HAVE_GLIB ++ if (rccGetCurrentEncoding(locale, 64)) strcpy(locale, "UTF-8"); ++#else ++ recoded = NULL; ++#endif ++ ++ + clear(); + move(0,0); + showInfo(); + move(2, 0); + addstr(_("Title : ")); +- if (md.Title().c_str()[0] != '\0') +- addstr((char *)md.Title().c_str()); +- else ++ if (md.Title().c_str()[0] != '\0') { ++#ifdef HAVE_GLIB ++ recoded = g_convert(md.Title().c_str(), -1, locale, "UTF-8", NULL, NULL, NULL); ++#endif ++ addstr(recoded?recoded:(char *)md.Title().c_str()); ++ } else + addstr(pmvi->m_filename.c_str()); ++ ++#ifdef HAVE_GLIB ++ if (recoded) free(recoded); ++ recoded = g_convert(md.Artist().c_str(), -1, locale, "UTF-8", NULL, NULL, NULL); ++#endif + addstr(_("\nArtist : ")); +- addstr((char *)md.Artist().c_str()); ++ addstr(recoded?recoded:(char *)md.Artist().c_str()); ++#ifdef HAVE_GLIB ++ if (recoded) free(recoded); ++ recoded = g_convert(md.Album().c_str(), -1, locale, "UTF-8", NULL, NULL, NULL); ++#endif + addstr(_("\nAlbum : ")); +- addstr((char *)md.Album().c_str()); ++ addstr(recoded?recoded:(char *)md.Album().c_str()); + addstr(_("\nYear : ")); + if (md.Year() != 0) + { + sprintf(buf, "%d", md.Year()); + addstr(buf); + } ++#ifdef HAVE_GLIB ++ if (recoded) free(recoded); ++ recoded = g_convert(md.Genre().c_str(), -1, locale, "UTF-8", NULL, NULL, NULL); ++#endif + addstr(_("\nGenre : ")); +- addstr((char *)md.Genre().c_str()); ++ addstr(recoded?recoded:(char *)md.Genre().c_str()); + addstr(_("\nTrack : ")); + if (md.Track() != 0) + { + sprintf(buf, "%d", md.Track()); + addstr(buf); + } ++#ifdef HAVE_GLIB ++ if (recoded) free(recoded); ++ recoded = g_convert(md.Comment().c_str(), -1, locale, "UTF-8", NULL, NULL, NULL); ++#endif + addstr(_("\nComment: ")); +- addstr((char *)md.Comment().c_str()); ++ addstr(recoded?recoded:(char *)md.Comment().c_str()); + addstr("\n"); ++ ++#ifdef HAVE_GLIB ++ if (recoded) free(recoded); ++#endif + refresh(); + + counter = 0; |