[Tux4kids-commits] r840 - tuxtype/trunk/src

dbruce-guest at alioth.debian.org dbruce-guest at alioth.debian.org
Mon Jan 12 13:29:26 UTC 2009


Author: dbruce-guest
Date: 2009-01-12 13:29:26 +0000 (Mon, 12 Jan 2009)
New Revision: 840

Modified:
   tuxtype/trunk/src/mysetenv.c
Log:
Windows i18n work - success! (mostly)



Modified: tuxtype/trunk/src/mysetenv.c
===================================================================
--- tuxtype/trunk/src/mysetenv.c	2009-01-12 01:30:09 UTC (rev 839)
+++ tuxtype/trunk/src/mysetenv.c	2009-01-12 13:29:26 UTC (rev 840)
@@ -1,16 +1,27 @@
-/* This file written by Bruno Haible and provided in GNU Gettext FAQ 
-   to help with difficulties using Gettext under Windows.            */
+/* This file was taken from example code in GNU Gettext FAQ 
 
+   http://www.gnu.org/software/gettext/FAQ.html
+
+   by Bruno Haible. No copyright or license is mentioned in
+   the FAQ, but the text clearly supplies this code
+   to help with difficulties using Gettext under Windows.   */
+
+#include "config.h"
+
+#include <stdio.h>
 #include <string.h>
- #include <stdlib.h>
- #if defined _WIN32
- # include <windows.h>
- #endif
+#include <stdlib.h>
+
+#ifdef WIN32
+#include <windows.h>
+#endif
  
- int my_setenv (const char * name, const char * value) {
+int my_setenv (const char * name, const char * value)
+{
    size_t namelen = strlen(name);
    size_t valuelen = (value==NULL ? 0 : strlen(value));
- #if defined _WIN32
+
+#ifdef WIN32
    /* On Woe32, each process has two copies of the environment variables,
       one managed by the OS and one managed by the C library. We set
       the value in both locations, so that other software that looks in
@@ -19,10 +30,16 @@
       <http://article.gmane.org/gmane.comp.gnu.mingw.user/8272>
       <http://article.gmane.org/gmane.comp.gnu.mingw.user/8273>
       <http://www.cygwin.com/ml/cygwin/1999-04/msg00478.html> */
+
    if (!SetEnvironmentVariableA(name,value))
-     return -1; 
- #endif
- #if defined(HAVE_PUTENV)
+   {   
+     fprintf(stderr, "Warning - SetEnvironmentVariableA(%s, %s) failed.\n",
+             name, value);
+   }
+#endif
+
+#ifdef HAVE_PUTENV
+  {
    char* buffer = (char*)malloc(namelen+1+valuelen+1);
    if (!buffer)
      return -1; /* no need to set errno = ENOMEM */
@@ -34,10 +51,15 @@
    } else
      buffer[namelen] = 0;
    return putenv(buffer);
- #elif defined(HAVE_SETENV)
+  }
+
+#else
+#ifdef HAVE_SETENV
    return setenv(name,value,1);
- #else
+#else
    /* Uh oh, neither putenv() nor setenv() ... */
+   fprintf(stderr, "my_setenv() - neither HAVE_PUTENV nor HAVE_SETENV defined\n");
    return -1;
- #endif
- }
+#endif
+#endif
+}




More information about the Tux4kids-commits mailing list