From 373651359e04b20a021fa65f1772b840a56b1e13 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Tue, 18 May 2010 22:09:01 +0200 Subject: [PATCH] Coding style fixes, mostly indentation and whitespace --- include/item.h | 32 ++++++++++++++--------------- include/land.h | 2 +- include/lost.h | 2 +- include/lwp.h | 10 +++++----- include/nat.h | 2 +- include/nsc.h | 2 +- src/client/servcmd.c | 2 +- src/lib/commands/cens.c | 4 ++-- src/lib/commands/edit.c | 2 +- src/lib/commands/fort.c | 2 +- src/lib/commands/info.c | 8 ++++---- src/lib/commands/mine.c | 2 +- src/lib/commands/navi.c | 8 ++++---- src/lib/commands/para.c | 4 ++-- src/lib/commands/pdump.c | 2 +- src/lib/commands/rada.c | 2 +- src/lib/commands/swap.c | 2 +- src/lib/commands/trad.c | 2 +- src/lib/commands/tran.c | 1 - src/lib/commands/upgr.c | 4 ++-- src/lib/commands/vers.c | 2 +- src/lib/commands/zdon.c | 2 +- src/lib/common/hours.c | 3 ++- src/lib/common/nsc.c | 30 ++++++++++++++-------------- src/lib/common/stmtch.c | 6 ++++-- src/lib/common/xdump.c | 2 +- src/lib/common/xundump.c | 4 ++-- src/lib/empthread/pthread.c | 2 +- src/lib/global/dir.c | 2 +- src/lib/global/symbol.c | 6 +++--- src/lib/player/accept.c | 4 ++-- src/lib/player/empdis.c | 4 ++-- src/lib/player/empmod.c | 2 +- src/lib/subs/mission.c | 2 +- src/lib/subs/nstr.c | 17 +++++++++------- src/lib/subs/paths.c | 2 +- src/lib/subs/pr.c | 5 ++--- src/lib/subs/sarg.c | 2 +- src/lib/subs/show.c | 6 +++--- src/lib/subs/shpsub.c | 3 +-- src/lib/subs/unitsub.c | 6 +++--- src/lib/update/deliver.c | 2 +- src/lib/update/plane.c | 4 ++-- src/lib/update/revolt.c | 2 +- src/lib/w32/sys/uio.h | 4 ++-- src/lib/w32/w32sockets.c | 40 ++++++++++++++++++------------------- src/util/fairland.c | 2 +- 47 files changed, 131 insertions(+), 130 deletions(-) diff --git a/include/item.h b/include/item.h index acace6dd..fc666fcf 100644 --- a/include/item.h +++ b/include/item.h @@ -49,22 +49,22 @@ enum { }; typedef enum { - I_NONE = -1, - I_CIVIL, - I_MILIT, - I_SHELL, - I_GUN, - I_PETROL, - I_IRON, - I_DUST, - I_BAR, - I_FOOD, - I_OIL, - I_LCM, - I_HCM, - I_UW, - I_RAD, - I_MAX = I_RAD + I_NONE = -1, + I_CIVIL, + I_MILIT, + I_SHELL, + I_GUN, + I_PETROL, + I_IRON, + I_DUST, + I_BAR, + I_FOOD, + I_OIL, + I_LCM, + I_HCM, + I_UW, + I_RAD, + I_MAX = I_RAD } ATTRIBUTE((packed)) i_type; struct ichrstr { diff --git a/include/land.h b/include/land.h index 289af2a5..3a625561 100644 --- a/include/land.h +++ b/include/land.h @@ -192,7 +192,7 @@ extern int lnd_hardtarget(struct lndstr *); extern int lnd_mar_one_sector(struct emp_qelem *, int, natid, int); extern int lnd_support(natid, natid, coord, coord, int); extern int lnd_can_attack(struct lndstr *); -extern int lnd_fortify (struct lndstr *lp, int hard_amt); +extern int lnd_fortify(struct lndstr *lp, int hard_amt); extern void lnd_set_tech(struct lndstr *, int); #endif diff --git a/include/lost.h b/include/lost.h index 6ce8f05d..07f2271d 100644 --- a/include/lost.h +++ b/include/lost.h @@ -47,7 +47,7 @@ struct loststr { natid lost_owner; /* Who lost it */ /* end of part matching struct empobj */ short lost_type; /* Type of thing (ship, plane, nuke, land, sector) */ - int lost_id; /* uid of lost thing (0 for sector)*/ + int lost_id; /* uid of lost thing (0 for sector) */ coord lost_x; coord lost_y; }; diff --git a/include/lwp.h b/include/lwp.h index 64c70a9e..02ccee06 100644 --- a/include/lwp.h +++ b/include/lwp.h @@ -61,17 +61,17 @@ struct lwpProc *lwpCreate(int prio, void (*)(void *), int size, int flags, char *name, int argc, char **argv, void *ud); void lwpExit(void); -void lwpTerminate(struct lwpProc * p); +void lwpTerminate(struct lwpProc *); void lwpYield(void); int lwpSleepFd(int fd, int flags, struct timeval *timeout); int lwpSleepUntil(time_t until); void lwpWakeup(struct lwpProc *); int lwpSigWait(sigset_t *set, int *sig); -void *lwpGetUD(struct lwpProc * p); -void lwpSetUD(struct lwpProc * p, char *ud); +void *lwpGetUD(struct lwpProc *); +void lwpSetUD(struct lwpProc *, char *ud); int lwpSetPriority(int prio); -char *lwpName(struct lwpProc * p); -void lwpSetName(struct lwpProc * p, char *name); +char *lwpName(struct lwpProc *); +void lwpSetName(struct lwpProc *, char *name); struct lwp_rwlock *lwp_rwlock_create(char *); void lwp_rwlock_destroy(struct lwp_rwlock *); diff --git a/include/nat.h b/include/nat.h index 926740bc..750d3211 100644 --- a/include/nat.h +++ b/include/nat.h @@ -183,7 +183,7 @@ extern int influx(struct natstr *np); extern struct natstr *nat_reset(struct natstr *, enum nat_status, coord, coord); extern int check_nat_name(char *cname); -extern int grant_btus(struct natstr *, int ); +extern int grant_btus(struct natstr *, int); /* nation flags */ #define NF_INFORM bit(0) /* Inform me of telegrams right away */ diff --git a/include/nsc.h b/include/nsc.h index 4f2afd6b..61d0e467 100644 --- a/include/nsc.h +++ b/include/nsc.h @@ -286,7 +286,7 @@ extern struct symbol sector_navigation[]; /* src/lib/subs/nstr.c */ extern int nstr_comp(struct nscstr *np, int len, int type, char *str); -extern char *nstr_comp_val(char *, struct valstr*, int); +extern char *nstr_comp_val(char *, struct valstr *, int); extern int nstr_exec(struct nscstr *, int, void *); /* src/lib/common/nstreval.c */ extern struct valstr *nstr_mksymval(struct valstr *, struct castr *, int); diff --git a/src/client/servcmd.c b/src/client/servcmd.c index 723c38b3..13a00d7e 100644 --- a/src/client/servcmd.c +++ b/src/client/servcmd.c @@ -112,7 +112,7 @@ servercmd(int code, char *arg, int len) break; case C_INFORM: if (arg[0] != '\n') { - snprintf(teles, sizeof(teles), "(%.*s) ", len -1, arg); + snprintf(teles, sizeof(teles), "(%.*s) ", len - 1, arg); if (!redir_fp) { putchar('\07'); prompt(code, the_prompt, teles); diff --git a/src/lib/commands/cens.c b/src/lib/commands/cens.c index 5ec65006..df79e0f3 100644 --- a/src/lib/commands/cens.c +++ b/src/lib/commands/cens.c @@ -85,9 +85,9 @@ cens(void) n = sect.sct_dist[I_FOOD] % 1000; pr("%c ", n == 0 ? '.' : '0' + (n / 100)); if (sect.sct_own != sect.sct_oldown) - pr("%3d", sect.sct_oldown); + pr("%3d", sect.sct_oldown); else - pr(" "); + pr(" "); pr("%5d", sect.sct_item[I_CIVIL]); pr("%5d", sect.sct_item[I_MILIT]); diff --git a/src/lib/commands/edit.c b/src/lib/commands/edit.c index 319372a7..4d7ebc6f 100644 --- a/src/lib/commands/edit.c +++ b/src/lib/commands/edit.c @@ -386,7 +386,7 @@ pr_ship(struct shpstr *ship) pr("Fleet : %.1s\n", &ship->shp_fleet); pr("Retreat path : '%s'\t\tRetreat Flags : %d\n", ship->shp_rpath, ship->shp_rflags); - pr("Plague Stage : %d\t\t",ship->shp_pstage); + pr("Plague Stage : %d\t\t", ship->shp_pstage); pr("Plague Time : %d\n", ship->shp_ptime); pr("civ mil uw food shl gun pet irn dst oil lcm hcm rad\n"); pr(" c m u f s g p i d o l h r\n"); diff --git a/src/lib/commands/fort.c b/src/lib/commands/fort.c index a147da1b..6606bcbc 100644 --- a/src/lib/commands/fort.c +++ b/src/lib/commands/fort.c @@ -82,7 +82,7 @@ fort(void) if (hard_amt <= 0) continue; - if (lnd_fortify (&land, hard_amt) <= 0) { + if (lnd_fortify(&land, hard_amt) <= 0) { pr("%s can't be fortified%s\n", prland(&land), land.lnd_harden >= land_mob_max ? " any further" : ""); continue; diff --git a/src/lib/commands/info.c b/src/lib/commands/info.c index 38e54196..dab5663b 100644 --- a/src/lib/commands/info.c +++ b/src/lib/commands/info.c @@ -320,7 +320,7 @@ info(void) default: pr("Error reading info dir\n"); logerror("Error (%lu) reading info dir(%s)\\file(%s)", - GetLastError(), infodir, filename); + GetLastError(), infodir, filename); } return RET_FAIL; } @@ -412,7 +412,7 @@ apro(void) lhitlim = 100; } - snprintf(filename, sizeof(filename), "%s\\*",infodir); + snprintf(filename, sizeof(filename), "%s\\*", infodir); hDir = FindFirstFile(filename, &fData); if (hDir == INVALID_HANDLE_VALUE) { if (GetLastError() == ERROR_PATH_NOT_FOUND) { @@ -421,7 +421,7 @@ apro(void) } else { pr("Error reading info dir\n"); logerror("Error (%lu) reading info dir(%s)\\file(%s)", - GetLastError(), infodir, filename); + GetLastError(), infodir, filename); } return RET_FAIL; } @@ -446,7 +446,7 @@ apro(void) (fData.dwFileAttributes == FILE_ATTRIBUTE_ARCHIVE) || (fData.dwFileAttributes == FILE_ATTRIBUTE_READONLY))) { snprintf(filename, sizeof(filename), "%s\\%s", infodir, - fData.cFileName); + fData.cFileName); fp = fopen(filename, "rb"); alreadyhit = 0; nll = nlhl = 0; diff --git a/src/lib/commands/mine.c b/src/lib/commands/mine.c index bef2f4ff..02c61773 100644 --- a/src/lib/commands/mine.c +++ b/src/lib/commands/mine.c @@ -109,7 +109,7 @@ landmine(void) continue; if (land.lnd_ship >= 0 || land.lnd_land >= 0) { pr("%s is on a %s\n", prland(&land), - land. lnd_ship >= 0 ? "ship" : "land unit"); + land.lnd_ship >= 0 ? "ship" : "land unit"); continue; } if (land.lnd_mobil < 1) { diff --git a/src/lib/commands/navi.c b/src/lib/commands/navi.c index 745208e6..3740b7a1 100644 --- a/src/lib/commands/navi.c +++ b/src/lib/commands/navi.c @@ -125,8 +125,8 @@ do_unit_move(struct emp_qelem *ulist, int *together, } if (!skip) nav_map(leader->x, leader->y, - type == EF_SHIP ? - !(mchr[(int)leader->type].m_flags & M_SUB) : 1); + type == EF_SHIP + ? !(mchr[(int)leader->type].m_flags & M_SUB) : 1); else skip = 0; sprintf(prompt, "<%.1f:%.1f: %s> ", *maxmob, @@ -171,7 +171,7 @@ do_unit_move(struct emp_qelem *ulist, int *together, if (dir >= 0) { if (type == EF_SHIP) { stopping |= shp_nav_one_sector(ulist, dir, - player->cnum, *together); + player->cnum, *together); if (stopping != 2) { *pt++ = dirch[dir]; *pt = '\0'; @@ -179,7 +179,7 @@ do_unit_move(struct emp_qelem *ulist, int *together, } else stopping |= lnd_mar_one_sector(ulist, dir, player->cnum, - *together); + *together); cp++; continue; } diff --git a/src/lib/commands/para.c b/src/lib/commands/para.c index deda7f19..db6feb80 100644 --- a/src/lib/commands/para.c +++ b/src/lib/commands/para.c @@ -81,8 +81,8 @@ para(void) pr("range to target is %d\n", ap_to_target); if (target.sct_own == player->cnum) { pr("You can't air-assault your own sector!\n"); - return RET_FAIL; - } + return RET_FAIL; + } /* * select planes within range */ diff --git a/src/lib/commands/pdump.c b/src/lib/commands/pdump.c index 530b5386..58ba76c5 100644 --- a/src/lib/commands/pdump.c +++ b/src/lib/commands/pdump.c @@ -264,7 +264,7 @@ pdump(void) case 19: pr(pln_is_in_orbit(&plane) && (plane.pln_flags & PLN_SYNCHRONOUS) - ? " Y" : " N"); + ? " Y" : " N"); break; case 20: if (getnuke(nuk_on_plane(&plane), &nuke)) { diff --git a/src/lib/commands/rada.c b/src/lib/commands/rada.c index c1479a5a..6563abe0 100644 --- a/src/lib/commands/rada.c +++ b/src/lib/commands/rada.c @@ -102,7 +102,7 @@ radar(int type) if (mchr[(int)item.ship.shp_type].m_flags & M_SONAR) tf = techfact(item.ship.shp_tech, 1.0); tech = techfact(item.ship.shp_tech, - mchr[(int)item.ship.shp_type].m_vrnge); + mchr[(int)item.ship.shp_type].m_vrnge); } else { if (!(lchr[(int)item.land.lnd_type].l_flags & L_RADAR)) { pr("%s can't use radar!\n", prland(&item.land)); diff --git a/src/lib/commands/swap.c b/src/lib/commands/swap.c index 9a70dc68..97eeca61 100644 --- a/src/lib/commands/swap.c +++ b/src/lib/commands/swap.c @@ -58,7 +58,7 @@ swaps(void) !getsect(sectb.sct_x, sectb.sct_y, §b)) return RET_SYN; print_res(§b); - if (!confirm ("Are you sure these are the two sectors you wish to swap? ")) + if (!confirm("Are you sure these are the two sectors you wish to swap? ")) return RET_FAIL; if (!check_sect_ok(§a) || !check_sect_ok(§b)) return RET_FAIL; diff --git a/src/lib/commands/trad.c b/src/lib/commands/trad.c index 9b066f53..64d0aed8 100644 --- a/src/lib/commands/trad.c +++ b/src/lib/commands/trad.c @@ -403,7 +403,7 @@ check_trade(void) "The bidding is over & you bought %s #%d from %s for $%.2f\n", trade_nameof(&trade, &tg), saveid, cname(trade.trd_owner), price); - } + } return RET_OK; } diff --git a/src/lib/commands/tran.c b/src/lib/commands/tran.c index b6ee3552..059f07cb 100644 --- a/src/lib/commands/tran.c +++ b/src/lib/commands/tran.c @@ -255,4 +255,3 @@ tran_nmap(coord curx, coord cury, char *arg) { return display_region_map(0, EF_NUKE, curx, cury, arg); } - diff --git a/src/lib/commands/upgr.c b/src/lib/commands/upgr.c index f1aac4ee..33b4add4 100644 --- a/src/lib/commands/upgr.c +++ b/src/lib/commands/upgr.c @@ -40,8 +40,8 @@ #include "ship.h" enum { - UPGR_COST = 15, /* how much avail and money to charge */ - UPGR_EFF = 35 /* efficiency reduction */ + UPGR_COST = 15, /* how much avail and money to charge */ + UPGR_EFF = 35 /* efficiency reduction */ }; static int lupgr(void); diff --git a/src/lib/commands/vers.c b/src/lib/commands/vers.c index bdb9124e..27b1b4a0 100644 --- a/src/lib/commands/vers.c +++ b/src/lib/commands/vers.c @@ -201,7 +201,7 @@ vers(void) pr("Fallout decays by %.0f%% per update\n", 100.0 - (decay_per_etu + 6.0) * fallout_spread * MIN(24, etu_per_update) * 100.0); pr("\n"); - pr ("Damage to\t\t\tSpills to\n"); + pr("Damage to\t\t\tSpills to\n"); pr("\t Sector People Mater. Ships Planes LandU.\n"); pr("Sector\t\t --\t%3.0f%%\t100%%\t 0%%\t%3.0f%%\t%3.0f%%\n", people_damage * 100.0, unit_damage / 0.07, unit_damage * 100.0); diff --git a/src/lib/commands/zdon.c b/src/lib/commands/zdon.c index d9655bc4..c2aa6005 100644 --- a/src/lib/commands/zdon.c +++ b/src/lib/commands/zdon.c @@ -81,7 +81,7 @@ zdon(void) if (*p == 'y' || *p == 'Y') { checking = 0; wantupd = 1; - } else if (*p == 'n' || *p == 'N') { + } else if (*p == 'n' || *p == 'N') { checking = 0; wantupd = 0; } else { diff --git a/src/lib/common/hours.c b/src/lib/common/hours.c index 07696ed1..e548f2a8 100644 --- a/src/lib/common/hours.c +++ b/src/lib/common/hours.c @@ -117,7 +117,8 @@ weekday(char *str, int *wday) */ static char *day_name[7] = { "sunday", "monday", "tuesday", "wednesday", - "thursday", "friday", "saturday" }; + "thursday", "friday", "saturday" + }; int i, j; for (; isspace(*str); ++str) ; diff --git a/src/lib/common/nsc.c b/src/lib/common/nsc.c index b3b79079..606d2f3a 100644 --- a/src/lib/common/nsc.c +++ b/src/lib/common/nsc.c @@ -211,21 +211,21 @@ struct castr dchr_ca[] = { }; #define NSC_GENITEM(ef_type, ef_chr) \ - {"uid", empobjoff(uid), NSC_INT, 0, NULL, ef_type, 0}, \ + {"uid", empobjoff(uid), NSC_INT, 0, NULL, ef_type, 0}, \ {"timestamp", empobjoff(timestamp), NSC_TIME, 0, NULL, EF_BAD, NSC_EXTRA}, \ - {"owner", empobjoff(own), NSC_NATID, 0, NULL, EF_NATION, 0}, \ - {"xloc", empobjoff(x), NSC_XCOORD, 0, NULL, EF_BAD, 0}, \ - {"yloc", empobjoff(y), NSC_YCOORD, 0, NULL, EF_BAD, 0}, \ - {"type", empobjoff(type), NSC_CHAR, 0, NULL, ef_chr, 0}, \ - {"effic", empobjoff(effic), NSC_CHAR, 0, NULL, EF_BAD, 0}, \ - {"mobil", empobjoff(mobil), NSC_CHAR , 0, NULL, EF_BAD, 0}, \ - {"off", empobjoff(off), NSC_UCHAR , 0, NULL, EF_BAD, 0}, \ - {"tech", empobjoff(tech), NSC_SHORT, 0, NULL, EF_BAD, 0}, \ - {"group", empobjoff(group), NSC_STRINGY, 1, NULL, EF_BAD, NSC_EXTRA}, \ - {"opx", empobjoff(opx), NSC_XCOORD, 0, NULL, EF_BAD, 0}, \ - {"opy", empobjoff(opy), NSC_YCOORD, 0, NULL, EF_BAD, 0}, \ - {"mission", empobjoff(mission), NSC_SHORT, 0, NULL, EF_MISSIONS, 0}, \ - {"radius", empobjoff(radius), NSC_SHORT, 0, NULL, EF_BAD, 0} + {"owner", empobjoff(own), NSC_NATID, 0, NULL, EF_NATION, 0}, \ + {"xloc", empobjoff(x), NSC_XCOORD, 0, NULL, EF_BAD, 0}, \ + {"yloc", empobjoff(y), NSC_YCOORD, 0, NULL, EF_BAD, 0}, \ + {"type", empobjoff(type), NSC_CHAR, 0, NULL, ef_chr, 0}, \ + {"effic", empobjoff(effic), NSC_CHAR, 0, NULL, EF_BAD, 0}, \ + {"mobil", empobjoff(mobil), NSC_CHAR , 0, NULL, EF_BAD, 0}, \ + {"off", empobjoff(off), NSC_UCHAR , 0, NULL, EF_BAD, 0}, \ + {"tech", empobjoff(tech), NSC_SHORT, 0, NULL, EF_BAD, 0}, \ + {"group", empobjoff(group), NSC_STRINGY, 1, NULL, EF_BAD, NSC_EXTRA}, \ + {"opx", empobjoff(opx), NSC_XCOORD, 0, NULL, EF_BAD, 0}, \ + {"opy", empobjoff(opy), NSC_YCOORD, 0, NULL, EF_BAD, 0}, \ + {"mission", empobjoff(mission), NSC_SHORT, 0, NULL, EF_MISSIONS, 0}, \ + {"radius", empobjoff(radius), NSC_SHORT, 0, NULL, EF_BAD, 0} struct castr ship_ca[] = { #define CURSTR struct shpstr @@ -482,7 +482,7 @@ struct castr news_ca[] = { struct castr lost_ca[] = { #define CURSTR struct loststr - /* no need for uid as long as it's not referenced from other tables */ + /* no need for uid as long as it's not referenced from other tables */ {"timestamp", fldoff(lost_timestamp), NSC_TIME, 0, NULL, EF_BAD, 0}, {"owner", fldoff(lost_owner), NSC_NATID, 0, NULL, EF_NATION, 0}, diff --git a/src/lib/common/stmtch.c b/src/lib/common/stmtch.c index adb80e4f..fd2cde04 100644 --- a/src/lib/common/stmtch.c +++ b/src/lib/common/stmtch.c @@ -84,7 +84,9 @@ mineq(char *a, char *b) /* find common prefix: */ for (i = 0; a[i] != 0 && a[i] == b[i]; i++) ; - if (a[i] != 0) return ME_MISMATCH; - if (b[i] == 0 || b[i] == ' ') return ME_EXACT; + if (a[i] != 0) + return ME_MISMATCH; + if (b[i] == 0 || b[i] == ' ') + return ME_EXACT; return ME_PARTIAL; } diff --git a/src/lib/common/xdump.c b/src/lib/common/xdump.c index ea7128c8..43a3d83a 100644 --- a/src/lib/common/xdump.c +++ b/src/lib/common/xdump.c @@ -288,7 +288,7 @@ xdcolhdr(struct xdstr *xd, struct castr ca[]) n = ca[i].ca_type != NSC_STRINGY ? ca[i].ca_len : 0; if (n) { for (j = 0; j < n; j++) { - xd->pr("%s%s(%d)",sep, ca[i].ca_name, j); + xd->pr("%s%s(%d)", sep, ca[i].ca_name, j); sep = " "; } } else { diff --git a/src/lib/common/xundump.c b/src/lib/common/xundump.c index 022c0ee2..b3d5af89 100644 --- a/src/lib/common/xundump.c +++ b/src/lib/common/xundump.c @@ -349,7 +349,7 @@ deffld(int fldno, char *name, int idx) int res; res = stmtch(name, ca, offsetof(struct castr, ca_name), - sizeof(struct castr)); + sizeof(struct castr)); if (res < 0) return gripe("Header %s of field %d is %s", name, fldno + 1, res == M_NOTUNIQUE ? "ambiguous" : "unknown"); @@ -851,7 +851,7 @@ xufooter(FILE *fp, struct castr ca[], int recs) res = -1; if (human) { - if (fscanf(fp, "config%n", &res) != 0 || res < 0) + if (fscanf(fp, "config%n", &res) != 0 || res < 0) return gripe("Malformed table footer"); } else { if (fscanf(fp, "%d", &n) != 1) diff --git a/src/lib/empthread/pthread.c b/src/lib/empthread/pthread.c index 7ce03f5e..4b01694e 100644 --- a/src/lib/empthread/pthread.c +++ b/src/lib/empthread/pthread.c @@ -439,7 +439,7 @@ empth_rwlock_wrlock(empth_rwlock_t *rwlock) empth_status("waiting for wrlock %s", rwlock->name); pthread_cond_wait(&rwlock->can_write, &mtx_ctxsw); empth_status("got wrlock %s %d %d", - rwlock->name, rwlock->nread, rwlock->nwrite); + rwlock->name, rwlock->nread, rwlock->nwrite); empth_restorectx(); } } diff --git a/src/lib/global/dir.c b/src/lib/global/dir.c index 337fa2cf..bfb65671 100644 --- a/src/lib/global/dir.c +++ b/src/lib/global/dir.c @@ -64,5 +64,5 @@ signed char dirindex[] = { /* must agree with dirch[] and DIR_ defines */ char *routech[] = { - " ", " /", " >"," \\","/ ","< ","\\ " + " ", " /", " >", " \\", "/ ", "< ", "\\ " }; diff --git a/src/lib/global/symbol.c b/src/lib/global/symbol.c index a00457db..f27312fc 100644 --- a/src/lib/global/symbol.c +++ b/src/lib/global/symbol.c @@ -87,7 +87,7 @@ struct symbol meta_flags[] = { {0, NULL} }; -struct symbol meta_type[] = { +struct symbol meta_type[] = { {NSC_LONG, "d"}, {NSC_DOUBLE, "g"}, {NSC_STRING, "s"}, @@ -101,7 +101,7 @@ struct symbol meta_type[] = { {NSC_HIDDEN, "d"}, {NSC_TIME, "d"}, {NSC_FLOAT, "g"}, - {NSC_STRINGY,"c"}, + {NSC_STRINGY, "c"}, {NSC_NOTYPE, NULL} }; @@ -150,7 +150,7 @@ struct symbol nation_relations[] = { struct symbol nation_status[] = { {STAT_UNUSED, "unused"}, - {STAT_NEW, "new"}, + {STAT_NEW, "new"}, {STAT_VIS, "visitor"}, {STAT_SANCT, "sanctuary"}, {STAT_ACTIVE, "active"}, diff --git a/src/lib/player/accept.c b/src/lib/player/accept.c index 2a410642..9c87d23a 100644 --- a/src/lib/player/accept.c +++ b/src/lib/player/accept.c @@ -76,10 +76,10 @@ player_new(int s) lp = malloc(sizeof(struct player)); if (!lp) - return NULL; + return NULL; memset(lp, 0, sizeof(struct player)); idle_timeout.tv_sec = max_idle * 60; - idle_timeout.tv_usec = 0 ; + idle_timeout.tv_usec = 0; if (s >= 0) { /* real player, not dummy created by update and market update */ lp->iop = io_open(s, IO_READ | IO_WRITE, IO_BUFSIZE, idle_timeout); diff --git a/src/lib/player/empdis.c b/src/lib/player/empdis.c index 51ceb53b..238812c1 100644 --- a/src/lib/player/empdis.c +++ b/src/lib/player/empdis.c @@ -167,7 +167,7 @@ disable_coms(void) cmd = comtch(name, player_coms, -1); if (cmd < 0) { logerror("Warning: not disabling %s command %s\n", - cmd == M_NOTUNIQUE ? "ambiguous" : "unknown", name); + cmd == M_NOTUNIQUE ? "ambiguous" : "unknown", name); continue; } player_coms[cmd].c_permit |= GOD; @@ -219,7 +219,7 @@ update_timeused(time_t now) void enforce_minimum_session_time(void) { - struct natstr *natp = getnatp(player->cnum); + struct natstr *natp = getnatp(player->cnum); time_t dt = natp->nat_last_logout - natp->nat_last_login; if (dt > seconds_since_midnight(natp->nat_last_logout)) diff --git a/src/lib/player/empmod.c b/src/lib/player/empmod.c index b9ec9d6a..38641b3e 100644 --- a/src/lib/player/empmod.c +++ b/src/lib/player/empmod.c @@ -101,7 +101,7 @@ struct cmndstr player_coms[] = { 0, edit, C_MOD, GOD}, {"enable", 0, enab, C_MOD, GOD}, {"enlist ", 2, enli, C_MOD, NORM + MONEY + CAP}, - {"execute ", 0, execute, 0, VIS + EXEC }, + {"execute ", 0, execute, 0, VIS + EXEC}, {"explore ", 1, explore, C_MOD, NORM + MONEY + CAP}, {"financial", 0, fina, 0, NORM}, diff --git a/src/lib/subs/mission.c b/src/lib/subs/mission.c index c13f5b53..2bff3f38 100644 --- a/src/lib/subs/mission.c +++ b/src/lib/subs/mission.c @@ -508,7 +508,7 @@ perform_mission_ship(int dam, struct shpstr *sp, coord x, coord y, } if (mcp->m_flags & M_SUB) { if (!targeting_ships) - return dam; /* subs interdict only ships */ + return dam; /* subs interdict only ships */ range = roundrange(torprange(sp)); if (md > range) return dam; diff --git a/src/lib/subs/nstr.c b/src/lib/subs/nstr.c index 5a60fcd1..6d9e8e42 100644 --- a/src/lib/subs/nstr.c +++ b/src/lib/subs/nstr.c @@ -199,8 +199,10 @@ static int strnncmp(char *s1, size_t sz1, char *s2, size_t sz2) { int res; - if (sz1 == sz2) return strncmp(s1, s2, sz2); - if (sz1 < sz2) return -strnncmp(s2, sz2, s1, sz1); + if (sz1 == sz2) + return strncmp(s1, s2, sz2); + if (sz1 < sz2) + return -strnncmp(s2, sz2, s1, sz1); res = strncmp(s1, s2, sz2); return res ? res : s1[sz2]; } @@ -278,7 +280,8 @@ nstr_parse_val(char *str, struct valstr *val) val->val_cat = NSC_VAL; val->val_as.str.base = str + 1; val->val_as.str.maxsz = tail - (str + 1); - if (*tail) ++tail; + if (*tail) + ++tail; /* FIXME else unclosed string */ return tail; } @@ -353,7 +356,7 @@ static int nstr_is_name_of_ca(struct valstr *val, struct castr *ca, int idx) { if (CANT_HAPPEN(val->val_cat != NSC_ID && idx >= 0)) - return 0; + return 0; return idx >= 0 && strlen(ca[idx].ca_name) == val->val_as.str.maxsz; } @@ -487,11 +490,11 @@ nstr_optype(enum nsc_type lft, enum nsc_type rgt) lft = nstr_promote(lft); rgt = nstr_promote(rgt); if (lft == rgt) - return lft; + return lft; if (lft == NSC_DOUBLE && rgt == NSC_LONG) - return NSC_DOUBLE; + return NSC_DOUBLE; if (rgt == NSC_DOUBLE && lft == NSC_LONG) - return NSC_DOUBLE; + return NSC_DOUBLE; return NSC_NOTYPE; } diff --git a/src/lib/subs/paths.c b/src/lib/subs/paths.c index 4a95ed38..ac621540 100644 --- a/src/lib/subs/paths.c +++ b/src/lib/subs/paths.c @@ -110,7 +110,7 @@ getpath(char *buf, char *arg, coord x, coord y, int onlyown, getsect(x, y, §); - more: +more: while (*p) { if (sarg_xy(p, &dx, &dy)) { bp = NULL; diff --git a/src/lib/subs/pr.c b/src/lib/subs/pr.c index 1698d4c4..215e46ca 100644 --- a/src/lib/subs/pr.c +++ b/src/lib/subs/pr.c @@ -544,7 +544,7 @@ copy_ascii_no_funny(char *dst, char *src) if ((ch < 0x20 && ch != '\t' && ch != '\n') || ch == 0x7f) ; /* ignore funny control */ else if (ch > 0x7f) - *p++ = '?'; /* replace non-ASCII */ + *p++ = '?'; /* replace non-ASCII */ else *p++ = ch; } @@ -619,8 +619,7 @@ ufindpfx(char *s, int n) { int i = 0; - while (n && s[i]) - { + while (n && s[i]) { if ((s[i++] & 0xc0) == 0xc0) while ((s[i] & 0xc0) == 0x80) i++; diff --git a/src/lib/subs/sarg.c b/src/lib/subs/sarg.c index e75fb212..3cc4c4b7 100644 --- a/src/lib/subs/sarg.c +++ b/src/lib/subs/sarg.c @@ -85,7 +85,7 @@ sarg_xy(char *str, coord *xp, coord *yp) return 0; y = strtoy(str, &str); if (y < 0 || (*str != 0 && !isspace(*str))) - return 0; + return 0; if ((x ^ y) & 1) return 0; np = getnatp(player->cnum); diff --git a/src/lib/subs/show.c b/src/lib/subs/show.c index 99703eae..c2b065f8 100644 --- a/src/lib/subs/show.c +++ b/src/lib/subs/show.c @@ -605,7 +605,7 @@ show_news(int tlev) if (rpt[i].r_newspage == N_NOTUSED) continue; pr("%-2d %-20.20s %4d\n", rpt[i].r_uid, - page_headings[rpt[i].r_newspage].name, rpt[i].r_good_will); + page_headings[rpt[i].r_newspage].name, rpt[i].r_good_will); for (j = 0; j < NUM_RPTS; j++) pr(" %s\n", rpt[i].r_newstory[j]); } @@ -686,12 +686,12 @@ fmttime2822(time_t t) (time->tm_isdst ? tzi.DaylightBias : tzi.StandardBias)); nn = _snprintf(buf + n, sizeof(buf) - n, " %+03d%02d", - time_offset/60, abs(time_offset) % 60); + time_offset / 60, abs(time_offset) % 60); if (CANT_HAPPEN(nn <= 0 || nn + n >= sizeof(buf))) buf[0] = 0; #else size_t n = strftime(buf, sizeof(buf), "%a, %d %b %Y %T %z", - localtime(&t)); + localtime(&t)); if (CANT_HAPPEN(n == 0)) buf[0] = 0; #endif diff --git a/src/lib/subs/shpsub.c b/src/lib/subs/shpsub.c index 35ef1546..1bacf515 100644 --- a/src/lib/subs/shpsub.c +++ b/src/lib/subs/shpsub.c @@ -627,8 +627,7 @@ shp_fort_interdiction(struct emp_qelem *list, coord newx, coord newy, mpr(victim, "Incoming fire does %d damage!\n", dam); #if 0 mpr(victim, "%s fires at you for %d!\n", - xyas(fsect.sct_x,fsect.sct_y,victim), - dam); + xyas(fsect.sct_x, fsect.sct_y, victim), dam); #endif wu(0, fsect.sct_own, "%s fires at %s ships in %s for %d!\n", diff --git a/src/lib/subs/unitsub.c b/src/lib/subs/unitsub.c index ea575682..4563b294 100644 --- a/src/lib/subs/unitsub.c +++ b/src/lib/subs/unitsub.c @@ -161,7 +161,7 @@ unit_path(int together, struct empobj *unit, char *buf) d_sect.sct_x, d_sect.sct_y, player->cnum); if (!cp || unit->mobil <= 0) { pr("Can't get to '%s' right now.\n", - xyas(d_sect.sct_x, d_sect.sct_y, player->cnum)); + xyas(d_sect.sct_x, d_sect.sct_y, player->cnum)); return NULL; } } else { @@ -201,8 +201,8 @@ unit_view(struct emp_qelem *list) pr("[oil:%d] ", sect.sct_oil); } pr("%s @ %s %d%% %s\n", obj_nameof(&ulp->unit.gen), - xyas(ulp->unit.gen.x, ulp->unit.gen.y, player->cnum), - sect.sct_effic, dchr[sect.sct_type].d_name); + xyas(ulp->unit.gen.x, ulp->unit.gen.y, player->cnum), + sect.sct_effic, dchr[sect.sct_type].d_name); } } diff --git a/src/lib/update/deliver.c b/src/lib/update/deliver.c index 908cd29a..b6dd7844 100644 --- a/src/lib/update/deliver.c +++ b/src/lib/update/deliver.c @@ -45,7 +45,7 @@ deliver(struct sctstr *from, struct ichrstr *ip, int dir, int thresh, int amt_src, int plague, enum i_packing packing) { struct sctstr *to; - i_type vtype; /* item vartype */ + i_type vtype; /* item vartype */ int amt_moved; int amt_dst; int mobility; diff --git a/src/lib/update/plane.c b/src/lib/update/plane.c index 752271e6..1269447f 100644 --- a/src/lib/update/plane.c +++ b/src/lib/update/plane.c @@ -183,8 +183,8 @@ planerepair(struct plnstr *pp, struct natstr *np, struct bp *bp, int etus) delta = 100 - pp->pln_effic; memset(mvec, 0, sizeof(mvec)); - mvec[I_MILIT] = pcp->pl_crew; - mvec[I_LCM] = pcp->pl_lcm; + mvec[I_MILIT] = pcp->pl_crew; + mvec[I_LCM] = pcp->pl_lcm; mvec[I_HCM] = pcp->pl_hcm; build = get_materials(sp, bp, mvec, delta); diff --git a/src/lib/update/revolt.c b/src/lib/update/revolt.c index 74733313..7a01b35d 100644 --- a/src/lib/update/revolt.c +++ b/src/lib/update/revolt.c @@ -346,7 +346,7 @@ guerrilla(struct sctstr *sp) uw -= n; sp->sct_item[I_UW] = uw; } - domove: +domove: if (move && che > 0) { struct sctstr *nicest_sp = NULL; if (convert) diff --git a/src/lib/w32/sys/uio.h b/src/lib/w32/sys/uio.h index 27ec5f03..00281f82 100644 --- a/src/lib/w32/sys/uio.h +++ b/src/lib/w32/sys/uio.h @@ -39,9 +39,9 @@ struct iovec { /* Base address of a memory region for input or output. */ - void *iov_base; + void *iov_base; /* The size of the memory pointed to by iov_base. */ - size_t iov_len; + size_t iov_len; }; extern ssize_t readv(int fd, const struct iovec *iov, int iovcnt); diff --git a/src/lib/w32/w32sockets.c b/src/lib/w32/w32sockets.c index 7df1427c..c91bc6d0 100644 --- a/src/lib/w32/w32sockets.c +++ b/src/lib/w32/w32sockets.c @@ -81,33 +81,32 @@ fd_is_socket(int fd, SOCKET *sockp) void w32_set_winsock_errno(void) { - int err = WSAGetLastError(); - WSASetLastError(0); + int err = WSAGetLastError(); + WSASetLastError(0); - /* Map some WSAE* errors to the runtime library's error codes. */ - switch (err) - { + /* Map some WSAE* errors to the runtime library's error codes. */ + switch (err) { case WSA_INVALID_HANDLE: - errno = EBADF; - break; + errno = EBADF; + break; case WSA_NOT_ENOUGH_MEMORY: - errno = ENOMEM; - break; + errno = ENOMEM; + break; case WSA_INVALID_PARAMETER: - errno = EINVAL; - break; + errno = EINVAL; + break; case WSAEWOULDBLOCK: - errno = EAGAIN; - break; + errno = EAGAIN; + break; case WSAENAMETOOLONG: - errno = ENAMETOOLONG; - break; + errno = ENAMETOOLONG; + break; case WSAENOTEMPTY: - errno = ENOTEMPTY; - break; + errno = ENOTEMPTY; + break; default: - errno = (err > 10000 && err < 10025) ? err - 10000 : err; - break; + errno = (err > 10000 && err < 10025) ? err - 10000 : err; + break; } } @@ -284,8 +283,7 @@ fcntl(int fd, int cmd, ...) unsigned long nonblocking; SOCKET sock; - switch (cmd) - { + switch (cmd) { case F_GETFL: return 0; case F_SETFL: diff --git a/src/util/fairland.c b/src/util/fairland.c index 83ee883a..d4120cac 100644 --- a/src/util/fairland.c +++ b/src/util/fairland.c @@ -1167,7 +1167,7 @@ write_newcap_script(void) } static void -qprint(const char * const fmt, ...) +qprint(const char *const fmt, ...) { va_list ap;