<URL: http://bugs.freeciv.org/Ticket/Display.html?id=40058 >

After much discussion, here's the simpler version.

Examining the actual mystrerror() code, it appears that there are already
WIN32_NATIVE and other variants that are non-reentrant.  The reentrant
version should be separate (as it is on most platforms).

Examining the actual mystrerror() calls (43), ~28 are freelog() parameters.
There should be no need for recursion, but there is a clear need for
conversion to internal_encoding.

This also adds explanatory comments to the header.

Madeline, as you are the only one with problems, could you please test?

Index: utility/support.c
===================================================================
--- utility/support.c   (revision 14336)
+++ utility/support.c   (working copy)
@@ -82,6 +82,7 @@
 #  include <strings.h>
 #endif
 
+#include "fciconv.h"
 #include "fcintl.h"
 #include "mem.h"
 #include "netintf.h"
@@ -191,6 +192,11 @@
 
 /***************************************************************
   Return a string which describes a given error (errno-style.)
+  The string is converted as necessary from the local_encoding
+  to internal_encoding, for inclusion in internal translations
+  that are subsequently converted to local_encoding for display.
+
+  Note that this is not the reentrant form.
 ***************************************************************/
 const char *mystrerror(void)
 {
@@ -207,7 +213,10 @@
   return buf;
 #else
 #ifdef HAVE_STRERROR
-  return strerror(errno);
+  static char buf[256];
+
+  return local_to_internal_string_buffer(strerror(errno),
+                                         buf, sizeof(buf));
 #else
   static char buf[64];
 
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to