Репозиторий ALT Linux backports/2.4
Последнее обновление: 9 июля 2008 | Пакетов: 497 | Посещений: 1576321
 поиск   регистрация   авторизация 
 
Группа :: Графические оболочки/Icewm
Пакет: icewm

 Главная   Изменения   Спек   Патчи   Загрузить   Bugs and FR 

Патч: icewm-LANG.menu.patch


--- icewm-orig/src/yapp.cc	2004-05-23 08:18:19.000000000 +0200
+++ icewm-1.2.14/src/yapp.cc	2004-08-05 13:56:31.000000000 +0200
@@ -61,23 +61,68 @@
     return findConfigFile(name, R_OK);
 }
 
+static char *access_ok(char *name, int n_locale_suffixes, char **locale_suffixes, int mode)
+{
+     int i;
+     char *p;
+     for(i=0; i<n_locale_suffixes-1; i++) {
+        p = strJoin(name, ".", locale_suffixes[i], NULL);
+         if (access(p, mode) == 0) {
+             delete name;
+              return p;
+        }
+        delete p;
+     }
+     if (access(name, mode) == 0) return name;
+     delete name;
+     return 0;
+}
+
+#include <locale.h>
+#include <string.h>
+
 char *YApplication::findConfigFile(const char *name, int mode) {
     char *p;
+    static char *locale_suffixes[3];
+    static int n_locale_suffixes = -1;
+    static char *locale;
+    if (n_locale_suffixes < 0) {
+	locale = setlocale(LC_MESSAGES, NULL);
+	n_locale_suffixes = 0;
+       if (strcmp(locale, "C") && strcmp(locale, "POSIX")) {
+           locale = strdup(locale);
+           p = strchr(locale, '@');
+           if (p) {
+               *p = 0;
+           }
+           p = strchr (locale, '.');
+           if (p) {
+               locale_suffixes[n_locale_suffixes++] = strdup(locale);
+               *p = 0;
+           }
+           p = strchr(locale, '_');
+           if (p) {
+               locale_suffixes[n_locale_suffixes++] = strdup(locale);
+               *p = 0;
+           }
+           locale_suffixes[n_locale_suffixes++] = strdup(locale);
+       }
+    }
 
     if (name[0] == '/')
         return newstr(name);
 
     p = strJoin(getPrivConfDir(), "/", name, NULL);
-    if (access(p, mode) == 0) return p;
-    delete[] p;
+    p = access_ok(p, n_locale_suffixes, locale_suffixes, mode);
+    if (p) return p;    
 
     p = strJoin(configDir, "/", name, NULL);
-    if (access(p, mode) == 0) return p;
-    delete[] p;
+    p = access_ok(p, n_locale_suffixes, locale_suffixes, mode);
+    if (p) return p;
 
     p = strJoin(REDIR_ROOT(libDir), "/", name, NULL);
-    if (access(p, mode) == 0) return p;
-    delete[] p;
+    p = access_ok(p, n_locale_suffixes, locale_suffixes, mode);
+    if (p) return p;
 
     return 0;
 }
 
design & coding: Vladimir Lettiev aka crux © 2004-2005