From afa95659104786bc40c2471d382fdc026bef0857 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 13 Mar 2021 15:10:56 +0200 Subject: [PATCH 30/30] Add spaces around '=' in assignments in C-code A couple of places were still missing them. See osdn #41770 Signed-off-by: Marko Lindqvist --- ai/default/aihand.c | 2 +- ai/tex/texaiplayer.c | 2 +- ai/threaded/taiplayer.c | 2 +- client/control.c | 4 ++-- client/gui-gtk-3.22/chatline.c | 2 +- client/gui-gtk-3.22/gamedlgs.c | 6 +++--- client/gui-gtk-3.22/helpdlg.c | 2 +- client/gui-gtk-3.22/menu.c | 4 +++- client/gui-gtk-3.22/repodlgs.c | 3 ++- client/gui-gtk-4.0/chatline.c | 2 +- client/gui-gtk-4.0/editgui.c | 2 +- client/gui-gtk-4.0/menu.c | 3 ++- client/gui-gtk-4.0/repodlgs.c | 3 ++- client/gui-qt/dialogs.cpp | 4 ++-- client/gui-qt/menu.cpp | 2 +- client/gui-sdl2/helpdlg.c | 2 +- client/helpdata.c | 2 +- client/options.c | 3 ++- client/packhand.c | 14 +++++++------- common/networking/connection.c | 2 +- server/cityhand.c | 4 ++-- server/citytools.c | 10 +++++----- server/cityturn.c | 8 ++++---- server/civserver.c | 10 +++++----- server/generator/mapgen.c | 16 ++++++++-------- server/maphand.c | 2 +- server/plrhand.c | 2 +- server/report.c | 14 +++++++------- server/stdinhand.c | 2 +- utility/netintf.c | 2 +- 30 files changed, 71 insertions(+), 65 deletions(-) diff --git a/ai/default/aihand.c b/ai/default/aihand.c index 80a7cfa795..38563e7182 100644 --- a/ai/default/aihand.c +++ b/ai/default/aihand.c @@ -229,7 +229,7 @@ static void dai_manage_taxes(struct ai_type *ait, struct player *pplayer) int delta_tax = 0, delta_sci = 0; #ifdef DEBUG_TIMERS - struct timer *taxtimer= NULL; + struct timer *taxtimer = NULL; #endif struct cm_parameter cmp; diff --git a/ai/tex/texaiplayer.c b/ai/tex/texaiplayer.c index 1258e4d613..cc1c14d973 100644 --- a/ai/tex/texaiplayer.c +++ b/ai/tex/texaiplayer.c @@ -165,7 +165,7 @@ struct unit_list *texai_player_units(struct player *pplayer) **************************************************************************/ static enum texai_abort_msg_class texai_check_messages(struct ai_type *ait) { - enum texai_abort_msg_class ret_abort= TEXAI_ABORT_NONE; + enum texai_abort_msg_class ret_abort = TEXAI_ABORT_NONE; texaimsg_list_allocate_mutex(exthrai.msgs_to.msglist); while (texaimsg_list_size(exthrai.msgs_to.msglist) > 0) { diff --git a/ai/threaded/taiplayer.c b/ai/threaded/taiplayer.c index a0c76bd17a..959879ed10 100644 --- a/ai/threaded/taiplayer.c +++ b/ai/threaded/taiplayer.c @@ -96,7 +96,7 @@ static void tai_thread_start(void *arg) **************************************************************************/ static enum tai_abort_msg_class tai_check_messages(struct ai_type *ait) { - enum tai_abort_msg_class ret_abort= TAI_ABORT_NONE; + enum tai_abort_msg_class ret_abort = TAI_ABORT_NONE; taimsg_list_allocate_mutex(thrai.msgs_to.msglist); while (taimsg_list_size(thrai.msgs_to.msglist) > 0) { diff --git a/client/control.c b/client/control.c index 4adaaaeb2e..e703d59855 100644 --- a/client/control.c +++ b/client/control.c @@ -1984,7 +1984,7 @@ void request_unit_disband(struct unit *punit) **************************************************************************/ void request_unit_change_homecity(struct unit *punit) { - struct city *pcity=tile_city(unit_tile(punit)); + struct city *pcity = tile_city(unit_tile(punit)); if (pcity) { request_do_action(ACTION_HOME_CITY, punit->id, pcity->id, 0, ""); @@ -1996,7 +1996,7 @@ void request_unit_change_homecity(struct unit *punit) **************************************************************************/ void request_unit_upgrade(struct unit *punit) { - struct city *pcity=tile_city(unit_tile(punit)); + struct city *pcity = tile_city(unit_tile(punit)); if (pcity) { request_do_action(ACTION_UPGRADE_UNIT, punit->id, pcity->id, 0, ""); diff --git a/client/gui-gtk-3.22/chatline.c b/client/gui-gtk-3.22/chatline.c index 99990b534e..34e3c7a679 100644 --- a/client/gui-gtk-3.22/chatline.c +++ b/client/gui-gtk-3.22/chatline.c @@ -163,7 +163,7 @@ static void inputline_return(GtkEntry *w, gpointer data) } genlist_prepend(history_list, fc_strdup(theinput)); - history_pos=-1; + history_pos = -1; } gtk_entry_set_text(w, ""); diff --git a/client/gui-gtk-3.22/gamedlgs.c b/client/gui-gtk-3.22/gamedlgs.c index a06576143e..0d3741db31 100644 --- a/client/gui-gtk-3.22/gamedlgs.c +++ b/client/gui-gtk-3.22/gamedlgs.c @@ -503,9 +503,9 @@ static GtkWidget *create_rates_dialog(void) gtk_widget_show_all(shell); - rates_tax_value=-1; - rates_lux_value=-1; - rates_sci_value=-1; + rates_tax_value = -1; + rates_lux_value = -1; + rates_sci_value = -1; rates_tax_sig = g_signal_connect_after(rates_tax_scale, "value-changed", diff --git a/client/gui-gtk-3.22/helpdlg.c b/client/gui-gtk-3.22/helpdlg.c index f2b214f5e2..b05d70a5a1 100644 --- a/client/gui-gtk-3.22/helpdlg.c +++ b/client/gui-gtk-3.22/helpdlg.c @@ -1539,7 +1539,7 @@ static void help_item_zoom(GtkTreePath *path) model = gtk_tree_view_get_model(GTK_TREE_VIEW(help_view)); gtk_tree_model_get_iter(model, &item, path); - for (child=item; gtk_tree_model_iter_parent(model, &it, &child); child=it) { + for (child = item; gtk_tree_model_iter_parent(model, &it, &child); child=it) { GtkTreePath *it_path; it_path = gtk_tree_model_get_path(model, &it); diff --git a/client/gui-gtk-3.22/menu.c b/client/gui-gtk-3.22/menu.c index d08c10d30f..eb46607d16 100644 --- a/client/gui-gtk-3.22/menu.c +++ b/client/gui-gtk-3.22/menu.c @@ -2154,9 +2154,11 @@ void real_menus_update(void) if (get_num_units_in_focus() > 0) { const struct tile *ptile = NULL; const struct unit_type *ptype = NULL; + punits = get_units_in_focus(); unit_list_iterate(punits, punit) { - fc_assert((ptile==NULL) == (ptype==NULL)); + fc_assert((ptile == NULL) == (ptype == NULL)); + if (ptile || ptype) { if (unit_tile(punit) != ptile) { units_all_same_tile = FALSE; diff --git a/client/gui-gtk-3.22/repodlgs.c b/client/gui-gtk-3.22/repodlgs.c index 120a8934bf..15fec40eef 100644 --- a/client/gui-gtk-3.22/repodlgs.c +++ b/client/gui-gtk-3.22/repodlgs.c @@ -1299,9 +1299,10 @@ static GtkListStore *units_report_store_new(void) { int i; GType cols[URD_COL_NUM]; + fc_assert(ARRAY_SIZE(unit_report_columns) == URD_COL_NUM); - for (i=0; iitemData(index).toBool()) { is_male->setChecked(true); is_female->setChecked(false); - selected_sex=0; + selected_sex = 0; } else { is_male->setChecked(false); is_female->setChecked(true); - selected_sex=1; + selected_sex = 1; } } diff --git a/client/gui-qt/menu.cpp b/client/gui-qt/menu.cpp index 2902b1be27..0590013481 100644 --- a/client/gui-qt/menu.cpp +++ b/client/gui-qt/menu.cpp @@ -1725,7 +1725,7 @@ void mr_menu::setup_menus() **************************************************************************/ void mr_menu::set_tile_for_order(tile *ptile) { - for (int i=0; i < units_list.nr_units; i++) { + for (int i = 0; i < units_list.nr_units; i++) { units_list.unit_list.at(units_list.unit_list.count() - i -1)->ptile = ptile; } } diff --git a/client/gui-sdl2/helpdlg.c b/client/gui-sdl2/helpdlg.c index cdf4b480ad..a6a8b7d02e 100644 --- a/client/gui-sdl2/helpdlg.c +++ b/client/gui-sdl2/helpdlg.c @@ -782,7 +782,7 @@ void popup_unit_info(Unit_type_id type_id) } punittype = utype_by_number(type_id); - unit_name_label= create_iconlabel_from_chars( + unit_name_label = create_iconlabel_from_chars( adj_surf(get_unittype_surface(punittype, direction8_invalid())), pwindow->dst, utype_name_translation(punittype), adj_font(24), WF_FREE_THEME); diff --git a/client/helpdata.c b/client/helpdata.c index 94cfb38a3d..c0c3e6dd51 100644 --- a/client/helpdata.c +++ b/client/helpdata.c @@ -1115,7 +1115,7 @@ void boot_help_texts(void) } free(paras); paras = NULL; - pitem->text=fc_strdup(long_buffer); + pitem->text = fc_strdup(long_buffer); help_list_append(help_nodes, pitem); } section_list_iterate_end; diff --git a/client/options.c b/client/options.c index 7dfc8b5b02..619c420d1a 100644 --- a/client/options.c +++ b/client/options.c @@ -5964,10 +5964,11 @@ static void options_init_names(const struct copt_val_name *(*acc)(int), { int val; const struct copt_val_name *name; + fc_assert_ret(NULL != acc); *support = strvec_new(); *pretty = strvec_new(); - for (val=0; (name = acc(val)); val++) { + for (val = 0; (name = acc(val)); val++) { strvec_append(*support, name->support); strvec_append(*pretty, name->pretty); } diff --git a/client/packhand.c b/client/packhand.c index fd3dca36be..36e1da310e 100644 --- a/client/packhand.c +++ b/client/packhand.c @@ -731,7 +731,7 @@ void handle_city_info(const struct packet_city_info *packet) need_science_dialog_update = TRUE; } - pcity->food_stock=packet->food_stock; + pcity->food_stock = packet->food_stock; if (pcity->shield_stock != packet->shield_stock) { shield_stock_changed = TRUE; pcity->shield_stock = packet->shield_stock; @@ -775,9 +775,9 @@ void handle_city_info(const struct packet_city_info *packet) worklist_copy(&pcity->worklist, &packet->worklist); pcity->airlift = packet->airlift; - pcity->did_buy=packet->did_buy; - pcity->did_sell=packet->did_sell; - pcity->was_happy=packet->was_happy; + pcity->did_buy = packet->did_buy; + pcity->did_sell = packet->did_sell; + pcity->was_happy = packet->was_happy; pcity->turn_founded = packet->turn_founded; pcity->turn_last_built = packet->turn_last_built; @@ -797,9 +797,9 @@ void handle_city_info(const struct packet_city_info *packet) } pcity->changed_from = product; - pcity->before_change_shields=packet->before_change_shields; - pcity->disbanded_shields=packet->disbanded_shields; - pcity->caravan_shields=packet->caravan_shields; + pcity->before_change_shields = packet->before_change_shields; + pcity->disbanded_shields = packet->disbanded_shields; + pcity->caravan_shields = packet->caravan_shields; pcity->last_turns_shield_surplus = packet->last_turns_shield_surplus; improvement_iterate(pimprove) { diff --git a/common/networking/connection.c b/common/networking/connection.c index 13456f26f3..1b8b7f049a 100644 --- a/common/networking/connection.c +++ b/common/networking/connection.c @@ -197,7 +197,7 @@ static int write_socket_data(struct connection *pc, } if (FD_ISSET(pc->sock, &writefs)) { - nblock=MIN(buf->ndata-start, MAX_LEN_PACKET); + nblock = MIN(buf->ndata-start, MAX_LEN_PACKET); log_debug("trying to write %d limit=%d", nblock, limit); if ((nput = fc_writesocket(pc->sock, (const char *)buf->data+start, nblock)) == -1) { diff --git a/server/cityhand.c b/server/cityhand.c index facb59b5dc..6a7c0e9ee8 100644 --- a/server/cityhand.c +++ b/server/cityhand.c @@ -246,7 +246,7 @@ void really_handle_city_sell(struct player *pplayer, struct city *pcity, return; } - pcity->did_sell=TRUE; + pcity->did_sell = TRUE; price = impr_sell_gold(pimprove); notify_player(pplayer, pcity->tile, E_IMP_SOLD, ftc_server, PL_("You sell %s in %s for %d gold.", @@ -343,7 +343,7 @@ void really_handle_city_buy(struct player *pplayer, struct city *pcity) /* As we never put penalty on disbanded_shields, we can * fully well add the missing shields there. */ pcity->disbanded_shields += total - pcity->shield_stock; - pcity->shield_stock=total; /* AI wants this -- Syela */ + pcity->shield_stock = total; /* AI wants this -- Syela */ pcity->did_buy = TRUE; /* !PS: no need to set buy flag otherwise */ } city_refresh(pcity); diff --git a/server/citytools.c b/server/citytools.c index bcfa1011b7..a246275ab1 100644 --- a/server/citytools.c +++ b/server/citytools.c @@ -2485,19 +2485,19 @@ void package_city(struct city *pcity, struct packet_city_info *packet, packet->production_kind = pcity->production.kind; packet->production_value = universal_number(&pcity->production); - packet->turn_last_built=pcity->turn_last_built; + packet->turn_last_built = pcity->turn_last_built; packet->turn_founded = pcity->turn_founded; packet->changed_from_kind = pcity->changed_from.kind; packet->changed_from_value = universal_number(&pcity->changed_from); - packet->before_change_shields=pcity->before_change_shields; - packet->disbanded_shields=pcity->disbanded_shields; - packet->caravan_shields=pcity->caravan_shields; + packet->before_change_shields = pcity->before_change_shields; + packet->disbanded_shields = pcity->disbanded_shields; + packet->caravan_shields = pcity->caravan_shields; packet->last_turns_shield_surplus = pcity->last_turns_shield_surplus; worklist_copy(&packet->worklist, &pcity->worklist); - packet->diplomat_investigate=dipl_invest; + packet->diplomat_investigate = dipl_invest; packet->airlift = pcity->airlift; packet->did_buy = pcity->did_buy; diff --git a/server/cityturn.c b/server/cityturn.c index f167e65db2..80d3b55bd7 100644 --- a/server/cityturn.c +++ b/server/cityturn.c @@ -3120,8 +3120,8 @@ static void define_orig_production_values(struct city *pcity) **************************************************************************/ static void nullify_caravan_and_disband_plus(struct city *pcity) { - pcity->disbanded_shields=0; - pcity->caravan_shields=0; + pcity->disbanded_shields = 0; + pcity->caravan_shields = 0; } /**********************************************************************//** @@ -3131,7 +3131,7 @@ static void nullify_caravan_and_disband_plus(struct city *pcity) void nullify_prechange_production(struct city *pcity) { nullify_caravan_and_disband_plus(pcity); - pcity->before_change_shields=0; + pcity->before_change_shields = 0; } /**********************************************************************//** @@ -3320,7 +3320,7 @@ static bool disband_city(struct city *pcity) { struct player *pplayer = city_owner(pcity); struct tile *ptile = pcity->tile; - struct city *rcity=NULL; + struct city *rcity = NULL; const struct unit_type *utype = pcity->production.value.utype; struct unit *punit; int saved_id = pcity->id; diff --git a/server/civserver.c b/server/civserver.c index 944059d73b..339740221d 100644 --- a/server/civserver.c +++ b/server/civserver.c @@ -507,7 +507,7 @@ static void Mac_options(int argc) short the_type; Handle the_handle; Rect the_rect; - short the_item, old_item=16; + short the_item, old_item = 16; int done = false; Str255 the_string; @@ -532,11 +532,11 @@ static void Mac_options(int argc) exit(EXIT_FAILURE); } /* insert default highlight draw code? */ - err=SetDialogCancelItem(optptr, 2); + err = SetDialogCancelItem(optptr, 2); if (err != 0) { exit(EXIT_FAILURE); } - err=SetDialogTracksCursor(optptr, true); + err = SetDialogTracksCursor(optptr, true); if (err != 0) { exit(EXIT_FAILURE); } @@ -557,7 +557,7 @@ static void Mac_options(int argc) break; case 13: GetDItem(optptr, 13, &the_type, &the_handle, &the_rect); - srvarg.metaserver_no_send=GetCtlValue((ControlHandle)the_handle); + srvarg.metaserver_no_send = GetCtlValue((ControlHandle)the_handle); SetCtlValue((ControlHandle)the_handle, !srvarg.metaserver_no_send); break; case 15: @@ -565,7 +565,7 @@ static void Mac_options(int argc) case 17: GetDItem(optptr, old_item, &the_type, &the_handle, &the_rect); SetCtlValue((ControlHandle)the_handle, false); - old_item=the_item; + old_item = the_item; GetDItem(optptr, the_item, &the_type, &the_handle, &the_rect); SetCtlValue((ControlHandle)the_handle, true); break; diff --git a/server/generator/mapgen.c b/server/generator/mapgen.c index 4bc89c9058..7edcfee1e7 100644 --- a/server/generator/mapgen.c +++ b/server/generator/mapgen.c @@ -2222,7 +2222,7 @@ static void initworld(struct gen234_state *pstate) #define DMSIS 10 /**********************************************************************//** - island base map generators + Island base map generators **************************************************************************/ static void mapgenerator2(void) { @@ -2231,7 +2231,7 @@ static void mapgenerator2(void) struct gen234_state *pstate = &state; int i; bool done = FALSE; - int spares= 1; + int spares = 1; /* constant that makes up that an island actually needs additional space */ /* put 70% of land in big continents, @@ -2346,7 +2346,7 @@ static void mapgenerator3(void) pstate->totalmass = (((wld.map.ysize - 6 - spares) * wld.map.server.landpercent * (wld.map.xsize - spares)) / 100); - bigislands= player_count(); + bigislands = player_count(); landmass = (wld.map.xsize * (wld.map.ysize - 6) * wld.map.server.landpercent)/100; /* subtracting the arctics */ @@ -2360,7 +2360,7 @@ static void mapgenerator3(void) islandmass = (landmass)/(2 * bigislands); } if (islandmass < 3 * maxmassdiv6 && player_count() * 2 < landmass) { - islandmass= (landmass)/(bigislands); + islandmass = (landmass)/(bigislands); } if (islandmass < 2) { @@ -2394,7 +2394,7 @@ static void mapgenerator3(void) size = fc_rand((islandmass + 1) / 2 + 1); } if (size < 2) { - size=2; + size = 2; } make_island(size, (pstate->isleindex - 2 <= player_count()) ? 1 : 0, @@ -2435,11 +2435,11 @@ static void mapgenerator4(void) } if (wld.map.server.landpercent > 60) { - bigweight=30; + bigweight = 30; } else if (wld.map.server.landpercent > 40) { - bigweight=50; + bigweight = 50; } else { - bigweight=70; + bigweight = 70; } spares = (wld.map.server.landpercent - 5) / 30; diff --git a/server/maphand.c b/server/maphand.c index 24c964c18c..b1488e2fdd 100644 --- a/server/maphand.c +++ b/server/maphand.c @@ -165,7 +165,7 @@ void climate_change(bool warming, int effect) /* If the preferred transformation is ruled out for some exceptional reason * specific to this tile, fall back to the other, rather than letting this * tile be immune to change. */ - for (i=0; i<2; i++) { + for (i = 0; i < 2; i++) { new = candidates[i]; /* If the preferred transformation simply hasn't been specified diff --git a/server/plrhand.c b/server/plrhand.c index be8a46e0b1..cda1899165 100644 --- a/server/plrhand.c +++ b/server/plrhand.c @@ -1134,7 +1134,7 @@ static void package_player_common(struct player *plr, packet->barbarian_type = plr->ai_common.barbarian_type; packet->phase_done = plr->phase_done; - packet->nturns_idle=plr->nturns_idle; + packet->nturns_idle = plr->nturns_idle; for (i = 0; i < B_LAST/*improvement_count()*/; i++) { packet->wonders[i] = plr->wonders[i]; diff --git a/server/report.c b/server/report.c index 5c7b1a20ee..d96bd4cc4a 100644 --- a/server/report.c +++ b/server/report.c @@ -74,14 +74,14 @@ static void plrdata_slot_replace(struct plrdata_slot *plrdata, static void plrdata_slot_free(struct plrdata_slot *plrdata); static void page_conn_etype(struct conn_list *dest, const char *caption, - const char *headline, const char *lines, - enum event_type event); + const char *headline, const char *lines, + enum event_type event); enum historian_type { - HISTORIAN_RICHEST=0, - HISTORIAN_ADVANCED=1, - HISTORIAN_MILITARY=2, - HISTORIAN_HAPPIEST=3, - HISTORIAN_LARGEST=4}; + HISTORIAN_RICHEST = 0, + HISTORIAN_ADVANCED = 1, + HISTORIAN_MILITARY = 2, + HISTORIAN_HAPPIEST = 3, + HISTORIAN_LARGEST = 4}; #define HISTORIAN_FIRST HISTORIAN_RICHEST #define HISTORIAN_LAST HISTORIAN_LARGEST diff --git a/server/stdinhand.c b/server/stdinhand.c index 93fbbab0b6..2407e22a99 100644 --- a/server/stdinhand.c +++ b/server/stdinhand.c @@ -6377,7 +6377,7 @@ static void show_help_command_list(struct connection *caller, int j; buf[0] = '\0'; - for (i=0, j=0; i