Sophie

Sophie

distrib > Mandriva > mes5 > i586 > by-pkgid > 215eb530f6c7d644cc7731602ddc5e81 > files > 7

nedit-5.5-6mdv2008.1.src.rpm

--- nedit-5.5/source/nedit.c.utf8	2004-09-02 04:49:56.000000000 -0400
+++ nedit-5.5/source/nedit.c	2005-02-24 07:38:45.213885019 -0500
@@ -90,6 +90,7 @@ static int checkDoMacroArg(const char *m
 static String neditLanguageProc(Display *dpy, String xnl, XtPointer closure);
 static void maskArgvKeywords(int argc, char **argv, const char **maskArgs);
 static void unmaskArgvKeywords(int argc, char **argv, const char **maskArgs);
+static void changeLocaleIfUTF8(void);
 static void patchResourcesForVisual(void);
 static void patchResourcesForKDEbug(void);
 static void patchLocaleForMotif(void);
@@ -392,6 +393,8 @@ int main(int argc, char **argv)
     /* Save the command which was used to invoke nedit for restart command */
     ArgV0 = argv[0];
 
+    changeLocaleIfUTF8();
+
     /* Set locale for C library, X, and Motif input functions. 
        Reverts to "C" if requested locale not available. */
     XtSetLanguageProc(NULL, neditLanguageProc, NULL);
@@ -1035,6 +1038,32 @@ static String neditLanguageProc(Display 
     return setlocale(LC_ALL, NULL); /* re-query in case overwritten */
 }
 
+ static void changeLocaleIfUTF8(void)
+{
+    char *locale;
+
+    locale = getenv("LANG");
+    if (!locale) {
+        locale = setlocale(LC_ALL, NULL);
+    }
+    
+    if (locale) {
+        char *ptr;
+
+        ptr = strstr(locale, ".UTF-8");
+        if (ptr) {
+            fprintf(stderr, "nedit: the current locale is utf8 (%s)\n", locale);
+
+            ptr[0] = '\0';
+
+            setenv("LC_ALL", locale, 1);
+            locale = setlocale(LC_ALL, locale);
+    	
+            fprintf(stderr, "nedit: changed locale to non-utf8 (%s)\n", locale);
+        }
+    }
+}
+
 static int sortAlphabetical(const void* k1, const void* k2)
 {
     const char* key1 = *(const char**)k1;