Author: cazfi
Date: Mon Feb  2 04:47:30 2015
New Revision: 27931

URL: http://svn.gna.org/viewcvs/freeciv?rev=27931&view=rev
Log:
Fixed sdl2-client create_new_line_utf8strs() to return correct, NULL terminated,
number of strings.

See patch #5768

Modified:
    branches/S2_6/client/gui-sdl2/utf8string.c

Modified: branches/S2_6/client/gui-sdl2/utf8string.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-sdl2/utf8string.c?rev=27931&r1=27930&r2=27931&view=diff
==============================================================================
--- branches/S2_6/client/gui-sdl2/utf8string.c  (original)
+++ branches/S2_6/client/gui-sdl2/utf8string.c  Mon Feb  2 04:47:30 2015
@@ -63,7 +63,7 @@
   size_t len = 0, count = 0;
 
   while (*start != '\0') {
-    if (*pstr == '\n' || *pstr == '\0') { /* find a new line char */
+    if (*pstr == '\n') { /* find a new line char */
       if (len) {
         buf[count] = fc_calloc(len + 1, 1);
         memcpy(buf[count], start, len);
@@ -80,9 +80,15 @@
 
     pstr++;
 
-    if ((*pstr == 0) && len) {
-      buf[count] = fc_calloc(len + 1, 1);
-      memcpy(buf[count], start, len);
+    if (*pstr == '\0') {
+      if (len != 0) {
+        buf[count] = fc_calloc(len + 1, 1);
+        memcpy(buf[count], start, len);
+        count++;
+      }
+
+      buf[count] = NULL;
+      start = pstr;
     }
   }
 


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to