[Freeciv-Dev] (PR#8664) gettext and const char *'s
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=8664 >
> [jdorje - Tue May 04 04:56:57 2004]:
>
> We should probably treat every gettext-returned string as a const char *
> rather than a char *. (This may or may not relate to PR#8661.)
Here's a patch for the gtk2 client.
There was one place where a const char is passed to g_list_append. This
discards the const qualifier but is probably harmless. I didn't make
any changes to it.
jason
Index: client/gui-gtk-2.0/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/citydlg.c,v
retrieving revision 1.85
diff -u -r1.85 citydlg.c
--- client/gui-gtk-2.0/citydlg.c 5 May 2004 20:39:15 -0000 1.85
+++ client/gui-gtk-2.0/citydlg.c 8 May 2004 00:19:52 -0000
@@ -485,7 +485,7 @@
int i;
GtkWidget *hbox, *table, *label;
- static char *output_label[NUM_INFO_FIELDS] = { N_("Food:"),
+ static const char *output_label[NUM_INFO_FIELDS] = { N_("Food:"),
N_("Prod:"),
N_("Trade:"),
N_("Gold:"),
@@ -540,8 +540,7 @@
GtkWidget *frame, *table, *label, *sw, *view, *bar;
GtkCellRenderer *rend;
GtkListStore *store;
-
- char *tab_title = _("_Overview");
+ const char *tab_title = _("_Overview");
page = gtk_vbox_new(FALSE, 0);
gtk_container_set_border_width(GTK_CONTAINER(page), 8);
@@ -771,7 +770,7 @@
*****************************************************************/
static void create_and_append_worklist_page(struct city_dialog *pdialog)
{
- char *tab_title = _("Pro_duction");
+ const char *tab_title = _("Pro_duction");
GtkWidget *label = gtk_label_new_with_mnemonic(tab_title);
GtkWidget *page, *hbox, *editor, *bar;
@@ -822,7 +821,7 @@
static void create_and_append_happiness_page(struct city_dialog *pdialog)
{
GtkWidget *page, *vbox, *label, *table, *align;
- char *tab_title = _("_Happiness");
+ const char *tab_title = _("_Happiness");
page = gtk_hbox_new(FALSE, 6);
gtk_container_set_border_width(GTK_CONTAINER(page), 8);
@@ -873,7 +872,7 @@
static void create_and_append_cma_page(struct city_dialog *pdialog)
{
GtkWidget *page, *label;
- char *tab_title = _("C_MA");
+ const char *tab_title = _("C_MA");
page = gtk_vbox_new(FALSE, 0);
@@ -893,7 +892,7 @@
static void create_and_append_trade_page(struct city_dialog *pdialog)
{
GtkWidget *page, *label;
- char *tab_title = _("Trade Ro_utes");
+ const char *tab_title = _("Trade Ro_utes");
page = gtk_hbox_new(TRUE, 0);
@@ -918,16 +917,15 @@
GtkWidget *vbox, *vbox2, *page, *frame, *label, *button;
GtkSizeGroup *size;
GSList *group;
+ const char *tab_title = _("_Settings");
- char *tab_title = _("_Settings");
-
- static char *new_citizens_label[] = {
+ static const char *new_citizens_label[] = {
N_("Entertainers"),
N_("Scientists"),
N_("Taxmen")
};
- static char *city_opts_label[NUM_CITY_OPTS] = {
+ static const char *city_opts_label[NUM_CITY_OPTS] = {
N_("Land units"),
N_("Sea units"),
N_("Helicopters"),
@@ -935,7 +933,7 @@
N_("Disband if build settler at size 1")
};
- static char *misc_whichtab_label[NUM_PAGES] = {
+ static const char *misc_whichtab_label[NUM_PAGES] = {
N_("Overview page"),
N_("Production page"),
N_("Happiness page"),
Index: client/gui-gtk-2.0/cma_fe.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/cma_fe.c,v
retrieving revision 1.17
diff -u -r1.17 cma_fe.c
--- client/gui-gtk-2.0/cma_fe.c 5 May 2004 20:39:15 -0000 1.17
+++ client/gui-gtk-2.0/cma_fe.c 8 May 2004 00:19:52 -0000
@@ -481,7 +481,7 @@
static void cma_add_preset_callback(GtkWidget *w, gpointer data)
{
struct cma_dialog *pdialog = (struct cma_dialog *) data;
- char *default_name;
+ const char *default_name;
GtkWidget *parent = gtk_widget_get_toplevel(pdialog->shell);
int index;
Index: client/gui-gtk-2.0/connectdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/connectdlg.c,v
retrieving revision 1.34
diff -u -r1.34 connectdlg.c
--- client/gui-gtk-2.0/connectdlg.c 1 May 2004 17:33:01 -0000 1.34
+++ client/gui-gtk-2.0/connectdlg.c 8 May 2004 00:19:53 -0000
@@ -263,7 +263,7 @@
row[0] = ntoh_str(pserver->name);
row[1] = ntoh_str(pserver->port);
row[2] = ntoh_str(pserver->version);
- row[3] = _(pserver->status);
+ row[3] = g_strdup(_(pserver->status));
row[4] = ntoh_str(pserver->players);
row[5] = ntoh_str(pserver->metastring);
@@ -273,9 +273,7 @@
3, row[3], 4, row[4], 5, row[5], -1);
for (i = 0; i < 6; i++) {
- if (i != 3) {
- g_free(row[i]);
- }
+ g_free(row[i]);
}
} server_list_iterate_end;
}
@@ -533,7 +531,7 @@
/**************************************************************************
create a file selector for both the load and save commands
**************************************************************************/
-GtkWidget *create_file_selection(char *title, bool is_save)
+GtkWidget *create_file_selection(const char *title, bool is_save)
{
GtkWidget *filesel;
@@ -1140,7 +1138,7 @@
row[0] = ntoh_str(pserver->name);
row[1] = ntoh_str(pserver->port);
row[2] = ntoh_str(pserver->version);
- row[3] = _(pserver->status);
+ row[3] = g_strdup(_(pserver->status));
row[4] = ntoh_str(pserver->players);
row[5] = ntoh_str(pserver->metastring);
@@ -1150,9 +1148,7 @@
3, row[3], 4, row[4], 5, row[5], -1);
for (i=0; i<6; i++) {
- if (i != 3) {
- g_free(row[i]);
- }
+ g_free(row[i]);
}
}
server_list_iterate_end;
Index: client/gui-gtk-2.0/connectdlg.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/connectdlg.h,v
retrieving revision 1.3
diff -u -r1.3 connectdlg.h
--- client/gui-gtk-2.0/connectdlg.h 2 May 2004 08:09:31 -0000 1.3
+++ client/gui-gtk-2.0/connectdlg.h 8 May 2004 00:19:53 -0000
@@ -19,6 +19,6 @@
#include "connectdlg_g.h"
-GtkWidget *create_file_selection(char *title, bool is_save);
+GtkWidget *create_file_selection(const char *title, bool is_save);
#endif /* FC__CONNECTDLG_H */
Index: client/gui-gtk-2.0/dialogs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/dialogs.c,v
retrieving revision 1.65
diff -u -r1.65 dialogs.c
--- client/gui-gtk-2.0/dialogs.c 8 May 2004 00:00:22 -0000 1.65
+++ client/gui-gtk-2.0/dialogs.c 8 May 2004 00:19:53 -0000
@@ -1555,7 +1555,7 @@
GtkWidget *shell, *view, *sw, *hbox;
GtkWidget *ready_cmd, *sentry_cmd, *close_cmd;
- static char *titles[NUM_UNIT_SELECT_COLUMNS] = {
+ static const char *titles[NUM_UNIT_SELECT_COLUMNS] = {
N_("Unit"),
N_("Name")
};
Index: client/gui-gtk-2.0/gui_stuff.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/gui_stuff.c,v
retrieving revision 1.12
diff -u -r1.12 gui_stuff.c
--- client/gui-gtk-2.0/gui_stuff.c 1 May 2004 17:28:47 -0000 1.12
+++ client/gui-gtk-2.0/gui_stuff.c 8 May 2004 00:19:53 -0000
@@ -95,7 +95,7 @@
(This is not directly gui/gtk related, but it fits in here
because so far it is used for doing i18n for gtk titles...)
**************************************************************************/
-void intl_slist(int n, char **s, bool *done)
+void intl_slist(int n, const char **s, bool *done)
{
int i;
Index: client/gui-gtk-2.0/gui_stuff.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/gui_stuff.h,v
retrieving revision 1.8
diff -u -r1.8 gui_stuff.h
--- client/gui-gtk-2.0/gui_stuff.h 2 May 2004 08:09:31 -0000 1.8
+++ client/gui-gtk-2.0/gui_stuff.h 8 May 2004 00:19:53 -0000
@@ -21,7 +21,7 @@
void gtk_expose_now(GtkWidget *w);
void gtk_set_relative_position(GtkWidget *ref, GtkWidget *w, int px, int py);
-void intl_slist(int n, char **s, bool *done);
+void intl_slist(int n, const char **s, bool *done);
/* the standard GTK+ 2.0 API is braindamaged. this is slightly better! */
Index: client/gui-gtk-2.0/inputdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/inputdlg.c,v
retrieving revision 1.9
diff -u -r1.9 inputdlg.c
--- client/gui-gtk-2.0/inputdlg.c 1 May 2004 17:28:47 -0000 1.9
+++ client/gui-gtk-2.0/inputdlg.c 8 May 2004 00:19:53 -0000
@@ -55,10 +55,11 @@
/****************************************************************
...
*****************************************************************/
-GtkWidget *input_dialog_create(GtkWindow *parent, char *dialogname,
- char *text, char *postinputtest,
- GCallback ok_callback, gpointer ok_cli_data,
- GCallback cancel_callback, gpointer cancel_cli_data)
+GtkWidget *input_dialog_create(GtkWindow *parent, const char *dialogname,
+ const char *text, const char *postinputtest,
+ GCallback ok_callback, gpointer ok_cli_data,
+ GCallback cancel_callback,
+ gpointer cancel_cli_data)
{
GtkWidget *shell, *label, *input, *ok, *cancel;
Index: client/gui-gtk-2.0/inputdlg.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/inputdlg.h,v
retrieving revision 1.3
diff -u -r1.3 inputdlg.h
--- client/gui-gtk-2.0/inputdlg.h 15 Dec 2002 19:26:37 -0000 1.3
+++ client/gui-gtk-2.0/inputdlg.h 8 May 2004 00:19:53 -0000
@@ -15,10 +15,11 @@
#include <gtk/gtk.h>
-GtkWidget *input_dialog_create(GtkWindow *parent, char *dialogname,
- char *text, char *postinputtest,
+GtkWidget *input_dialog_create(GtkWindow *parent, const char *dialogname,
+ const char *text, const char *postinputtest,
GCallback ok_callback, gpointer ok_cli_data,
- GCallback cancel_callback, gpointer
cancel_cli_data);
+ GCallback cancel_callback,
+ gpointer cancel_cli_data);
void input_dialog_destroy(GtkWidget *button);
const char *input_dialog_get_input(GtkWidget *button);
Index: client/gui-gtk-2.0/menu.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/menu.c,v
retrieving revision 1.29
diff -u -r1.29 menu.c
--- client/gui-gtk-2.0/menu.c 23 Apr 2004 23:13:55 -0000 1.29
+++ client/gui-gtk-2.0/menu.c 8 May 2004 00:19:53 -0000
@@ -61,7 +61,7 @@
GtkAccelGroup *toplevel_accel = NULL;
static enum unit_activity road_activity;
-static void menus_rename(const char *path, char *s);
+static void menus_rename(const char *path, const char *s);
/****************************************************************
...
@@ -897,7 +897,8 @@
g_strlcpy(res, path, sizeof(res));
#else
static struct astring in, out, tmp; /* these are never free'd */
- char *tok, *next, *trn, *t;
+ char *tok, *next, *t;
+ const char *trn;
int len;
char *res;
@@ -1039,7 +1040,7 @@
/****************************************************************
...
*****************************************************************/
-static void menus_rename(const char *path, char *s)
+static void menus_rename(const char *path, const char *s)
{
GtkWidget *item;
@@ -1178,11 +1179,11 @@
}
if((punit=get_unit_in_focus())) {
- char *irrfmt = _("Change to %s (_I)");
- char *minfmt = _("Change to %s (_M)");
- char *transfmt = _("Transf_orm to %s");
+ const char *irrfmt = _("Change to %s (_I)");
+ const char *minfmt = _("Change to %s (_M)");
+ const char *transfmt = _("Transf_orm to %s");
char irrtext[128], mintext[128], transtext[128];
- char *roadtext;
+ const char *roadtext;
enum tile_terrain_type ttype;
struct tile_type * tinfo;
Index: client/gui-gtk-2.0/messagewin.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/messagewin.c,v
retrieving revision 1.24
diff -u -r1.24 messagewin.c
--- client/gui-gtk-2.0/messagewin.c 1 May 2004 17:28:47 -0000 1.24
+++ client/gui-gtk-2.0/messagewin.c 8 May 2004 00:19:53 -0000
@@ -150,7 +150,7 @@
*****************************************************************/
static void create_meswin_dialog(void)
{
- static char *titles[1] = { N_("Messages") };
+ static const char *titles[1] = { N_("Messages") };
static bool titles_done;
GtkCellRenderer *renderer;
GtkTreeViewColumn *col;
Index: client/gui-gtk-2.0/repodlgs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/repodlgs.c,v
retrieving revision 1.49
diff -u -r1.49 repodlgs.c
--- client/gui-gtk-2.0/repodlgs.c 1 May 2004 17:28:47 -0000 1.49
+++ client/gui-gtk-2.0/repodlgs.c 8 May 2004 00:19:54 -0000
@@ -609,7 +609,7 @@
*****************************************************************/
void create_economy_report_dialog(bool make_modal)
{
- static char *titles[4] = {
+ static const char *titles[4] = {
N_("Building Name"),
N_("Count"),
N_("Cost"),
@@ -941,7 +941,7 @@
*****************************************************************/
void create_activeunits_report_dialog(bool make_modal)
{
- static char *titles[AU_COL] = {
+ static const char *titles[AU_COL] = {
N_("Unit Type"),
N_("U"),
N_("In-Prog"),
@@ -1308,7 +1308,7 @@
static bool titles_done;
GtkTreeIter it;
- static char *titles[NUM_SCORE_COLS] = {
+ static const char *titles[NUM_SCORE_COLS] = {
N_("Player\n"),
N_("Score\n"),
N_("Population\n"),
Index: client/gui-gtk-2.0/wldlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/wldlg.c,v
retrieving revision 1.34
diff -u -r1.34 wldlg.c
--- client/gui-gtk-2.0/wldlg.c 1 May 2004 17:28:47 -0000 1.34
+++ client/gui-gtk-2.0/wldlg.c 8 May 2004 00:19:54 -0000
@@ -946,7 +946,7 @@
static void populate_view(GtkTreeView *view, struct city **ppcity,
GtkTreeViewColumn **pcol)
{
- static char *titles[] =
+ static const char *titles[] =
{ N_("Type"), N_("Name"), N_("Info"), N_("Cost"), N_("Turns") };
static bool titles_done;
|
|