Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2004:
[Freeciv-Dev] (PR#10149) gtk2 invalid utf8 string
Home

[Freeciv-Dev] (PR#10149) gtk2 invalid utf8 string

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#10149) gtk2 invalid utf8 string
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 21 Sep 2004 20:18:32 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=10149 >

> [jdorje - Thu Sep 16 20:26:27 2004]:
> 
> ** (civclient:20820): WARNING **: Invalid UTF8 string passed to 
> pango_layout_set_text()
> 
> I get this when opening the city report.
> 
> I tried running with --g-fatal-warnings but the backtrace was really 
> long and useless-looking.

In this case the error is in cr_entry_cityname in cityrepdata.c.  The
name is truncated to 14 bytes and the 15th byte is changed to '.'. 
Probably this is supposed to help things fit in gui-xaw (it's not needed
in gtk).  But it will clearly not work.  It borks on one of the names in
the Hungarian ruleset.

This patch simply removes the truncation.

jason

Index: client/cityrepdata.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/cityrepdata.c,v
retrieving revision 1.37
diff -u -r1.37 cityrepdata.c
--- client/cityrepdata.c        13 Sep 2004 15:54:49 -0000      1.37
+++ client/cityrepdata.c        22 Sep 2004 02:57:35 -0000
@@ -39,15 +39,10 @@
 
 static const char *cr_entry_cityname(const struct city *pcity)
 {
-  static char buf[REPORT_CITYNAME_ABBREV+1];
-  if (strlen(pcity->name) <= REPORT_CITYNAME_ABBREV) {
-    return pcity->name;
-  } else {
-    strncpy(buf, pcity->name, REPORT_CITYNAME_ABBREV-1);
-    buf[REPORT_CITYNAME_ABBREV-1] = '.';
-    buf[REPORT_CITYNAME_ABBREV] = '\0';
-    return buf;
-  }
+  /* We used to truncate the name to 14 bytes.  This should not be needed
+   * in any modern GUI library and may give an invalid string if a
+   * multibyte character is clipped. */
+  return pcity->name;
 }
 
 static const char *cr_entry_size(const struct city *pcity)
Index: client/cityrepdata.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/cityrepdata.h,v
retrieving revision 1.11
diff -u -r1.11 cityrepdata.h
--- client/cityrepdata.h        4 Sep 2004 18:39:38 -0000       1.11
+++ client/cityrepdata.h        22 Sep 2004 02:57:35 -0000
@@ -17,9 +17,6 @@
 
 #include "fc_types.h"
 
-/* abbreviate long city names to this length in the city report: */
-#define REPORT_CITYNAME_ABBREV 15
-
 /* Number of city report columns: have to set this manually now... */
 #define NUM_CREPORT_COLS 33
 

[Prev in Thread] Current Thread [Next in Thread]