<URL: http://bugs.freeciv.org/Ticket/Display.html?id=40028 >
> [jdorje - Sun Jan 27 22:16:24 2008]: > > Here is a quick and partial fix. I assume that strerror() is one of the > most common offending functions, so I quickly went through and converted > all mystrerror users in client/ and server/ directories to use the > newly-written L_(). The only real issue with it is the use of > fixed-sized buffers which are wasteful if too large and broken if too > small, but as I said in my previous message I see no real alternative here. Might I suggest that instead of wrapping every call to mystrerror with L, you instead call L inside mysterror (and of course document that mystrerror does the conversion)? Or make a "mystrerror_l" that does this (to keep mysterror for the cases that shouldn't be converted). It would make your patch much simpler. I agree in general with your reservations about fixed size buffers, but I think that in this case it is acceptable to used them because: 1. It is very unlikey that any strerror message is longer than 256 characters (I have looked at _sys_errlist_internal in libc and that is the case, I assume it is very probably so on other platforms). 2. Strerror is not re-entrant (e.g. thread-safe) anyway (we would need to use strerror_r for that). 3. It is very unlikely that someone will need to call mysterror twice in the same expression (e.g. more than once in a printf-like call). Hence a fixed static buffer inside mystrerror (or mysterror_l) to hold the converted text would be an acceptable solution in this case, in my opinion. > Madeline, if you can test this and verify it fixes those strings then at > least we'll know we're getting somewhere. It would also be helpful if > you'd point out to us what other strings are being handled wrongly. All the "corrupted" strings that I had found previously now display correctly (and no gtk warnings appear) with your patch applied. I cannot of course guarantee that that is all of them. ;) > It is important to recognize which strings go in which encoding. If you > use printf() directly your strings must be in the local encoding. More > commonly freelog or fc_fprintf is used and these functions expect > strings in the internal encoding. Generally all freeciv functions > should expect the internal encoding unless specifically documented > otherwise. > > Also as a side note there's another library we use, lua. Strings from > LUA are probably in the local encoding so should use L_ too. I agree with you on those points. _______________________________________________ Freeciv-dev mailing list [email protected] https://mail.gna.org/listinfo/freeciv-dev
