r15412 - gnucash/trunk/src - Use g_getenv instead of getenv.

Andreas Köhler andi5 at cvs.gnucash.org
Sun Jan 21 17:11:35 EST 2007


Author: andi5
Date: 2007-01-21 17:11:34 -0500 (Sun, 21 Jan 2007)
New Revision: 15412
Trac: http://svn.gnucash.org/trac/changeset/15412

Modified:
   gnucash/trunk/src/backend/file/sixtp-utils.c
   gnucash/trunk/src/backend/file/test/test-load-example-account.c
   gnucash/trunk/src/backend/file/test/test-load-xml2.c
   gnucash/trunk/src/backend/file/test/test-save-in-lang.c
   gnucash/trunk/src/backend/file/test/test-xml2-is-file.c
   gnucash/trunk/src/bin/gnucash-bin.c
   gnucash/trunk/src/gnc-module/gnc-module.c
   gnucash/trunk/src/import-export/qif/test/test-qif.c
Log:
Use g_getenv instead of getenv.

getenv returns the pure bytes, whereas g_getenv converts the value to
the GLib filename encoding, i.e. UTF-8 on Windows. Also use TRUE instead
of 1 as overwrite argument to g_setenv.


Modified: gnucash/trunk/src/backend/file/sixtp-utils.c
===================================================================
--- gnucash/trunk/src/backend/file/sixtp-utils.c	2007-01-21 19:32:59 UTC (rev 15411)
+++ gnucash/trunk/src/backend/file/sixtp-utils.c	2007-01-21 22:11:34 UTC (rev 15412)
@@ -388,16 +388,17 @@
   time_t result;
   char *old_tz;
 
-  old_tz = getenv ("TZ");
+  old_tz = g_strdup(g_getenv ("TZ"));
   /* FIXME: there's no way to report this error to the caller. */
