Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37857730
en ru br
Репозитории ALT
S:3.4.2-alt1
5.1: 1.2.38pre1-alt1
4.1: 1.2.35-alt2.1
4.0: 1.2.32-alt2.1
3.0: 1.2.23-alt1
+backports:1.2.30-alt1.M30.1
www.altlinux.org/Changes

Группа :: Графические оболочки/Icewm
Пакет: icewm

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

Патч: icewm-alt-locale.patch
Скачать


 icewm/src/yapp.cc |   57 +++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 51 insertions(+), 6 deletions(-)
diff --git a/icewm/src/yapp.cc b/icewm/src/yapp.cc
index 63afc92..37519b8 100644
--- a/icewm/src/yapp.cc
+++ b/icewm/src/yapp.cc
@@ -61,23 +61,68 @@ char *YApplication::findConfigFile(const char *name) {
     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;
 }
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin