[Freeciv-Dev] Re: (PR#10265) GTK/win32 left panel missing some informati
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=10265 >
Jason Short wrote:
> <URL: http://bugs.freeciv.org/Ticket/Display.html?id=10265 >
>
>>[rbk@xxxxxx - Mon Mar 21 08:30:11 2005]:
>>
>>Hello
>> I'd like to report you a bug in the sidebar game information pane.
>>When I start a game and make first movement with explorer, it looks OK
>>(game-start.jpg). After I build first city and commit it's name, game
>>information pane collapses (game-first-city.jpg) and there is no way to
>>restore it. This bug shows on all computers I have access to, on Linux
>>(Debian testing) as well as on Windows XP. I can't find this bug on
>>bugs.freeciv.org; I can provide more informations if you request to.
>
>
> I can't reproduce this on debian unstable. What $LANG or locale do you use?
And, can you test if this patch fixes it?
-jason
Index: utility/fciconv.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/utility/fciconv.c,v
retrieving revision 1.12
diff -u -r1.12 fciconv.c
--- utility/fciconv.c 1 Dec 2004 22:15:23 -0000 1.12
+++ utility/fciconv.c 23 Mar 2005 06:00:48 -0000
@@ -318,6 +318,8 @@
CONV_FUNC_MALLOC(internal, local)
CONV_FUNC_MALLOC(local, internal)
+CONV_FUNC_BUFFER(local, internal)
+
static CONV_FUNC_BUFFER(internal, local)
static CONV_FUNC_STATIC(internal, local)
Index: utility/fciconv.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/utility/fciconv.h,v
retrieving revision 1.9
diff -u -r1.9 fciconv.h
--- utility/fciconv.h 1 Dec 2004 22:15:23 -0000 1.9
+++ utility/fciconv.h 23 Mar 2005 06:00:48 -0000
@@ -31,6 +31,9 @@
char *internal_to_local_string_malloc(const char *text);
char *local_to_internal_string_malloc(const char *text);
+char *local_to_internal_string_buffer(const char *text,
+ char *buf, size_t bufsz);
+
#define fc_printf(...) fc_fprintf(stdout, __VA_ARGS__)
void fc_fprintf(FILE *stream, const char *format, ...)
fc__attribute((format (printf, 2, 3)));
Index: utility/shared.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/utility/shared.c,v
retrieving revision 1.128
diff -u -r1.128 shared.c
--- utility/shared.c 23 Mar 2005 05:51:07 -0000 1.128
+++ utility/shared.c 23 Mar 2005 06:00:49 -0000
@@ -67,9 +67,10 @@
"~/.freeciv"
#endif
+/* Both of these are stored in the local encoding. The grouping_sep must
+ * be converted to the internal encoding when it's used. */
static char *grouping = NULL;
static char *grouping_sep = NULL;
-static size_t grouping_sep_len = 0;
/***************************************************************
Take a string containing multiple lines and create a copy where
@@ -293,6 +294,14 @@
char *grp = grouping;
char *ptr;
unsigned int cnt = 0;
+ char sep[64];
+ size_t seplen;
+
+ /* We have to convert the encoding here (rather than when the locale
+ * is initialized) because it can't be done before the charsets are
+ * initialized. */
+ local_to_internal_string_buffer(grouping_sep, sep, sizeof(sep));
+ seplen = strlen(sep);
#if 0 /* Not needed while the values are unsigned. */
assert(mantissa >= 0);
@@ -311,9 +320,9 @@
while (mantissa != 0 && exponent >= 0) {
int dig;
- if (ptr <= buf + grouping_sep_len) {
+ if (ptr <= buf + seplen) {
/* Avoid a buffer overflow. */
- assert(ptr > buf + grouping_sep_len);
+ assert(ptr > buf + seplen);
return ptr;
}
@@ -336,9 +345,9 @@
least 421-bit ints to break the 127 digit barrier, but why not. */
break;
}
- ptr -= grouping_sep_len;
+ ptr -= seplen;
assert(ptr >= buf);
- memcpy(ptr, grouping_sep, grouping_sep_len);
+ memcpy(ptr, sep, seplen);
if (*(grp + 1) != 0) {
/* Zero means to repeat the present group-size indefinitely. */
grp++;
@@ -1196,7 +1205,6 @@
*/
grouping = mystrdup("\3");
grouping_sep = mystrdup(",");
- grouping_sep_len = strlen(grouping_sep);
#ifdef ENABLE_NLS
#ifdef WIN32_NATIVE
@@ -1255,7 +1263,6 @@
(void) bindtextdomain(PACKAGE, LOCALEDIR);
(void) textdomain(PACKAGE);
-#ifndef WIN32_NATIVE /* Some windows locales are buggy */
/* Don't touch the defaults when LC_NUMERIC == "C".
This is intended to cater to the common case where:
1) The user is from North America. ;-)
@@ -1285,10 +1292,8 @@
}
free(grouping_sep);
grouping_sep = mystrdup(lc->thousands_sep);
- grouping_sep_len = strlen(grouping_sep);
}
#endif
-#endif
}
/***************************************************************************
|
|