Enlightenment CVS committal

Author  : andreas99
Project : e16
Module  : tools

Dir     : e16/tools/e16menuedit2/src


Modified Files:
        file.c file.h 


Log Message:
- changed locale handling again (I hope it's better now)
- fixed this dirty bug that crashed e16menuedit2 often while opening help

===================================================================
RCS file: /cvsroot/enlightenment/e16/tools/e16menuedit2/src/file.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -3 -r1.12 -r1.13
--- file.c      11 Dec 2004 09:04:17 -0000      1.12
+++ file.c      20 Dec 2004 20:22:40 -0000      1.13
@@ -372,13 +372,22 @@
   gboolean spawn;
   gchar *argv_child[3];
   gchar *params;
-  char *locale;
-  char *locale_fallback;
+  char *locale = NULL;
+  gboolean locale_failed = FALSE;
+  char *locale_fallback = NULL;
   char *locale_tmp;
   gboolean help_missing = TRUE;
   struct stat buf;
 
-  locale = getenv ("LANG");
+  /* Is there a better way to get the users current language? */
+  locale = setlocale (LC_MESSAGES, NULL);
+  
+  /* If no locale is available use 'C' and free it later */
+  if (!locale)
+  {
+    locale_failed = TRUE;
+    locale = g_strdup_printf ("C");
+  }
   
   params = g_strdup_printf ("%s/%s/%s", help_dir,
                             locale, help_file);
@@ -418,17 +427,22 @@
       if (help_missing)
       {
         locale_tmp = strdup (locale_fallback);
-        g_free (locale_fallback);
+       g_free (locale_fallback);
         locale_fallback = get_fallback_locale (locale_tmp);
         g_free (locale_tmp);
         g_free (params);
         params = g_strdup_printf ("%s/%s/%s", help_dir,
                                   locale_fallback, help_file);
+       g_free (locale_fallback);
        #ifdef DEBUG
         DEBUG_OUTPUT printf ("Try help fallback4: %s\n", params);
         #endif /* DEBUG */  
         help_missing = stat (params, &buf);
       }
+      else
+      {
+       g_free (locale_fallback);
+      }
     }
   }
 
@@ -457,10 +471,11 @@
       return 2;
     }
 
-    //g_free (argv_child[0]);
     g_free (params);
-    g_free (locale_fallback);
   }
 
+  if (locale_failed)
+    g_free (locale);
+
   return 0;
 }
===================================================================
RCS file: /cvsroot/enlightenment/e16/tools/e16menuedit2/src/file.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -3 -r1.8 -r1.9
--- file.h      5 Dec 2004 13:19:48 -0000       1.8
+++ file.h      20 Dec 2004 20:22:40 -0000      1.9
@@ -41,6 +41,7 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <locale.h>
+#include <langinfo.h>
 #include "e16menuedit2.h"
 
 char *field (char *s, int field);




-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to