-  if (!g_setenv("TZ", "UTC", 1))
+  if (!g_setenv("TZ", "UTC", TRUE))
     PERR ("couldn't switch the TZ.");
   result = mktime (tm);
   if(old_tz)
   {
     /* FIXME: there's no way to report this error to the caller. */
-    if (!g_setenv("TZ", old_tz, 1))
+    if (!g_setenv("TZ", old_tz, TRUE))
       PERR ("couldn't switch the TZ back.");
+    g_free(old_tz);
   }
   else
   {

Modified: gnucash/trunk/src/backend/file/test/test-load-example-account.c
===================================================================
--- gnucash/trunk/src/backend/file/test/test-load-example-account.c	2007-01-21 19:32:59 UTC (rev 15411)
+++ gnucash/trunk/src/backend/file/test/test-load-example-account.c	2007-01-21 22:11:34 UTC (rev 15412)
@@ -66,7 +66,7 @@
 static void
 guile_main (void *closure, int argc, char **argv)
 {
-    const char *location = getenv("GNC_ACCOUNT_PATH");
+    const char *location = g_getenv("GNC_ACCOUNT_PATH");
     GSList *list = NULL;
     GDir *ea_dir;
     QofBook *book;

Modified: gnucash/trunk/src/backend/file/test/test-load-xml2.c
===================================================================
--- gnucash/trunk/src/backend/file/test/test-load-xml2.c	2007-01-21 19:32:59 UTC (rev 15411)
+++ gnucash/trunk/src/backend/file/test/test-load-xml2.c	2007-01-21 22:11:34 UTC (rev 15412)
@@ -85,7 +85,7 @@
 
     remove_locks(filename);
 
-    ignore_lock = (safe_strcmp(getenv("SRCDIR"), ".") != 0);
+    ignore_lock = (safe_strcmp(g_getenv("SRCDIR"), ".") != 0);
     qof_session_begin(session, filename, ignore_lock, FALSE);
 
     qof_session_load(session, NULL);
@@ -106,7 +106,7 @@
 int
 main (int argc, char ** argv)
 {
-    const char *location = getenv("GNC_TEST_FILES");
+    const char *location = g_getenv("GNC_TEST_FILES");
     GDir *xml2_dir;
 
     g_type_init();

Modified: gnucash/trunk/src/backend/file/test/test-save-in-lang.c
===================================================================
--- gnucash/trunk/src/backend/file/test/test-save-in-lang.c	2007-01-21 19:32:59 UTC (rev 15411)
+++ gnucash/trunk/src/backend/file/test/test-save-in-lang.c	2007-01-21 22:11:34 UTC (rev 15412)
@@ -93,8 +93,8 @@
             return g_strdup_printf("qof_session_load errorid %d", err);
         }
 
-        if (!g_setenv("LANG", possible_envs[i], 1))
-          return g_strdup_printf("setenv for LANG");
+        if (!g_setenv("LANG", possible_envs[i], TRUE))
+          return g_strdup("setenv for LANG");
 
         new_session = qof_session_new();
         
@@ -165,7 +165,7 @@
                 break;
             }
 
-            if (!g_setenv("LANG", base_env, 1))
+            if (!g_setenv("LANG", base_env, TRUE))
             {
               failure_args("setenv", __FILE__, __LINE__,
                            "setenv of LANG failed");

Modified: gnucash/trunk/src/backend/file/test/test-xml2-is-file.c
===================================================================
--- gnucash/trunk/src/backend/file/test/test-xml2-is-file.c	2007-01-21 19:32:59 UTC (rev 15411)
+++ gnucash/trunk/src/backend/file/test/test-xml2-is-file.c	2007-01-21 22:11:34 UTC (rev 15412)
@@ -13,7 +13,7 @@
 int
 main(int argc, char **argv)
 {
-    const char *directory = getenv("GNC_TEST_FILES");
+    const char *directory = g_getenv("GNC_TEST_FILES");
     char *filename;
 
     if (!directory)

Modified: gnucash/trunk/src/bin/gnucash-bin.c
===================================================================
--- gnucash/trunk/src/bin/gnucash-bin.c	2007-01-21 19:32:59 UTC (rev 15411)
+++ gnucash/trunk/src/bin/gnucash-bin.c	2007-01-21 22:11:34 UTC (rev 15412)
@@ -96,14 +96,14 @@
 static void
 envt_override()
 {
-    char *path;
+    const char *path;
     
-    if ((path = getenv("GNC_CONFIG_PATH")))
-        config_path = path;
-    if ((path = getenv("GNC_SHARE_PATH")))
-        share_path = path;
-    if ((path = getenv("GNC_DOC_PATH")))
-        help_path = path;
+    if ((path = g_getenv("GNC_CONFIG_PATH")))
+        config_path = g_strdup(path);
+    if ((path = g_getenv("GNC_SHARE_PATH")))
+        share_path = g_strdup(path);
+    if ((path = g_getenv("GNC_DOC_PATH")))
+        help_path = g_strdup(path);
 }
 
 static gboolean

Modified: gnucash/trunk/src/gnc-module/gnc-module.c
===================================================================
--- gnucash/trunk/src/gnc-module/gnc-module.c	2007-01-21 19:32:59 UTC (rev 15411)
+++ gnucash/trunk/src/gnc-module/gnc-module.c	2007-01-21 22:11:34 UTC (rev 15412)
@@ -46,11 +46,11 @@
 static GList * 
 gnc_module_system_search_dirs(void) 
 {
-  char  * spath   = getenv("GNC_MODULE_PATH");
+  const char *spath = g_getenv("GNC_MODULE_PATH");
   GList * list    = NULL;
   GString * token = g_string_new(NULL);
   int   escchar   = 0;
-  char  * cpos;
+  const char *cpos;
 
   if(!spath) 
   {
@@ -127,14 +127,10 @@
 
   if(dirs)
   {
-    char *envt = getenv("LD_LIBRARY_PATH");
+    char *envt = g_strdup(g_getenv("LD_LIBRARY_PATH"));
     
-    if(envt)
+    if(!envt)
     {
-      envt = g_strdup(envt);
-    }
-    else
-    {
       envt = g_strdup("");
     }
     
@@ -147,7 +143,7 @@
     }
     g_list_free(dirs);
     
-    if (!g_setenv("LD_LIBRARY_PATH", envt, 1))
+    if (!g_setenv("LD_LIBRARY_PATH", envt, TRUE))
     {
       g_warning ("gnc-module failed to set LD_LIBRARY_PATH");
     }

Modified: gnucash/trunk/src/import-export/qif/test/test-qif.c
===================================================================
--- gnucash/trunk/src/import-export/qif/test/test-qif.c	2007-01-21 19:32:59 UTC (rev 15411)
+++ gnucash/trunk/src/import-export/qif/test/test-qif.c	2007-01-21 22:11:34 UTC (rev 15412)
@@ -60,7 +60,7 @@
 {
   QifContext ctx, file;
   char *filename;
-  const char *location = getenv("GNC_TEST_FILES");
+  const char *location = g_getenv("GNC_TEST_FILES");
   int i;
 
   ctx = qif_context_new();



More information about the gnucash-changes mailing list