Re: [Freeciv-Dev] GTK-client and snprintf
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
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);
}
|
|