[Freeciv-Dev] Re: (PR#2745) Change style guide to favor a++ instead of +
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Tue, Jan 07, 2003 at 03:32:56AM -0800, Raimar Falke via RT wrote:
>
>
> $ grep -Irn '[a-nA-Z][+][+]' .|fgrep .c|wc -l
> 1961
> $ grep -Irn '[+][+][a-nA-Z]' .|fgrep .c|wc -l
> 132
>
> >From these 132 cases some are in intl/ (out of reach), some are
> required:
> ./client/gui-sdl/gui_dither.c:516: if (++h >= NORMAL_TILE_HEIGHT / 2) {
> ./server/mapgen.c:1888: && ++j < 500) {
> but the larger part doesn't require it. for loops like
> ./client/gui-sdl/optiondlg.c:347: for (i = 0; pModes[i]; ++i) {
> can be replaced. And simple statements like:
> ./client/gui-mui/messagedlg.c:111: ++err;
> ./common/rand.c:208: ++behaviourchange;
> ./server/unithand.c:187: ++number_of_upgraded_units;
> also doesn't need it.
And the patch.
Raimar
--
email: rf13@xxxxxxxxxxxxxxxxx
"Your mail could not be delivered to the following Address:
VTCMC.VTLPR@xxxxxxxxxxxxx ** Unassigned error message **"
Index: ai/aihand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aihand.c,v
retrieving revision 1.73
diff -u -u -r1.73 aihand.c
--- ai/aihand.c 2002/12/23 18:09:58 1.73
+++ ai/aihand.c 2003/01/10 11:11:21
@@ -320,7 +320,7 @@
int bonus = 0; /* in percentage */
int current_gov = pplayer->government;
- for (i = 0; i < game.government_count; ++i) {
+ for (i = 0; i < game.government_count; i++) {
struct government *gov = &governments[i];
int val = 0;
int dist;
Index: client/clinet.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/clinet.c,v
retrieving revision 1.77
diff -u -u -r1.77 clinet.c
--- client/clinet.c 2002/12/08 22:55:24 1.77
+++ client/clinet.c 2003/01/10 11:11:22
@@ -535,8 +535,10 @@
port = 80;
}
s[0] = '\0';
- ++s;
- while (my_isdigit(s[0])) {++s;}
+ s++;
+ while (my_isdigit(s[0])) {
+ s++;
+ }
} else {
port = 80;
if (!(s = strchr(server,'/'))) {
@@ -546,7 +548,7 @@
if (s[0] == '/') {
s[0] = '\0';
- ++s;
+ s++;
} else if (s[0] != '\0') {
(void) mystrlcpy(errbuf, _("Invalid $http_proxy value, cannot "
"find separating '/'"), n_errbuf);
Index: client/helpdata.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/helpdata.c,v
retrieving revision 1.58
diff -u -u -r1.58 helpdata.c
--- client/helpdata.c 2003/01/05 23:24:51 1.58
+++ client/helpdata.c 2003/01/10 11:11:24
@@ -414,13 +414,14 @@
idx = 0;
help_list_iterate(help_nodes, ptmp) {
char *p=ptmp->topic;
- while(*p==' ')
- ++p;
+ while (*p == ' ') {
+ p++;
+ }
if(strcmp(name, p)==0 && (htype==HELP_ANY || htype==ptmp->type)) {
pitem = ptmp;
break;
}
- ++idx;
+ idx++;
}
help_list_iterate_end;
Index: client/gui-gtk/gamedlgs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/gamedlgs.c,v
retrieving revision 1.29
diff -u -u -r1.29 gamedlgs.c
--- client/gui-gtk/gamedlgs.c 2002/11/14 09:14:53 1.29
+++ client/gui-gtk/gamedlgs.c 2003/01/10 11:11:26
@@ -380,7 +380,7 @@
bool b;
int i;
- for (o=options; o->name; ++o) {
+ for (o = options; o->name; o++) {
switch (o->type) {
case COT_BOOL:
b = *(o->p_bool_value);
@@ -449,14 +449,15 @@
gtk_window_set_title(GTK_WINDOW(option_dialog_shell), _("Set local
options"));
- for (o=options, i=0; o->name; ++o, i++)
- ;
+ for (o = options, i = 0; o->name; o++, i++) {
+ /* nothing */
+ }
table=gtk_table_new(i, 2, FALSE);
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(option_dialog_shell)->vbox),
table);
- for (o=options, i=0; o->name; ++o, i++) {
+ for (o = options, i = 0; o->name; o++, i++) {
switch (o->type) {
case COT_BOOL:
label = gtk_label_new(_(o->description));
@@ -512,7 +513,7 @@
create_option_dialog();
- for (o=options; o->name; ++o) {
+ for (o = options; o->name; o++) {
switch (o->type) {
case COT_BOOL:
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(o->p_gui_data),
Index: client/gui-gtk/graphics.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/graphics.c,v
retrieving revision 1.47
diff -u -u -r1.47 graphics.c
--- client/gui-gtk/graphics.c 2002/11/14 09:14:53 1.47
+++ client/gui-gtk/graphics.c 2003/01/10 11:11:27
@@ -477,13 +477,13 @@
xoffset = 0;
xremsum = new_w / 2;
- for (x = 0; x < new_w; ++x) {
+ for (x = 0; x < new_w; x++) {
xoffset_table[x] = xoffset;
xoffset += xadd;
xremsum += xremadd;
if (xremsum >= new_w) {
xremsum -= new_w;
- ++xoffset;
+ xoffset++;
}
}
@@ -498,8 +498,8 @@
dst->mask = gdk_pixmap_new(root_window, new_w, new_h, 1);
gdk_draw_rectangle(dst->mask, mask_bg_gc, TRUE, 0, 0, -1, -1);
- for (y = 0; y < new_h; ++y) {
- for (x = 0; x < new_w; ++x) {
+ for (y = 0; y < new_h; y++) {
+ for (x = 0; x < new_w; x++) {
pixel = gdk_image_get_pixel(xi_src, xoffset_table[x], yoffset);
gdk_image_put_pixel(xi_dst, x, y, pixel);
@@ -512,14 +512,14 @@
yremsum += yremadd;
if (yremsum >= new_h) {
yremsum -= new_h;
- ++yoffset;
+ yoffset++;
}
}
gdk_image_destroy(xb_src);
} else {
- for (y = 0; y < new_h; ++y) {
- for (x = 0; x < new_w; ++x) {
+ for (y = 0; y < new_h; y++) {
+ for (x = 0; x < new_w; x++) {
pixel = gdk_image_get_pixel(xi_src, xoffset_table[x], yoffset);
gdk_image_put_pixel(xi_dst, x, y, pixel);
}
@@ -528,7 +528,7 @@
yremsum += yremadd;
if (yremsum >= new_h) {
yremsum -= new_h;
- ++yoffset;
+ yoffset++;
}
}
}
Index: client/gui-gtk/helpdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/helpdlg.c,v
retrieving revision 1.60
diff -u -u -r1.60 helpdlg.c
--- client/gui-gtk/helpdlg.c 2002/11/14 09:14:54 1.60
+++ client/gui-gtk/helpdlg.c 2003/01/10 11:11:29
@@ -858,7 +858,7 @@
gtk_box_pack_start(GTK_BOX(hbox), w, FALSE, FALSE, 0);
} unit_type_iterate_end;
- for(j=0; j<game.num_tech_types; ++j) {
+ for (j = 0; j < game.num_tech_types; j++) {
if(i==advances[j].req[0]) {
if(advances[j].req[1]==A_NONE) {
hbox = gtk_hbox_new(FALSE, 0);
@@ -1063,7 +1063,9 @@
/* figure out what kind of item is required for pitem ingo */
- for(top=pitem->topic; *top==' '; ++top);
+ for (top = pitem->topic; *top == ' '; top++) {
+ /* nothing */
+ }
gtk_widget_hide_all(help_box);
gtk_text_freeze(GTK_TEXT(help_text));
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.30
diff -u -u -r1.30 dialogs.c
--- client/gui-gtk-2.0/dialogs.c 2003/01/01 11:51:33 1.30
+++ client/gui-gtk-2.0/dialogs.c 2003/01/10 11:11:34
@@ -1194,7 +1194,7 @@
gtk_container_add(GTK_CONTAINER(dlabel), vbox);
gtk_container_border_width(GTK_CONTAINER(vbox), 5);
- for (i=0; i<game.government_count; ++i) {
+ for (i = 0; i < game.government_count; i++) {
struct government *g = &governments[i];
if (i != game.government_when_anarchy) {
Index: client/gui-gtk-2.0/gamedlgs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/gamedlgs.c,v
retrieving revision 1.13
diff -u -u -r1.13 gamedlgs.c
--- client/gui-gtk-2.0/gamedlgs.c 2002/12/06 21:45:41 1.13
+++ client/gui-gtk-2.0/gamedlgs.c 2003/01/10 11:11:35
@@ -371,7 +371,7 @@
bool b;
int i;
- for (o=options; o->name; ++o) {
+ for (o = options; o->name; o++) {
switch (o->type) {
case COT_BOOL:
b = *(o->p_bool_value);
@@ -442,14 +442,15 @@
G_CALLBACK(option_ok_command_callback), NULL);
gtk_window_set_position (GTK_WINDOW(option_dialog_shell), GTK_WIN_POS_MOUSE);
- for (o=options, i=0; o->name; ++o, i++)
- ;
+ for (o = options, i = 0; o->name; o++, i++) {
+ /* nothing */
+ }
table=gtk_table_new(i, 2, FALSE);
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(option_dialog_shell)->vbox),
table);
- for (o=options, i=0; o->name; ++o, i++) {
+ for (o = options, i = 0; o->name; o++, i++) {
switch (o->type) {
case COT_BOOL:
label = gtk_label_new(_(o->description));
@@ -496,7 +497,7 @@
create_option_dialog();
}
- for (o=options; o->name; ++o) {
+ for (o = options; o->name; o++) {
switch (o->type) {
case COT_BOOL:
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(o->p_gui_data),
Index: client/gui-gtk-2.0/graphics.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/graphics.c,v
retrieving revision 1.11
diff -u -u -r1.11 graphics.c
--- client/gui-gtk-2.0/graphics.c 2002/11/14 09:14:55 1.11
+++ client/gui-gtk-2.0/graphics.c 2003/01/10 11:11:36
@@ -471,13 +471,13 @@
xoffset = 0;
xremsum = new_w / 2;
- for (x = 0; x < new_w; ++x) {
+ for (x = 0; x < new_w; x++) {
xoffset_table[x] = xoffset;
xoffset += xadd;
xremsum += xremadd;
if (xremsum >= new_w) {
xremsum -= new_w;
- ++xoffset;
+ xoffset++;
}
}
@@ -492,8 +492,8 @@
dst->mask = gdk_pixmap_new(root_window, new_w, new_h, 1);
gdk_draw_rectangle(dst->mask, mask_bg_gc, TRUE, 0, 0, -1, -1);
- for (y = 0; y < new_h; ++y) {
- for (x = 0; x < new_w; ++x) {
+ for (y = 0; y < new_h; y++) {
+ for (x = 0; x < new_w; x++) {
pixel = gdk_image_get_pixel(xi_src, xoffset_table[x], yoffset);
gdk_image_put_pixel(xi_dst, x, y, pixel);
@@ -506,14 +506,14 @@
yremsum += yremadd;
if (yremsum >= new_h) {
yremsum -= new_h;
- ++yoffset;
+ yoffset++;
}
}
gdk_image_destroy(xb_src);
} else {
- for (y = 0; y < new_h; ++y) {
- for (x = 0; x < new_w; ++x) {
+ for (y = 0; y < new_h; y++) {
+ for (x = 0; x < new_w; x++) {
pixel = gdk_image_get_pixel(xi_src, xoffset_table[x], yoffset);
gdk_image_put_pixel(xi_dst, x, y, pixel);
}
@@ -522,7 +522,7 @@
yremsum += yremadd;
if (yremsum >= new_h) {
yremsum -= new_h;
- ++yoffset;
+ yoffset++;
}
}
}
Index: client/gui-gtk-2.0/helpdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/helpdlg.c,v
retrieving revision 1.12
diff -u -u -r1.12 helpdlg.c
--- client/gui-gtk-2.0/helpdlg.c 2002/12/31 03:32:18 1.12
+++ client/gui-gtk-2.0/helpdlg.c 2003/01/10 11:11:39
@@ -897,7 +897,7 @@
gtk_widget_show_all(hbox);
} unit_type_iterate_end;
- for(j=0; j<game.num_tech_types; ++j) {
+ for (j = 0; j < game.num_tech_types; j++) {
if(i==advances[j].req[0]) {
if(advances[j].req[1]==A_NONE) {
hbox = gtk_hbox_new(FALSE, 0);
@@ -1097,7 +1097,9 @@
/* figure out what kind of item is required for pitem ingo */
- for(top=pitem->topic; *top==' '; ++top);
+ for (top = pitem->topic; *top == ' '; top++) {
+ /* nothing */
+ }
help_box_hide();
gtk_text_buffer_set_text(help_text, "", -1);
Index: client/gui-mui/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-mui/citydlg.c,v
retrieving revision 1.60
diff -u -u -r1.60 citydlg.c
--- client/gui-mui/citydlg.c 2002/12/15 22:43:47 1.60
+++ client/gui-mui/citydlg.c 2003/01/10 11:11:44
@@ -1351,7 +1351,7 @@
DoMethod(pcprod->available_listview, MUIM_NList_InsertSingle, i + 1,
MUIV_NList_Insert_Bottom);
if (i == pcity->currently_building && !pcity->is_building_unit)
- current = ++pos;
+ current = pos++;
pos++;
}
@@ -1371,7 +1371,7 @@
DoMethod(pcprod->available_listview, MUIM_NList_InsertSingle, i +
10000, MUIV_NList_Insert_Bottom);
if(i == pcity->currently_building && pcity->is_building_unit)
- current = ++pos;
+ current = pos++;
pos++;
}
Index: client/gui-mui/cityrep.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-mui/cityrep.c,v
retrieving revision 1.24
diff -u -u -r1.24 cityrep.c
--- client/gui-mui/cityrep.c 2002/11/14 09:14:56 1.24
+++ client/gui-mui/cityrep.c 2003/01/10 11:11:45
@@ -91,7 +91,7 @@
sz_strlcat(buf[j], city_report_specs[i].title2);
}
array[j] = buf[j];
- ++j;
+ j++;
}
}
return 0;
@@ -263,7 +263,7 @@
LONG i, j = 0;
buffer[j++] = ','; /* the name! */
- for(i = 1; i < NUM_CREPORT_COLS; ++i)
+ for(i = 1; i < NUM_CREPORT_COLS; i++)
{
if((city_report_specs[i].show = xget(cityrep_configure_objects[i],
MUIA_Selected)))
buffer[j++] = ',';
@@ -315,12 +315,12 @@
if((o = MakeLabel(city_report_specs[i].explanation)))
DoMethod(group, OM_ADDMEMBER, o);
else
- ++err;
+ err++;
if((cityrep_configure_objects[i] =
MakeCheck(city_report_specs[i].explanation, FALSE)))
DoMethod(group, OM_ADDMEMBER, cityrep_configure_objects[i]);
else
- ++err;
+ err++;
}
if(!err)
{
@@ -339,7 +339,7 @@
if(config_wnd)
{
- for(i = 0; i < NUM_CREPORT_COLS; ++i)
+ for (i = 0; i < NUM_CREPORT_COLS; i++)
setcheckmark(cityrep_configure_objects[i], city_report_specs[i].show);
set(config_wnd, MUIA_Window_Open, TRUE);
}
@@ -357,7 +357,7 @@
LONG i, j = 0;
format[j++] = ','; /* the name! */
- for(i = 1; i < NUM_CREPORT_COLS; ++i)
+ for (i = 1; i < NUM_CREPORT_COLS; i++)
{
if(city_report_specs[i].show)
format[j++] = ',';
Index: client/gui-mui/gamedlgs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-mui/gamedlgs.c,v
retrieving revision 1.11
diff -u -u -r1.11 gamedlgs.c
--- client/gui-mui/gamedlgs.c 2002/11/14 09:14:56 1.11
+++ client/gui-mui/gamedlgs.c 2003/01/10 11:11:46
@@ -290,7 +290,7 @@
{
client_option *o;
- for (o = options; o->name; ++o)
+ for (o = options; o->name; o++)
{
Object *obj = (Object *) o->p_gui_data;
if (obj)
@@ -334,8 +334,7 @@
if (option_wnd)
{
- for (o = options; o->name; ++o)
- {
+ for (o = options; o->name; o++) {
Object *obj, *label;
if (o->type == COT_BOOL) obj = MakeCheck(_(o->description), FALSE);
@@ -364,8 +363,7 @@
if (option_wnd)
{
- for (o = options; o->name; ++o)
- {
+ for (o = options; o->name; o++) {
Object *obj = (Object *) o->p_gui_data;
if (obj)
{
Index: client/gui-mui/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-mui/gui_main.c,v
retrieving revision 1.69
diff -u -u -r1.69 gui_main.c
--- client/gui-mui/gui_main.c 2003/01/01 11:51:33 1.69
+++ client/gui-mui/gui_main.c 2003/01/10 11:11:49
@@ -872,8 +872,7 @@
#ifdef ENABLE_NLS
struct NewMenu *nm;
- for(nm = MenuData; nm->nm_Type != NM_END; ++nm)
- {
+ for (nm = MenuData; nm->nm_Type != NM_END; nm++) {
if(nm->nm_Label != NM_BARLABEL)
nm->nm_Label = _(nm->nm_Label);
}
Index: client/gui-mui/helpdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-mui/helpdlg.c,v
retrieving revision 1.30
diff -u -u -r1.30 helpdlg.c
--- client/gui-mui/helpdlg.c 2002/11/14 09:22:09 1.30
+++ client/gui-mui/helpdlg.c 2003/01/10 11:11:51
@@ -770,8 +770,7 @@
} unit_type_iterate_end;
- for (j = 0; j < game.num_tech_types; ++j)
- {
+ for (j = 0; j < game.num_tech_types; j++) {
Object *o, *button;
if (i == advances[j].req[0])
{
@@ -962,7 +961,9 @@
/* figure out what kind of item is required for pitem ingo */
- for (top = pitem->topic; *top == ' '; ++top);
+ for (top = pitem->topic; *top == ' '; top++) {
+ /* nothing */
+ }
switch (pitem->type)
{
Index: client/gui-mui/messagedlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-mui/messagedlg.c,v
retrieving revision 1.12
diff -u -u -r1.12 messagedlg.c
--- client/gui-mui/messagedlg.c 2002/11/14 09:14:57 1.12
+++ client/gui-mui/messagedlg.c 2003/01/10 11:11:51
@@ -41,8 +41,7 @@
{
LONG i, j;
- for(i = 0; i < E_LAST; ++i)
- {
+ for (i = 0; i < E_LAST; i++) {
j = 0;
if(xget(message_option_objects[i].Out, MUIA_Selected)) j |= MW_OUTPUT;
if(xget(message_option_objects[i].Mes, MUIA_Selected)) j |= MW_MESSAGES;
@@ -96,41 +95,40 @@
if(option_wnd)
{
- for(i = 0; i < 2 && !err; ++i)
- {
- if((o = MakeLabel(""))) DoMethod(group[i], OM_ADDMEMBER, o); else
++err;
- if((o = MakeLabel(_("Out:")))) DoMethod(group[i], OM_ADDMEMBER, o);
else ++err;
- if((o = MakeLabel(_("Mes:")))) DoMethod(group[i], OM_ADDMEMBER, o);
else ++err;
- if((o = MakeLabel(_("Pop:")))) DoMethod(group[i], OM_ADDMEMBER, o);
else ++err;
+ for (i = 0; i < 2 && !err; i++) {
+ if((o = MakeLabel(""))) DoMethod(group[i], OM_ADDMEMBER, o); else
err++;
+ if((o = MakeLabel(_("Out:")))) DoMethod(group[i], OM_ADDMEMBER, o);
else err++;
+ if((o = MakeLabel(_("Mes:")))) DoMethod(group[i], OM_ADDMEMBER, o);
else err++;
+ if((o = MakeLabel(_("Pop:")))) DoMethod(group[i], OM_ADDMEMBER, o);
else err++;
}
for(i=0; i < E_LAST && !err; i++)
{
if((o = MakeLabelLeft(get_message_text(sorted_events[i]))))
DoMethod(group[i < (E_LAST/2) ? 0: 1], OM_ADDMEMBER, o);
else
- ++err;
+ err++;
if((message_option_objects[i].Out =
MakeCheck(get_message_text(sorted_events[i]), FALSE)))
DoMethod(group[i < (E_LAST/2) ? 0: 1], OM_ADDMEMBER,
message_option_objects[i].Out);
else
- ++err;
+ err++;
if((message_option_objects[i].Mes =
MakeCheck(get_message_text(sorted_events[i]), FALSE)))
DoMethod(group[i < (E_LAST/2) ? 0: 1], OM_ADDMEMBER,
message_option_objects[i].Mes);
else
- ++err;
+ err++;
if((message_option_objects[i].Pop =
MakeCheck(get_message_text(sorted_events[i]), FALSE)))
DoMethod(group[i < (E_LAST/2) ? 0: 1], OM_ADDMEMBER,
message_option_objects[i].Pop);
else
- ++err;
+ err++;
}
if(E_LAST & 1) /* uneven number of entries */
{
if((o = MakeLabel("")))
DoMethod(group[0], OM_ADDMEMBER, o);
else
- ++err;
+ err++;
}
if(!err)
@@ -150,8 +148,7 @@
if(option_wnd)
{
- for(i = 0; i < E_LAST; ++i)
- {
+ for (i = 0; i < E_LAST; i++) {
setcheckmark(message_option_objects[i].Out,
messages_where[sorted_events[i]] & MW_OUTPUT);
setcheckmark(message_option_objects[i].Mes,
messages_where[sorted_events[i]] & MW_MESSAGES);
setcheckmark(message_option_objects[i].Pop,
messages_where[sorted_events[i]] & MW_POPUP);
Index: client/gui-sdl/graphics.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-sdl/graphics.c,v
retrieving revision 1.6
diff -u -u -r1.6 graphics.c
--- client/gui-sdl/graphics.c 2003/01/05 23:19:18 1.6
+++ client/gui-sdl/graphics.c 2003/01/10 11:11:54
@@ -846,7 +846,7 @@
pUniStringArray = CALLOC(i + 1, sizeof(Uint16 *));
/* fill array */
- for (i = 0; pModes[i]; ++i) {
+ for (i = 0; pModes[i]; i++) {
sprintf(__buf, "%dx%d", pModes[i]->w, pModes[i]->h);
pUniStringArray[i] = convert_to_utf16(__buf);
freelog(LOG_DEBUG, _("Add %s"), __buf);
Index: client/gui-sdl/optiondlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-sdl/optiondlg.c,v
retrieving revision 1.3
diff -u -u -r1.3 optiondlg.c
--- client/gui-sdl/optiondlg.c 2003/01/05 23:19:18 1.3
+++ client/gui-sdl/optiondlg.c 2003/01/10 11:11:58
@@ -344,7 +344,7 @@
}
/* create modes buttons */
- for (i = 0; pModes[i]; ++i) {
+ for (i = 0; pModes[i]; i++) {
pTmpGui = create_icon_button_from_unichar(NULL, pModes[i], 14, 0);
Index: client/gui-win32/helpdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/helpdlg.c,v
retrieving revision 1.13
diff -u -u -r1.13 helpdlg.c
--- client/gui-win32/helpdlg.c 2002/12/05 20:26:39 1.13
+++ client/gui-win32/helpdlg.c 2003/01/10 11:12:00
@@ -797,7 +797,7 @@
0,FALSE,FALSE,5);
} unit_type_iterate_end;
- for(j=0; j<game.num_tech_types; ++j) {
+ for (j = 0; j < game.num_tech_types; j++) {
if(i==advances[j].req[0]) {
if(advances[j].req[1]==A_NONE) {
hbox=fcwin_hbox_new(helpdlg_win,FALSE);
@@ -860,7 +860,9 @@
char *top;
/* figure out what kind of item is required for pitem ingo */
- for(top=pitem->topic; *top==' '; ++top);
+ for (top = pitem->topic; *top == ' '; top++) {
+ /* nothing */
+ }
SetWindowText(helpdlg_text,"");
switch(pitem->type) {
Index: client/gui-win32/optiondlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/optiondlg.c,v
retrieving revision 1.12
diff -u -u -r1.12 optiondlg.c
--- client/gui-win32/optiondlg.c 2002/12/22 13:08:57 1.12
+++ client/gui-win32/optiondlg.c 2003/01/10 11:12:00
@@ -49,7 +49,7 @@
bool b;
int i;
- for (o=options; o->name; ++o) {
+ for (o = options; o->name; o++) {
switch (o->type) {
case COT_BOOL:
b = *(o->p_bool_value);
@@ -113,7 +113,7 @@
hbox=fcwin_hbox_new(option_dialog,FALSE);
vbox=fcwin_vbox_new(option_dialog,TRUE);
vbox_labels=fcwin_vbox_new(option_dialog,TRUE);
- for (o=options; o->name; ++o) {
+ for (o = options; o->name; o++) {
switch (o->type) {
case COT_BOOL:
fcwin_box_add_static(vbox_labels,_(o->description),
@@ -174,7 +174,7 @@
if (!option_dialog)
create_option_dialog();
- for (o=options; o->name; ++o) {
+ for (o = options; o->name; o++) {
switch (o->type) {
case COT_BOOL:
Button_SetCheck((HWND)(o->p_gui_data),
Index: client/gui-xaw/dialogs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/dialogs.c,v
retrieving revision 1.76
diff -u -u -r1.76 dialogs.c
--- client/gui-xaw/dialogs.c 2003/01/01 11:51:34 1.76
+++ client/gui-xaw/dialogs.c 2003/01/10 11:12:05
@@ -1343,7 +1343,7 @@
dlabel = I_L(XtVaCreateManagedWidget("dlabel", labelWidgetClass, form,
NULL));
prev = dlabel;
- for (i=0; i < game.government_count; ++i) {
+ for (i = 0; i < game.government_count; i++) {
if (i == game.government_when_anarchy) continue;
can_change = can_change_to_government(game.player_ptr, i);
button = XtVaCreateManagedWidget("button", commandWidgetClass, form,
Index: client/gui-xaw/gui_stuff.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/gui_stuff.c,v
retrieving revision 1.12
diff -u -u -r1.12 gui_stuff.c
--- client/gui-xaw/gui_stuff.c 2002/11/14 09:15:00 1.12
+++ client/gui-xaw/gui_stuff.c 2003/01/10 11:12:06
@@ -154,13 +154,13 @@
xoffset=0;
xremsum=dst_w/2;
- for(x=0; x<dst_w; ++x) {
+ for (x = 0; x < dst_w; x++) {
xoffset_table[x]=xoffset;
xoffset+=xadd;
xremsum+=xremadd;
if(xremsum>=dst_w) {
xremsum-=dst_w;
- ++xoffset;
+ xoffset++;
}
}
@@ -169,7 +169,7 @@
yoffset=0;
yremsum=dst_h/2;
- for(y=0; y<dst_h; ++y) {
+ for (y = 0; y < dst_h; y++) {
psrc_data=xi_src->data + (yoffset * xi_src->bytes_per_line);
pdst_data=xi_dst->data + (y * xi_dst->bytes_per_line);
@@ -195,7 +195,7 @@
yremsum+=yremadd;
if(yremsum>=dst_h) {
yremsum-=dst_h;
- ++yoffset;
+ yoffset++;
}
}
@@ -211,14 +211,14 @@
void put_line_8(char *psrc, char *pdst, int dst_w, int xoffset_table[])
{
int x;
- for(x=0; x<dst_w; ++x)
+ for (x = 0; x < dst_w; x++)
*pdst++=*(psrc+xoffset_table[x]+0);
}
void put_line_16(char *psrc, char *pdst, int dst_w, int xoffset_table[])
{
int x;
- for(x=0; x<dst_w; ++x) {
+ for (x = 0; x < dst_w; x++) {
*pdst++=*(psrc+2*xoffset_table[x]+0);
*pdst++=*(psrc+2*xoffset_table[x]+1);
}
@@ -227,7 +227,7 @@
void put_line_24(char *psrc, char *pdst, int dst_w, int xoffset_table[])
{
int x;
- for(x=0; x<dst_w; ++x) {
+ for (x = 0; x < dst_w; x++) {
*pdst++=*(psrc+3*xoffset_table[x]+0);
*pdst++=*(psrc+3*xoffset_table[x]+1);
*pdst++=*(psrc+3*xoffset_table[x]+2);
@@ -237,7 +237,7 @@
void put_line_32(char *psrc, char *pdst, int dst_w, int xoffset_table[])
{
int x;
- for(x=0; x<dst_w; ++x) {
+ for (x = 0; x < dst_w; x++) {
*pdst++=*(psrc+4*xoffset_table[x]+0);
*pdst++=*(psrc+4*xoffset_table[x]+1);
*pdst++=*(psrc+4*xoffset_table[x]+2);
Index: client/gui-xaw/helpdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/helpdlg.c,v
retrieving revision 1.45
diff -u -u -r1.45 helpdlg.c
--- client/gui-xaw/helpdlg.c 2002/11/14 09:15:00 1.45
+++ client/gui-xaw/helpdlg.c 2003/01/10 11:12:08
@@ -924,7 +924,7 @@
get_unit_type(j)->name);
} unit_type_iterate_end;
- for(j=0; j<game.num_tech_types; ++j) {
+ for (j = 0; j < game.num_tech_types; j++) {
if(i==advances[j].req[0]) {
if(advances[j].req[1]==A_NONE)
sprintf(buf+strlen(buf), _("Allows %s.\n"),
@@ -1102,7 +1102,9 @@
/* figure out what kind of item is required for pitem ingo */
- for(top=pitem->topic; *top==' '; ++top);
+ for (top = pitem->topic; *top == ' '; top++) {
+ /* nothing */
+ }
switch(pitem->type) {
case HELP_IMPROVEMENT:
@@ -1156,7 +1158,7 @@
XtNnumChildren, &cnt,
NULL);
- for(; cnt>0; --cnt, ++children) {
+ for (; cnt > 0; cnt--, children++) {
if(XtIsSubclass(*children, commandWidgetClass)) {
Widget par;
XtVaGetValues(*children, XtNtreeParent, &par, NULL);
Index: client/gui-xaw/menu.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/menu.c,v
retrieving revision 1.52
diff -u -u -r1.52 menu.c
--- client/gui-xaw/menu.c 2003/01/01 11:51:34 1.52
+++ client/gui-xaw/menu.c 2003/01/10 11:12:10
@@ -811,7 +811,7 @@
struct Menu *pmenu = menus[menu];
int i;
- for(i=0; pmenu->entries[i].id != MENU_END_OF_LIST; ++i) {
+ for (i = 0; pmenu->entries[i].id != MENU_END_OF_LIST; i++) {
if(pmenu->entries[i].id==id) {
return XtIsSensitive(pmenu->entries[i].w);
}
@@ -841,13 +841,13 @@
/* Calculate the longest string in this menu so if the font
* is fixed then we will know where to put the accelerator key.- Serrada */
litem=lacel=0;
- for(i=0; entries[i].id != MENU_END_OF_LIST; ++i) {
+ for (i = 0; entries[i].id != MENU_END_OF_LIST; i++) {
if (entries[i].id != MENU_SEPARATOR_LINE) {
lstr=strlen(entries[i].acel);
if (lacel<lstr) {
lacel=lstr;
}
- for(j=0; entries[i].text[j]; ++j) {
+ for (j = 0; entries[i].text[j]; j++) {
xlt=_(entries[i].text[j]);
lstr=strlen(xlt);
if (strstr(xlt, "%s")) {
@@ -874,7 +874,7 @@
mymenu->shell=XtCreatePopupShell("menu", simpleMenuWidgetClass,
mymenu->button, NULL, 0);
- for(i=0; entries[i].id != MENU_END_OF_LIST; ++i) {
+ for (i = 0; entries[i].id != MENU_END_OF_LIST; i++) {
if (entries[i].id == MENU_SEPARATOR_LINE) {
entries[i].w = XtCreateManagedWidget(NULL, smeLineObjectClass,
mymenu->shell, NULL, 0);
@@ -899,7 +899,7 @@
int i;
char *item;
- for(i=0; pmenu->entries[i].id != MENU_END_OF_LIST; ++i) {
+ for (i = 0; pmenu->entries[i].id != MENU_END_OF_LIST; i++) {
if(pmenu->entries[i].id==id) {
item=menu_entry_text(menu, i, var, terr);
XtVaSetValues(pmenu->entries[i].w, XtNlabel, item, NULL);
@@ -916,7 +916,7 @@
struct Menu *pmenu = menus[menu];
int i;
- for(i=0; pmenu->entries[i].id != MENU_END_OF_LIST; ++i) {
+ for (i = 0; pmenu->entries[i].id != MENU_END_OF_LIST; i++) {
if(pmenu->entries[i].id==id) {
XtSetSensitive(pmenu->entries[i].w, (s ? True : False));
return;
Index: client/gui-xaw/optiondlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/optiondlg.c,v
retrieving revision 1.22
diff -u -u -r1.22 optiondlg.c
--- client/gui-xaw/optiondlg.c 2002/11/14 09:15:01 1.22
+++ client/gui-xaw/optiondlg.c 2003/01/10 11:12:11
@@ -70,7 +70,7 @@
create_option_dialog();
- for (o=options; o->name; ++o) {
+ for (o = options; o->name; o++) {
switch (o->type) {
case COT_BOOL:
XtVaSetValues((Widget) o->p_gui_data, XtNstate, *(o->p_bool_value),
@@ -260,7 +260,7 @@
client_option *o;
XtPointer dp;
- for (o=options; o->name; ++o) {
+ for (o = options; o->name; o++) {
switch (o->type) {
case COT_BOOL:
b = *(o->p_bool_value);
Index: common/connection.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/connection.c,v
retrieving revision 1.30
diff -u -u -r1.30 connection.c
--- common/connection.c 2002/12/18 17:36:19 1.30
+++ common/connection.c 2003/01/10 11:12:12
@@ -94,7 +94,7 @@
enum cmdlevel_id i;
size_t len = strlen(token);
- for (i = 0; i < ALLOW_NUM; ++i) {
+ for (i = 0; i < ALLOW_NUM; i++) {
if (strncmp(levelnames[i], token, len) == 0) {
return i;
}
Index: common/game.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/game.c,v
retrieving revision 1.155
diff -u -u -r1.155 game.c
--- common/game.c 2003/01/09 02:36:37 1.155
+++ common/game.c 2003/01/10 11:12:14
@@ -902,7 +902,7 @@
{
int i;
- for(i=plrno; i<game.nplayers-1; ++i) {
+ for (i = plrno; i < game.nplayers - 1; i++) {
game.players[i]=game.players[i+1];
game.players[i].player_no=i;
conn_list_iterate(game.players[i].connections, pconn)
Index: common/government.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/government.c,v
retrieving revision 1.37
diff -u -u -r1.37 government.c
--- common/government.c 2003/01/09 16:03:43 1.37
+++ common/government.c 2003/01/10 11:12:14
@@ -135,7 +135,7 @@
{
int i;
- for (i = 0; i < game.government_count; ++i) {
+ for (i = 0; i < game.government_count; i++) {
if (mystrcasecmp(governments[i].name, name) == 0) {
return &governments[i];
}
Index: common/hash.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/hash.c,v
retrieving revision 1.22
diff -u -u -r1.22 hash.c
--- common/hash.c 2002/12/11 10:39:41 1.22
+++ common/hash.c 2003/01/10 11:12:16
@@ -185,7 +185,7 @@
const char *key = (const char*)vkey;
unsigned long result=0;
- for(; *key != '\0'; ++key) {
+ for (; *key != '\0'; key++) {
result *= 5;
result += *key;
}
Index: common/rand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/rand.c,v
retrieving revision 1.9
diff -u -u -r1.9 rand.c
--- common/rand.c 2002/12/06 14:55:48 1.9
+++ common/rand.c 2003/01/10 11:12:16
@@ -205,9 +205,9 @@
didchange = (new_value != old_value);
if (i > 1) { /* have olddidchange */
if (didchange != olddidchange) {
- ++behaviourchange;
+ behaviourchange++;
} else {
- ++behavioursame;
+ behavioursame++;
}
}
olddidchange = didchange;
Index: doc/CodingStyle
===================================================================
RCS file: /home/freeciv/CVS/freeciv/doc/CodingStyle,v
retrieving revision 1.5
diff -u -u -r1.5 CodingStyle
--- doc/CodingStyle 2002/12/22 18:02:16 1.5
+++ doc/CodingStyle 2003/01/10 11:12:17
@@ -165,6 +165,9 @@
/* nothing */
}
+- Prefer the postfix operator if both (postfix and prefix) can be
+ used. I.e. write "a++" instead of "++a".
+
- Order include files consistently: First state all system include
files with <> in alphabetic order, then all Freeciv include files
with "", sorted by directory (common, server, ...) and then by
Index: server/handchat.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/handchat.c,v
retrieving revision 1.23
diff -u -u -r1.23 handchat.c
--- server/handchat.c 2002/11/14 09:15:04 1.23
+++ server/handchat.c 2003/01/10 11:12:19
@@ -164,7 +164,7 @@
genmsg.x = -1;
genmsg.y = -1;
genmsg.event =-1;
- for (cp = packet->message; *cp != '\0'; ++cp)
+ for (cp = packet->message; *cp != '\0'; cp++)
if(!my_isprint(*cp & 0x7f)) {
*cp='\0';
break;
Index: server/ruleset.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/ruleset.c,v
retrieving revision 1.128
diff -u -u -r1.128 ruleset.c
--- server/ruleset.c 2003/01/03 08:58:48 1.128
+++ server/ruleset.c 2003/01/10 11:12:25
@@ -2563,7 +2563,7 @@
struct government *g;
int i, j;
- for (i = 0; i < game.government_count; ++i) {
+ for (i = 0; i < game.government_count; i++) {
g = &governments[i];
/* send one packet_government */
Index: server/unithand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unithand.c,v
retrieving revision 1.246
diff -u -u -r1.246 unithand.c
--- server/unithand.c 2003/01/09 02:36:38 1.246
+++ server/unithand.c 2003/01/10 11:12:29
@@ -184,7 +184,7 @@
/* Only units in cities can be upgraded. */
if (pcity && pcity->owner == player_no) {
upgrade_unit(punit, to_unittype);
- ++number_of_upgraded_units;
+ number_of_upgraded_units++;
if ((pplayer->economic.gold -= cost) < cost) {
/* We can't upgrade any more units. */
break;
|
|