Re: [Freeciv-Dev] (PR#40058) mystrerror() and local encoding
http://bugs.freeciv.org/Ticket/Display.html?id=40058 > Jason Short wrote: > Patch is fine but the comment is a bit misleading - generally the > returned value is passed off to GTK which wants it in UTF-8 (aka the > internal encoding). When used in the server this may not be the case. > Changed comment to: + The string is converted as necessary from the local_encoding + to internal_encoding, for inclusion in translations. May be + subsequently converted back to local_encoding for display. Even in the server, it will *always* be passed to either freelog() or some other *my* variant of printf(). ALL OF THEM need to use internal encoding, not some other encoding. Otherwise, we'd have a lot more bug reports. Anything else -- bare printf() to stderror -- is a bug. Unfortunately, there are ~170 bare printf remaining, mostly in gui-sdl, gui-ftwl, and lua. Oh well, another bug for another ticket (each). Anyway, since it's confirmed: Committed S2_1 revision 14342. Committed S2_2 revision 14343. Committed trunk revision 14344. ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] (PR#40058) mystrerror() and local encoding
http://bugs.freeciv.org/Ticket/Display.html?id=40058 > > [jdorje - Tue Jan 29 02:02:12 2008]: > > Patch is fine but the comment is a bit misleading - generally the > returned value is passed off to GTK which wants it in UTF-8 (aka the > internal encoding). When used in the server this may not be the case. Hence my previous suggestion that there could be mystrerror (no re-encode) and mystrerror_utf8 (or with some other descriptive suffix). The former to be used e.g. in the the server where the error messages are generally printed to the console, and the latter for gtk or other libraries that expect only utf8. > > A similar patch should then work for the strsockerror function. What I did for the warclient codebase is to factor out the common code from mystrerror and mystrsocketerror (really only one line difference between the two functions) into a helper function get_errno_string(bool is_socket_error) (if you really really want to see: http://svn.gna.org/viewcvs/freeciv-warclient?rev=983&view=rev). I do wonder now if I was not a bit hasty in that by making the return value of mystr*error always in internal encoding (i.e. utf8), there might now be "garbage" strings appearing in server error messages printed to the console for systems that do not expect utf8 in that place... ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] (PR#40058) mystrerror() and local encoding
http://bugs.freeciv.org/Ticket/Display.html?id=40058 > Patch is fine but the comment is a bit misleading - generally the returned value is passed off to GTK which wants it in UTF-8 (aka the internal encoding). When used in the server this may not be the case. A similar patch should then work for the strsockerror function. -jason ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
[Freeciv-Dev] (PR#40058) mystrerror() and local encoding
http://bugs.freeciv.org/Ticket/Display.html?id=40058 > > [wsimpson - Mon Jan 28 13:42:20 2008]: > > 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? It appears to work well, there are no corrupted messages or gtk warnings. ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev
Re: [Freeciv-Dev] (PR#40058) mystrerror() and local encoding
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 #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
[Freeciv-Dev] (PR#40058) mystrerror() and local encoding
http://bugs.freeciv.org/Ticket/Display.html?id=40058 > Followup of PR#40028. See earlier patch and objections there. ___ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev