Complete.Org: Mailing Lists: Archives: freeciv-dev: May 1999:
Re: [Freeciv-Dev] GTK-client and snprintf
Home

Re: [Freeciv-Dev] GTK-client and snprintf

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: Re: [Freeciv-Dev] GTK-client and snprintf
From: David Pfitzner <dwp@xxxxxxxxxxxxxx>
Date: Sat, 15 May 1999 16:29:46 +1000 (EST)

On Tue, 11 May 1999 Heikki Kantola <hezu@xxxxxx> wrote:

> There appears to be one portability issue in the GTK-client code: it
> requires snprintf-function, which unfortunately isn't available on
> every platform

Since we don't yet have a replacement snprintf
(though in the long term it would be good to do so)
and since I notice the current use of snprintf is 
actually very limited, the attached patch fixes the
above portability problem (thanks to Reinier Post 
for the idea).

I think this should do the right thing, safely, and 
work on all appropriate platforms. (?)

(I _think_ the specifier should be %.63s and not %.64s.)

Regards,
-- David
diff -u -r --exclude-from exclude freeciv-cvs/client/gui-gtk/clinet.c 
freeciv-mod/client/gui-gtk/clinet.c
--- freeciv-cvs/client/gui-gtk/clinet.c Wed May 12 21:33:11 1999
+++ freeciv-mod/client/gui-gtk/clinet.c Sat May 15 16:14:53 1999
@@ -278,12 +278,12 @@
       GET_FIELD(players);
       GET_FIELD(metastring);
 
-      snprintf(row[0], 64, "%s", name);
-      snprintf(row[1], 64, "%s", port);
-      snprintf(row[2], 64, "%s", version);
-      snprintf(row[3], 64, "%s", status);
-      snprintf(row[4], 64, "%s", players);
-      snprintf(row[5], 64, "%s", metastring);
+      sprintf(row[0], "%.63s", name);
+      sprintf(row[1], "%.63s", port);
+      sprintf(row[2], "%.63s", version);
+      sprintf(row[3], "%.63s", status);
+      sprintf(row[4], "%.63s", players);
+      sprintf(row[5], "%.63s", metastring);
 
       gtk_clist_append(GTK_CLIST(list), row);
     }

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