formatting cleanup src/*.c

Remove trailing spaces, and remove tabs from the files that had
trailing spaces.

Also, rndorcname() was using a random value to terminate a loop
and was recalculating a new one each iteration.
This commit is contained in:
PatR
2018-10-02 16:53:22 -07:00
parent 1110786ec2
commit 14bef9a02d
16 changed files with 75 additions and 80 deletions
+27 -29
View File
@@ -793,44 +793,42 @@ enum earlyarg e_arg;
userea = &argv[i][1]; userea = &argv[i][1];
} }
match = match_optname(userea, earlyopts[idx].name, match = match_optname(userea, earlyopts[idx].name,
earlyopts[idx].minlength, earlyopts[idx].valallowed); earlyopts[idx].minlength,
earlyopts[idx].valallowed);
if (match) break; if (match) break;
} }
if (match) { if (match) {
const char *extended_opt = index(userea,':'); const char *extended_opt = index(userea, ':');
if (!extended_opt) if (!extended_opt)
extended_opt = index(userea, '='); extended_opt = index(userea, '=');
switch(e_arg) { switch(e_arg) {
case ARG_DEBUG: case ARG_DEBUG:
if (extended_opt) { if (extended_opt) {
extended_opt++; extended_opt++;
debug_fields(extended_opt); debug_fields(extended_opt);
}
return 1;
break;
case ARG_VERSION: {
boolean insert_into_pastebuf = FALSE;
if (extended_opt) {
extended_opt++;
if (match_optname(extended_opt, "paste",
5, FALSE)) {
insert_into_pastebuf = TRUE;
} else {
raw_printf(
"-%sversion can only be extended with -%sversion:paste.\n",
dashdash, dashdash);
return TRUE;
}
}
early_version_info(insert_into_pastebuf);
return 2;
break;
} }
default: return 1;
break; case ARG_VERSION: {
boolean insert_into_pastebuf = FALSE;
if (extended_opt) {
extended_opt++;
if (match_optname(extended_opt, "paste", 5, FALSE)) {
insert_into_pastebuf = TRUE;
} else {
raw_printf(
"-%sversion can only be extended with -%sversion:paste.\n",
dashdash, dashdash);
return TRUE;
}
}
early_version_info(insert_into_pastebuf);
return 2;
}
default:
break;
} }
}; };
return FALSE; return FALSE;
+8 -11
View File
@@ -175,7 +175,7 @@ const char *goal;
} }
/* disgusting hack; the alternate selection characters work for any /* disgusting hack; the alternate selection characters work for any
getpos call, but only matter for dowhatis (and doquickwhatis) */ getpos call, but only matter for dowhatis (and doquickwhatis) */
doing_what_is = (goal == what_is_an_unknown_object); doing_what_is = (goal == what_is_an_unknown_object);
if (doing_what_is) { if (doing_what_is) {
Sprintf(kbuf, "'%s' or '%s' or '%s' or '%s'", Sprintf(kbuf, "'%s' or '%s' or '%s' or '%s'",
visctrl(Cmd.spkeys[NHKF_GETPOS_PICK]), visctrl(Cmd.spkeys[NHKF_GETPOS_PICK]),
@@ -2071,20 +2071,17 @@ char *
rndorcname(s) rndorcname(s)
char *s; char *s;
{ {
int i; static const char *v[] = { "a", "ai", "og", "u" };
const char *v[] = {"a", "ai", "og", "u"}; static const char *snd[] = { "gor", "gris", "un", "bane", "ruk",
const char *snd[] = {"gor", "gris", "un", "bane", "ruk", "oth","ul", "z", "thos","akh","hai" };
"oth","ul", "z", "thos","akh","hai"}; int i, iend = rn1(2, 3), vstart = rn2(2);
int vstart = rn2(2);
if (s) { if (s) {
*s = '\0'; *s = '\0';
for (i = 0; i < rn2(2) + 3; ++i) { for (i = 0; i < iend; ++i) {
vstart = 1 - vstart; /* 0 -> 1, 1 -> 0 */ vstart = 1 - vstart; /* 0 -> 1, 1 -> 0 */
if (!rn2(30) && i > 0) Sprintf(eos(s), "%s%s", (i > 0 && !rn2(30)) ? "-" : "",
(void) strcat(s, "-"); vstart ? v[rn2(SIZE(v))] : snd[rn2(SIZE(snd))]);
(void) sprintf(eos(s), "%s", vstart ? v[rn2(SIZE(v))] :
snd[rn2(SIZE(snd))]);
} }
} }
return s; return s;
+15 -12
View File
@@ -2156,24 +2156,27 @@ char sep;
return (char *) 0; return (char *) 0;
while (*str) { while (*str) {
if (*str == sep) nsep++; if (*str == sep)
str++; nsep++;
str++;
} }
csep = rn2(nsep); csep = rn2(nsep);
str = begin; str = begin;
while ((csep > 0) && *str) { while ((csep > 0) && *str) {
str++; str++;
if (*str == sep) csep--; if (*str == sep)
csep--;
} }
if (*str) { if (*str) {
if (*str == sep) str++; if (*str == sep)
begin = str; str++;
while (*str && *str != sep) { begin = str;
str++; while (*str && *str != sep) {
len++; str++;
} len++;
*str = '\0'; }
if (len) *str = '\0';
if (len)
return begin; return begin;
} }
return (char *) 0; return (char *) 0;
+1 -1
View File
@@ -1391,7 +1391,7 @@ int mmflags;
} }
if (allow_minvent && migrating_objs) if (allow_minvent && migrating_objs)
deliver_obj_to_mon(mtmp, 1, DF_NONE); /* in case there's waiting items */ deliver_obj_to_mon(mtmp, 1, DF_NONE); /* in case of waiting items */
if (!in_mklev) if (!in_mklev)
newsym(mtmp->mx, mtmp->my); /* make sure the mon shows up */ newsym(mtmp->mx, mtmp->my); /* make sure the mon shows up */
+1 -1
View File
@@ -782,7 +782,7 @@ struct attack *mattk;
/* Kill off aggressor if it didn't die. */ /* Kill off aggressor if it didn't die. */
if (!(result & MM_AGR_DIED)) { if (!(result & MM_AGR_DIED)) {
boolean was_leashed = (magr->mleashed); boolean was_leashed = (magr->mleashed != 0);
mondead(magr); mondead(magr);
if (!DEADMONSTER(magr)) if (!DEADMONSTER(magr))
-1
View File
@@ -805,7 +805,6 @@ stolen_booty(VOID_ARGS)
migrate_orc(mtmp, 0UL); migrate_orc(mtmp, 0UL);
} }
} }
ransacked = 0; ransacked = 0;
} }
+1 -1
View File
@@ -462,7 +462,7 @@ unsigned corpseflags;
* underneath it, you could be told the corpse type of a * underneath it, you could be told the corpse type of a
* monster that you never knew was there without this. * monster that you never knew was there without this.
* The code in hitmu() substitutes the word "something" * The code in hitmu() substitutes the word "something"
* if the corpses obj->dknown is 0. * if the corpse's obj->dknown is 0.
*/ */
if (Blind && !sensemon(mtmp)) if (Blind && !sensemon(mtmp))
obj->dknown = 0; obj->dknown = 0;
+4 -6
View File
@@ -255,13 +255,11 @@ struct monst *mon;
} }
} }
#define flees_light(mon) ((mon)->data == &mons[PM_GREMLIN] && \ #define flees_light(mon) ((mon)->data == &mons[PM_GREMLIN] \
(uwep && artifact_light(uwep) && uwep->lamplit)) && (uwep && artifact_light(uwep) && uwep->lamplit))
/* we could include this in the above macro, but probably overkill/overhead */ /* we could include this in the above macro, but probably overkill/overhead */
/* (!((which_armor((mon), W_ARMC) != 0) && ((which_armor((mon), W_ARMH) != 0))) && */ /* && (!(which_armor((mon), W_ARMC) != 0 */
/* && which_armor((mon), W_ARMH) != 0)) */
/* monster begins fleeing for the specified time, 0 means untimed flee /* monster begins fleeing for the specified time, 0 means untimed flee
* if first, only adds fleetime if monster isn't already fleeing * if first, only adds fleetime if monster isn't already fleeing
+1 -1
View File
@@ -1390,7 +1390,7 @@ boolean without_asking;
} }
display_nhwindow(datawin, FALSE); display_nhwindow(datawin, FALSE);
destroy_nhwindow(datawin), datawin = WIN_ERR; destroy_nhwindow(datawin), datawin = WIN_ERR;
} }
} }
} }