diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1997-01-17 07:14:33 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1997-01-17 07:14:33 +0000 |
commit | 3e150a880447536a0af58c395e5a857635e985d3 (patch) | |
tree | 867c3504f60ee9bfd2fa5db3dd66d5b3a1649ecd /games/hack | |
parent | 8e78a24e2e89c03ac53bd758a1781c925fe7ab71 (diff) |
r?index -> strr?chr
Diffstat (limited to 'games/hack')
29 files changed, 104 insertions, 106 deletions
diff --git a/games/hack/hack.c b/games/hack/hack.c index 5261e183b33..e18c9686a13 100644 --- a/games/hack/hack.c +++ b/games/hack/hack.c @@ -380,7 +380,7 @@ pickup(all) char c; pline("Pick up %s ? [ynaq]", doname(obj)); - while(!index("ynaq ", (c = readchar()))) + while(!strchr("ynaq ", (c = readchar()))) bell(); if(c == 'q') return; if(c == 'n') continue; @@ -571,7 +571,7 @@ register struct monst *mtmp; for(x = u.ux-1; x <= u.ux+1; x++) for(y = u.uy-1; y <= u.uy+1; y++){ if(x == u.ux && y == u.uy) continue; if((mtmp = m_at(x,y)) && !mtmp->mimic && !mtmp->mtame && - !mtmp->mpeaceful && !index("Ea", mtmp->data->mlet) && + !mtmp->mpeaceful && !strchr("Ea", mtmp->data->mlet) && !mtmp->mfroz && !mtmp->msleep && /* aplvax!jcn */ (!mtmp->minvis || See_invisible)) return(1); diff --git a/games/hack/hack.cmd.c b/games/hack/hack.cmd.c index 0af29895588..64457125f5d 100644 --- a/games/hack/hack.cmd.c +++ b/games/hack/hack.cmd.c @@ -234,7 +234,7 @@ char sym; register char *dp; u.dz = 0; - if(!(dp = index(sdir, sym))) return(0); + if(!(dp = strchr(sdir, sym))) return(0); u.dx = xdir[dp-sdir]; u.dy = ydir[dp-sdir]; u.dz = zdir[dp-sdir]; @@ -249,7 +249,7 @@ boolean s; if(s) pline("In what direction?"); dirsym = readchar(); if(!movecmd(dirsym) && !u.dz) { - if(!index(quitchars, dirsym)) + if(!strchr(quitchars, dirsym)) pline("What a strange direction!"); return(0); } diff --git a/games/hack/hack.do_name.c b/games/hack/hack.do_name.c index c50d45cd13f..93e73b40da6 100644 --- a/games/hack/hack.do_name.c +++ b/games/hack/hack.do_name.c @@ -170,7 +170,7 @@ register struct obj *obj; otemp.quan = 1; otemp.onamelth = 0; str = xname(&otemp); - pline("Call %s %s: ", index(vowels,*str) ? "an" : "a", str); + pline("Call %s %s: ", strchr(vowels,*str) ? "an" : "a", str); getlin(buf); clrlin(); if(!*buf || *buf == '\033') diff --git a/games/hack/hack.do_wear.c b/games/hack/hack.do_wear.c index 2084b630201..169dffd68bb 100644 --- a/games/hack/hack.do_wear.c +++ b/games/hack/hack.do_wear.c @@ -53,7 +53,7 @@ doremring() { char answer; pline("What ring, Right or Left? [ rl?]"); - if(index(quitchars, (answer = readchar()))) + if(strchr(quitchars, (answer = readchar()))) return(0); switch(answer) { case 'l': @@ -198,7 +198,7 @@ dowearring() { char answer; pline("What ring-finger, Right or Left? "); - if(index(quitchars, (answer = readchar()))) + if(strchr(quitchars, (answer = readchar()))) return(0); switch(answer){ case 'l': diff --git a/games/hack/hack.dog.c b/games/hack/hack.dog.c index d9192a4c7c5..80b2f08f4ea 100644 --- a/games/hack/hack.dog.c +++ b/games/hack/hack.dog.c @@ -164,7 +164,7 @@ int info[9]; edog->droptime = moves; } } else { - if(obj = o_at(omx,omy)) if(!index("0_", obj->olet)){ + if(obj = o_at(omx,omy)) if(!strchr("0_", obj->olet)){ if((otyp = dogfood(obj)) <= CADAVER){ nix = omx; niy = omy; @@ -398,7 +398,7 @@ register struct obj *obj; #ifndef NOWORM mtmp->wormno || #endif NOWORM - mtmp->isshk || mtmp->isgd || index(" &@12", mtmp->data->mlet)) + mtmp->isshk || mtmp->isgd || strchr(" &@12", mtmp->data->mlet)) return(0); /* no tame long worms? */ if(obj) { if(dogfood(obj) >= MANFOOD) return(0); diff --git a/games/hack/hack.eat.c b/games/hack/hack.eat.c index 7745f63feb2..05f140a07e4 100644 --- a/games/hack/hack.eat.c +++ b/games/hack/hack.eat.c @@ -360,7 +360,7 @@ newuhs(incr) boolean incr; { poisonous(otmp) register struct obj *otmp; { - return(index(POISONOUS, CORPSE_I_TO_C(otmp->otyp)) != 0); + return(strchr(POISONOUS, CORPSE_I_TO_C(otmp->otyp)) != 0); } /* returns 1 if some text was printed */ @@ -373,7 +373,7 @@ register tp = 0; pline("You get very sick."); Sick = 10 + rn2(10); u.usick_cause = objects[otmp->otyp].oc_name; - } else if(index(POISONOUS, let) && rn2(5)){ + } else if(strchr(POISONOUS, let) && rn2(5)){ tp++; pline("Ecch -- that must have been poisonous!"); if(!Poison_resistance){ @@ -381,7 +381,7 @@ register tp = 0; losehp(rnd(15), "poisonous corpse"); } else pline("You don't seem affected by the poison."); - } else if(index("ELNOPQRUuxz", let) && rn2(5)){ + } else if(strchr("ELNOPQRUuxz", let) && rn2(5)){ tp++; pline("You feel sick."); losehp(rnd(8), "cadaver"); diff --git a/games/hack/hack.end.c b/games/hack/hack.end.c index 20b77e4f689..067d576dce5 100644 --- a/games/hack/hack.end.c +++ b/games/hack/hack.end.c @@ -95,11 +95,11 @@ register char *st1; if(*st1 == 'd' && st1[1] == 'r') killer = "drowning"; else if(*st1 == 'p') killer = "panic"; else if(*st1 == 't') killer = "trickery"; else - if(!index("bcd", *st1)) killer = st1; + if(!strchr("bcd", *st1)) killer = st1; paybill(); clearlocks(); if(flags.toplin == 1) more(); - if(index("bcds", *st1)){ + if(strchr("bcds", *st1)){ #ifdef WIZARD if(!wizard) #endif WIZARD @@ -426,7 +426,7 @@ char linebuf[BUFSZ]; if(killed) Sprintf(eos(linebuf), " by %s%s", (!strncmp(t1->death, "trick", 5) || !strncmp(t1->death, "the ", 4)) ? "" : - index(vowels,*t1->death) ? "an " : "a ", + strchr(vowels,*t1->death) ? "an " : "a ", t1->death); Sprintf(eos(linebuf), "."); if(t1->maxhp) { @@ -538,7 +538,7 @@ prscore(argc,argv) int argc; char **argv; { if(!argv[1][2]){ argc--; argv++; - } else if(!argv[1][3] && index("CFKSTWX", argv[1][2])) { + } else if(!argv[1][3] && strchr("CFKSTWX", argv[1][2])) { argv[1]++; argv[1][0] = '-'; } else argv[1] += 2; @@ -638,7 +638,7 @@ prscore(argc,argv) int argc; char **argv; { .hacklog or something in his home directory. */ flags.beginner = (total_score < 6000); for(i=0; i<6; i++) - if(!index(totchars, "CFKSTWX"[i])) { + if(!strchr(totchars, "CFKSTWX"[i])) { flags.beginner = 1; if(!pl_character[0]) pl_character[0] = "CFKSTWX"[i]; break; diff --git a/games/hack/hack.fight.c b/games/hack/hack.fight.c index 92d11c2ea4a..0bee9ca238d 100644 --- a/games/hack/hack.fight.c +++ b/games/hack/hack.fight.c @@ -20,7 +20,7 @@ register struct permonst *pa = magr->data, *pd = mdef->data; int hit; schar tmp; boolean vis; - if(index("Eauy", pa->mlet)) return(0); + if(strchr("Eauy", pa->mlet)) return(0); if(magr->mfroz) return(0); /* riv05!a3 */ tmp = pd->ac + pa->mlevel; if(mdef->mconf || mdef->mfroz || mdef->msleep){ @@ -88,7 +88,7 @@ register struct permonst *pd = mdef->data; /* drop a rock and remove monster */ monstone(mdef) register struct monst *mdef; { extern char mlarge[]; - if(index(mlarge, mdef->data->mlet)) + if(strchr(mlarge, mdef->data->mlet)) mksobj_at(ENORMOUS_ROCK, mdef->mx, mdef->my); else mksobj_at(ROCK, mdef->mx, mdef->my); @@ -151,7 +151,7 @@ register thrown; if(obj == uwep && (obj->otyp > SPEAR || obj->otyp < BOOMERANG)) tmp = rnd(2); else { - if(index(mlarge, mon->data->mlet)) { + if(strchr(mlarge, mon->data->mlet)) { tmp = rnd(objects[obj->otyp].wldam); if(obj->otyp == TWO_HANDED_SWORD) tmp += d(2,6); else if(obj->otyp == FLAIL) tmp += rnd(4); @@ -194,7 +194,7 @@ register thrown; killed(mon); return(FALSE); case CLOVE_OF_GARLIC: /* no effect against demons */ - if(index(UNDEAD, mon->data->mlet)) + if(strchr(UNDEAD, mon->data->mlet)) mon->mflee = 1; tmp = 1; break; @@ -304,7 +304,7 @@ register struct monst *mtmp; else if(uwep->otyp == DAGGER) tmp += 2; else if(uwep->otyp == CRYSKNIFE) tmp += 3; else if(uwep->otyp == SPEAR && - index("XDne", mdat->mlet)) tmp += 2; + strchr("XDne", mdat->mlet)) tmp += 2; } if(mtmp->msleep) { mtmp->msleep = 0; diff --git a/games/hack/hack.invent.c b/games/hack/hack.invent.c index 3cc42763a1d..00f8b2124c5 100644 --- a/games/hack/hack.invent.c +++ b/games/hack/hack.invent.c @@ -321,7 +321,7 @@ register char *let,*word; ilet = 'a'; for(otmp = invent; otmp; otmp = otmp->nobj){ - if(!*let || index(let, otmp->olet)) { + if(!*let || strchr(let, otmp->olet)) { bp[foo++] = flags.invlet_constant ? otmp->invlet : ilet; /* ugly check: remove inappropriate things */ @@ -383,7 +383,7 @@ register char *let,*word; pline("No count allowed with this command."); continue; } - if(index(quitchars,ilet)) + if(strchr(quitchars,ilet)) return((struct obj *)0); if(ilet == '-') { return(allownone ? &zeroobj : (struct obj *) 0); @@ -426,7 +426,7 @@ register char *let,*word; } break; } - if(!allowall && let && !index(let,otmp->olet)) { + if(!allowall && let && !strchr(let,otmp->olet)) { pline("That is a silly thing to %s.",word); return(0); } @@ -469,7 +469,7 @@ xchar allowgold = (u.ugold && !strcmp(word, "drop")) ? 1 : 0; /* BAH */ if(allowgold) ilets[iletct++] = '$'; ilets[iletct] = 0; while(otmp) { - if(!index(ilets, otmp->olet)){ + if(!strchr(ilets, otmp->olet)){ ilets[iletct++] = otmp->olet; ilets[iletct] = 0; } @@ -501,8 +501,8 @@ xchar allowgold = (u.ugold && !strcmp(word, "drop")) ? 1 : 0; /* BAH */ } else if(sym == 'a' || sym == 'A') allflag = TRUE; else if(sym == 'u' || sym == 'U') ckfn = ckunpaid; else - if(index("!%?[()=*/\"0", sym)){ - if(!index(olets, sym)){ + if(strchr("!%?[()=*/\"0", sym)){ + if(!strchr(olets, sym)){ olets[oletct++] = sym; olets[oletct] = 0; } @@ -536,7 +536,7 @@ register int cnt = 0; for(otmp = objchn; otmp; otmp = otmp2){ if(ilet == 'z') ilet = 'A'; else ilet++; otmp2 = otmp->nobj; - if(olets && *olets && !index(olets, otmp->olet)) continue; + if(olets && *olets && !strchr(olets, otmp->olet)) continue; if(ckfn && !(*ckfn)(otmp)) continue; if(!allflag) { pline(xprname(otmp, ilet)); @@ -623,7 +623,7 @@ register char *lets; ilet = 'a'; for(otmp = invent; otmp; otmp = otmp->nobj) { if(flags.invlet_constant) ilet = otmp->invlet; - if(!lets || !*lets || index(lets, ilet)) { + if(!lets || !*lets || strchr(lets, ilet)) { cornline(1, xprname(otmp, ilet)); any[ct++] = ilet; } @@ -652,7 +652,7 @@ dotypeinv () /* free after Robert Viduya */ if(u.ugold) stuff[stct++] = '$'; stuff[stct] = 0; for(otmp = invent; otmp; otmp = otmp->nobj) { - if (!index (stuff, otmp->olet)) { + if (!strchr (stuff, otmp->olet)) { stuff[stct++] = otmp->olet; stuff[stct] = 0; } @@ -667,7 +667,7 @@ dotypeinv () /* free after Robert Viduya */ pline ("What type of object [%s] do you want an inventory of? ", stuff); c = readchar(); - if(index(quitchars,c)) return(0); + if(strchr(quitchars,c)) return(0); } else c = stuff[0]; @@ -777,7 +777,7 @@ merged(otmp,obj,lose) register struct obj *otmp, *obj; { obj->spe == otmp->spe && obj->dknown == otmp->dknown && obj->cursed == otmp->cursed && - (index("%*?!", obj->olet) || + (strchr("%*?!", obj->olet) || (obj->known == otmp->known && (obj->olet == WEAPON_SYM && obj->otyp < BOOMERANG)))) { otmp->quan += obj->quan; diff --git a/games/hack/hack.lev.c b/games/hack/hack.lev.c index e15d39ee0fd..8b65b87cfeb 100644 --- a/games/hack/hack.lev.c +++ b/games/hack/hack.lev.c @@ -199,7 +199,7 @@ xchar lev; long newhp; /* tmoves may be very large */ mtmp2 = mtmp->nmon; - if(index(genocided, mtmp->data->mlet)) { + if(strchr(genocided, mtmp->data->mlet)) { mondead(mtmp); continue; } @@ -210,7 +210,7 @@ xchar lev; } newhp = mtmp->mhp + - (index(MREGEN, mtmp->data->mlet) ? tmoves : tmoves/20); + (strchr(MREGEN, mtmp->data->mlet) ? tmoves : tmoves/20); if(newhp > mtmp->mhpmax) mtmp->mhp = mtmp->mhpmax; else diff --git a/games/hack/hack.main.c b/games/hack/hack.main.c index 58501936082..4772ae29bca 100644 --- a/games/hack/hack.main.c +++ b/games/hack/hack.main.c @@ -236,7 +236,7 @@ char *argv[]; register char *gp = genocided; while(pm < mons+CMNUM+2){ - if(!index(sfoo, pm->mlet)) + if(!strchr(sfoo, pm->mlet)) *gp++ = pm->mlet; pm++; } diff --git a/games/hack/hack.makemon.c b/games/hack/hack.makemon.c index f7fc0ecbe55..fbe58dbf466 100644 --- a/games/hack/hack.makemon.c +++ b/games/hack/hack.makemon.c @@ -8,7 +8,6 @@ static char rcsid[] = "$NetBSD: hack.makemon.c,v 1.3 1995/03/23 08:30:38 cgd Exp #include "hack.h" extern char fut_geno[]; -extern char *index(); extern struct obj *mkobj_at(); struct monst zeromonst; @@ -31,18 +30,18 @@ register struct permonst *ptr; if(x != 0 || y != 0) if(m_at(x,y)) return((struct monst *) 0); if(ptr){ - if(index(fut_geno, ptr->mlet)) return((struct monst *) 0); + if(strchr(fut_geno, ptr->mlet)) return((struct monst *) 0); } else { ct = CMNUM - strlen(fut_geno); - if(index(fut_geno, 'm')) ct++; /* make only 1 minotaur */ - if(index(fut_geno, '@')) ct++; + if(strchr(fut_geno, 'm')) ct++; /* make only 1 minotaur */ + if(strchr(fut_geno, '@')) ct++; if(ct <= 0) return(0); /* no more monsters! */ tmp = rn2(ct*dlevel/24 + 7); if(tmp < dlevel - 4) tmp = rn2(ct*dlevel/24 + 12); if(tmp >= ct) tmp = rn1(ct - ct/2, ct/2); for(ct = 0; ct < CMNUM; ct++){ ptr = &mons[ct]; - if(index(fut_geno, ptr->mlet)) + if(strchr(fut_geno, ptr->mlet)) continue; if(!tmp--) goto gotmon; } @@ -87,7 +86,7 @@ gotmon: if(ptr->mlet == 'I' || ptr->mlet == ';') mtmp->minvis = 1; if(ptr->mlet == 'L' || ptr->mlet == 'N' - || (in_mklev && index("&w;", ptr->mlet) && rn2(5)) + || (in_mklev && strchr("&w;", ptr->mlet) && rn2(5)) ) mtmp->msleep = 1; #ifndef NOWORM diff --git a/games/hack/hack.mhitu.c b/games/hack/hack.mhitu.c index 430bfa42204..1ac2ce4176b 100644 --- a/games/hack/hack.mhitu.c +++ b/games/hack/hack.mhitu.c @@ -63,11 +63,11 @@ register struct monst *mtmp; mtmp->minvis = 0; pmon(mtmp); } - if(!index("1&DuxynNF",mdat->mlet)) + if(!strchr("1&DuxynNF",mdat->mlet)) tmp = hitu(mtmp,d(mdat->damn,mdat->damd)); else tmp = 0; - if(index(UNDEAD, mdat->mlet) && midnight()) + if(strchr(UNDEAD, mdat->mlet) && midnight()) tmp += hitu(mtmp,d(mdat->damn,mdat->damd)); ctmp = tmp && !mtmp->mcan && diff --git a/games/hack/hack.mklev.c b/games/hack/hack.mklev.c index 5e8c7b51f04..623bd0074d6 100644 --- a/games/hack/hack.mklev.c +++ b/games/hack/hack.mklev.c @@ -679,7 +679,7 @@ register struct mkroom *croom; if(!num || num >= TRAPNUM) { nopierc = (dlevel < 4) ? 1 : 0; nomimic = (dlevel < 9 || goldseen ) ? 1 : 0; - if(index(fut_geno, 'M')) nomimic = 1; + if(strchr(fut_geno, 'M')) nomimic = 1; kind = rn2(TRAPNUM - nopierc - nomimic); /* note: PIERC = 7, MIMIC = 8, TRAPNUM = 9 */ } else kind = num; diff --git a/games/hack/hack.mkobj.c b/games/hack/hack.mkobj.c index d4e37fd7928..2231c0e45d0 100644 --- a/games/hack/hack.mkobj.c +++ b/games/hack/hack.mkobj.c @@ -63,7 +63,7 @@ register otyp; otmp->quan = 1; otmp->olet = let; otmp->otyp = otyp; - otmp->dknown = index("/=!?*", let) ? 0 : 1; + otmp->dknown = strchr("/=!?*", let) ? 0 : 1; switch(let) { case WEAPON_SYM: otmp->quan = (otmp->otyp <= ROCK) ? rn1(6,6) : 1; diff --git a/games/hack/hack.mon.c b/games/hack/hack.mon.c index 56dedce6d32..de75086e630 100644 --- a/games/hack/hack.mon.c +++ b/games/hack/hack.mon.c @@ -170,7 +170,7 @@ register struct monst *mtmp; panic("bad monster %c (%d)",mdat->mlet,mdat->mlevel); /* regenerate monsters */ - if((!(moves%20) || index(MREGEN, mdat->mlet)) && + if((!(moves%20) || strchr(MREGEN, mdat->mlet)) && mtmp->mhp < mtmp->mhpmax) mtmp->mhp++; @@ -182,8 +182,8 @@ register struct monst *mtmp; /* Nymphs and Leprechauns do not easily wake up */ if(cansee(mtmp->mx,mtmp->my) && (!Stealth || (mdat->mlet == 'e' && rn2(10))) && - (!index("NL",mdat->mlet) || !rn2(50)) && - (Aggravate_monster || index("d1", mdat->mlet) + (!strchr("NL",mdat->mlet) || !rn2(50)) && + (Aggravate_monster || strchr("d1", mdat->mlet) || (!rn2(7) && !mtmp->mimic))) mtmp->msleep = 0; else return(0); @@ -196,7 +196,7 @@ register struct monst *mtmp; if(mtmp->mconf && !rn2(50)) mtmp->mconf = 0; /* some monsters teleport */ - if(mtmp->mflee && index("tNL", mdat->mlet) && !rn2(40)){ + if(mtmp->mflee && strchr("tNL", mdat->mlet) && !rn2(40)){ rloc(mtmp); return(0); } @@ -219,7 +219,7 @@ register struct monst *mtmp; mtmp->mflee || mtmp->mconf || (mtmp->minvis && !rn2(3)) || - (index("BIuy", mdat->mlet) && !rn2(4)) || + (strchr("BIuy", mdat->mlet) && !rn2(4)) || (mdat->mlet == 'L' && !u.ugold && (mtmp->mgold || rn2(2))) || (!mtmp->mcansee && !rn2(4)) || mtmp->mpeaceful @@ -229,7 +229,7 @@ register struct monst *mtmp; return(tmp == 2); } - if(!index("Ea", mdat->mlet) && nearby && + if(!strchr("Ea", mdat->mlet) && nearby && !mtmp->mpeaceful && u.uhp > 0 && !scared) { if(mhitu(mtmp)) return(1); /* monster died (e.g. 'y' or 'F') */ @@ -299,7 +299,7 @@ register struct monst *mtmp; } /* spit fire ('D') or use a wand ('1') when appropriate */ - if(index("D1", msym)) + if(strchr("D1", msym)) inrange(mtmp); if(msym == 'U' && !mtmp->mcan && canseemon(mtmp) && @@ -316,7 +316,7 @@ not_special: appr = 1; if(mtmp->mflee) appr = -1; if(mtmp->mconf || Invis || !mtmp->mcansee || - (index("BIy", msym) && !rn2(3))) + (strchr("BIy", msym) && !rn2(3))) appr = 0; omx = mtmp->mx; omy = mtmp->my; @@ -344,8 +344,8 @@ not_special: } /* look for gold or jewels nearby */ - likegold = (index("LOD", msym) != NULL); - likegems = (index("ODu", msym) != NULL); + likegold = (strchr("LOD", msym) != NULL); + likegems = (strchr("ODu", msym) != NULL); likeobjs = mtmp->mhide; #define SRCHRADIUS 25 { xchar mind = SRCHRADIUS; /* not too far away */ @@ -384,7 +384,7 @@ not_special: cnt = mfndpos(mtmp,poss,info, msym == 'u' ? NOTONL : (msym == '@' || msym == '1') ? (ALLOW_SSM | ALLOW_TRAPS) : - index(UNDEAD, msym) ? NOGARLIC : ALLOW_TRAPS); + strchr(UNDEAD, msym) ? NOGARLIC : ALLOW_TRAPS); /* ALLOW_ROCK for some monsters ? */ chcnt = 0; chi = -1; @@ -687,7 +687,7 @@ register struct monst *mtmp; extern char fut_geno[]; u.nr_killed[tmp]++; if((nk = u.nr_killed[tmp]) > MAXMONNO && - !index(fut_geno, mdat->mlet)) + !strchr(fut_geno, mdat->mlet)) charcat(fut_geno, mdat->mlet); } @@ -700,9 +700,9 @@ register struct monst *mtmp; /* give experience points */ tmp = 1 + mdat->mlevel * mdat->mlevel; if(mdat->ac < 3) tmp += 2*(7 - mdat->ac); - if(index("AcsSDXaeRTVWU&In:P", mdat->mlet)) + if(strchr("AcsSDXaeRTVWU&In:P", mdat->mlet)) tmp += 2*mdat->mlevel; - if(index("DeV&P",mdat->mlet)) tmp += (7*mdat->mlevel); + if(strchr("DeV&P",mdat->mlet)) tmp += (7*mdat->mlevel); if(mdat->mlevel > 6) tmp += 50; if(mdat->mlet == ';') tmp += 1000; @@ -753,11 +753,11 @@ register struct monst *mtmp; stackobj(fobj); } else #endif NOWORM - if(!letter(tmp) || (!index("mw", tmp) && !rn2(3))) tmp = 0; + if(!letter(tmp) || (!strchr("mw", tmp) && !rn2(3))) tmp = 0; if(ACCESSIBLE(levl[x][y].typ)) /* might be mimic in wall or dead eel*/ if(x != u.ux || y != u.uy) /* might be here after swallowed */ - if(index("NTVm&",mdat->mlet) || rn2(5)) { + if(strchr("NTVm&",mdat->mlet) || rn2(5)) { register struct obj *obj2 = mkobj_at(tmp,x,y); if(cansee(x,y)) atl(x,y,obj2->olet); diff --git a/games/hack/hack.objnam.c b/games/hack/hack.objnam.c index 2ab2f2ae43e..991385b6e35 100644 --- a/games/hack/hack.objnam.c +++ b/games/hack/hack.objnam.c @@ -231,7 +231,7 @@ register int pl = (obj->quan != 1); if(*p == 's' || *p == 'z' || *p == 'x' || (*p == 'h' && p[-1] == 's')) Strcat(buf, "es"); /* boxes */ - else if(*p == 'y' && !index(vowels, p[-1])) + else if(*p == 'y' && !strchr(vowels, p[-1])) Strcpy(p, "ies"); /* rubies, zruties */ else Strcat(buf, "s"); @@ -286,7 +286,7 @@ register char *bp = xname(obj); Strcat(bp, " (weapon in hand)"); if(obj->unpaid) Strcat(bp, " (unpaid)"); - if(!strcmp(prefix, "a ") && index(vowels, *bp)) + if(!strcmp(prefix, "a ") && strchr(vowels, *bp)) Strcpy(prefix, "an "); bp = strprepend(bp, prefix); return(bp); @@ -296,7 +296,7 @@ register char *bp = xname(obj); setan(str,buf) register char *str,*buf; { - if(index(vowels,*str)) + if(strchr(vowels,*str)) Sprintf(buf, "an %s", str); else Sprintf(buf, "a %s", str); @@ -375,7 +375,7 @@ char *un, *dn, *an; while(digit(*bp)) bp++; while(*bp == ' ') bp++; } else { - p = rindex(bp, '('); + p = strrchr(bp, '('); if(p) { if(p > bp && p[-1] == ' ') p[-1] = 0; else *p = 0; @@ -524,7 +524,7 @@ typfnd: otmp = mksobj(typ); if(heavy) otmp->owt += 15; - if(cnt > 0 && index("%?!*)", let) && + if(cnt > 0 && strchr("%?!*)", let) && (cnt < 4 || (let == WEAPON_SYM && typ <= ROCK && cnt < 20))) otmp->quan = cnt; diff --git a/games/hack/hack.options.c b/games/hack/hack.options.c index 361b94230ec..081f2b43d6e 100644 --- a/games/hack/hack.options.c +++ b/games/hack/hack.options.c @@ -35,11 +35,11 @@ boolean from_env; unsigned num; boolean negated; - if(op = index(opts, ',')) { + if(op = strchr(opts, ',')) { *op++ = 0; parseoptions(op, from_env); } - if(op = index(opts, ' ')) { + if(op = strchr(opts, ' ')) { op2 = op; while(*op++) if(*op != ' ') *op2++ = *op; @@ -106,7 +106,7 @@ boolean from_env; pline("The playername can be set only from HACKOPTIONS."); return; } - op = index(opts,':'); + op = strchr(opts,':'); if(!op) goto bad; (void) strncpy(plname, op+1, sizeof(plname)-1); plname[sizeof(plname)-1] = '\0'; @@ -115,7 +115,7 @@ boolean from_env; /* endgame:5t[op] 5a[round] o[wn] */ if(!strncmp(opts,"endgame",3)) { - op = index(opts,':'); + op = strchr(opts,':'); if(!op) goto bad; op++; while(*op) { diff --git a/games/hack/hack.pager.c b/games/hack/hack.pager.c index 7bbffd86cb5..13382aceda4 100644 --- a/games/hack/hack.pager.c +++ b/games/hack/hack.pager.c @@ -36,7 +36,7 @@ dowhatis() if(q != '\t') while(fgets(buf,BUFSZ,fp)) if(*buf == q) { - ep = index(buf, '\n'); + ep = strchr(buf, '\n'); if(ep) *ep = 0; /* else: bad data file */ /* Expand tab 'by hand' */ @@ -82,7 +82,7 @@ int strip; /* nr of chars to be stripped from each line (0 or 1) */ bufr = (char *) alloc((unsigned) CO); bufr[CO-1] = 0; while(fgets(bufr,CO-1,fp) && (!strip || *bufr == '\t') && !got_intrup){ - ep = index(bufr, '\n'); + ep = strchr(bufr, '\n'); if(ep) *ep = 0; if(page_line(bufr+strip)) { @@ -286,9 +286,9 @@ dohelp() char c; pline ("Long or short help? "); - while (((c = readchar ()) != 'l') && (c != 's') && !index(quitchars,c)) + while (((c = readchar ()) != 'l') && (c != 's') && !strchr(quitchars,c)) bell (); - if (!index(quitchars, c)) + if (!strchr(quitchars, c)) (void) page_file((c == 'l') ? HELP : SHELP, FALSE); return(0); } diff --git a/games/hack/hack.read.c b/games/hack/hack.read.c index 7fbbf8a7e33..4aae8b5246b 100644 --- a/games/hack/hack.read.c +++ b/games/hack/hack.read.c @@ -195,9 +195,9 @@ doread() { pline("What monster do you want to genocide (Type the letter)? "); getlin(buf); } while(strlen(buf) != 1 || !monstersym(*buf)); - if(!index(fut_geno, *buf)) + if(!strchr(fut_geno, *buf)) charcat(fut_geno, *buf); - if(!index(genocided, *buf)) + if(!strchr(genocided, *buf)) charcat(genocided, *buf); else { pline("Such monsters do not exist in this world."); @@ -398,7 +398,7 @@ doread() { for(mtmp = fmon; mtmp; mtmp = mtmp->nmon) { if(dist(mtmp->mx,mtmp->my) < 3) { mtmp->mhp -= num; - if(index("FY", mtmp->data->mlet)) + if(strchr("FY", mtmp->data->mlet)) mtmp->mhp -= 3*num; /* this might well kill 'F's */ if(mtmp->mhp < 1) { killed(mtmp); @@ -532,7 +532,7 @@ register char ch; /* * can't genocide certain monsters */ - if (index("12 &:", ch)) + if (strchr("12 &:", ch)) return FALSE; if (ch == pm_eel.mlet) diff --git a/games/hack/hack.rip.c b/games/hack/hack.rip.c index ced3a27b465..46cfd7eac96 100644 --- a/games/hack/hack.rip.c +++ b/games/hack/hack.rip.c @@ -39,7 +39,7 @@ outrip(){ (void) sprintf(buf, "killed by%s", !strncmp(killer, "the ", 4) ? "" : !strcmp(killer, "starvation") ? "" : - index(vowels, *killer) ? " an" : " a"); + strchr(vowels, *killer) ? " an" : " a"); center(8, buf); (void) strcpy(buf, killer); { diff --git a/games/hack/hack.rumors.c b/games/hack/hack.rumors.c index 0ace09e2600..7dff7de2387 100644 --- a/games/hack/hack.rumors.c +++ b/games/hack/hack.rumors.c @@ -10,7 +10,6 @@ static char rcsid[] = "$NetBSD: hack.rumors.c,v 1.3 1995/03/23 08:31:24 cgd Exp #include "hack.h" /* for RUMORFILE and BSD (index) */ #define CHARSZ 8 /* number of bits in a char */ extern long *alloc(); -extern char *index(); int n_rumors = 0; int n_used_rumors = -1; char *usedbits; @@ -29,7 +28,7 @@ skipline(rumf) register FILE *rumf; { char line[COLNO]; while(1) { if(!fgets(line, sizeof(line), rumf)) return(0); - if(index(line, '\n')) return(1); + if(strchr(line, '\n')) return(1); } } @@ -37,7 +36,7 @@ outline(rumf) register FILE *rumf; { char line[COLNO]; register char *ep; if(!fgets(line, sizeof(line), rumf)) return; - if((ep = index(line, '\n')) != 0) *ep = 0; + if((ep = strchr(line, '\n')) != 0) *ep = 0; pline("This cookie has a scrap of paper inside! It reads: "); pline(line); } diff --git a/games/hack/hack.shk.c b/games/hack/hack.shk.c index a3adc7b8358..ab4e3f81017 100644 --- a/games/hack/hack.shk.c +++ b/games/hack/hack.shk.c @@ -608,7 +608,7 @@ register struct bill_x *bp; return; if(ESHK(shopkeeper)->billct == BILLSZ || ((tmp = shtypes[rooms[ESHK(shopkeeper)->shoproom].rtype-8]) && tmp != obj->olet) - || index("_0", obj->olet)) { + || strchr("_0", obj->olet)) { pline("%s seems not interested.", Monnam(shopkeeper)); return; } @@ -985,7 +985,7 @@ online(x,y) { follower(mtmp) register struct monst *mtmp; { - return( mtmp->mtame || index("1TVWZi&, ", mtmp->data->mlet) + return( mtmp->mtame || strchr("1TVWZi&, ", mtmp->data->mlet) #ifndef QUEST || (mtmp->isshk && ESHK(mtmp)->following) #endif QUEST diff --git a/games/hack/hack.topl.c b/games/hack/hack.topl.c index 89b8c8937e4..4316228164f 100644 --- a/games/hack/hack.topl.c +++ b/games/hack/hack.topl.c @@ -34,7 +34,7 @@ doredotopl(){ redotoplin() { home(); - if(index(toplines, '\n')) cl_end(); + if(strchr(toplines, '\n')) cl_end(); putstr(toplines); cl_end(); tlx = curx; @@ -129,7 +129,7 @@ register char *line,*arg1,*arg2,*arg3,*arg4,*arg5,*arg6; register int n,n0; if(!line || !*line) return; - if(!index(line, '%')) (void) strcpy(pbuf,line); else + if(!strchr(line, '%')) (void) strcpy(pbuf,line); else (void) sprintf(pbuf,line,arg1,arg2,arg3,arg4,arg5,arg6); if(flags.toplin == 1 && !strcmp(pbuf, toplines)) return; nscr(); /* %% */ diff --git a/games/hack/hack.trap.c b/games/hack/hack.trap.c index dbcb12140a4..edf876f39a2 100644 --- a/games/hack/hack.trap.c +++ b/games/hack/hack.trap.c @@ -160,7 +160,7 @@ mintrap(mtmp) register struct monst *mtmp; { mtmp->mtrapseen |= (1 << tt); switch (tt) { case BEAR_TRAP: - if(index(mlarge, mtmp->data->mlet)) { + if(strchr(mlarge, mtmp->data->mlet)) { if(in_sight) pline("%s is caught in a bear trap!", Monnam(mtmp)); @@ -172,7 +172,7 @@ mintrap(mtmp) register struct monst *mtmp; { break; case PIT: /* there should be a mtmp/data -> floating */ - if(!index("EywBfk'& ", mtmp->data->mlet)) { /* ab */ + if(!strchr("EywBfk'& ", mtmp->data->mlet)) { /* ab */ mtmp->mtrapped = 1; if(in_sight) pline("%s falls in a pit!", Monnam(mtmp)); diff --git a/games/hack/hack.tty.c b/games/hack/hack.tty.c index 727fea0d239..2b5cc04b595 100644 --- a/games/hack/hack.tty.c +++ b/games/hack/hack.tty.c @@ -216,7 +216,7 @@ register int c; while((c = readchar()) != '\n') { if(flags.cbreak) { if(c == ' ') break; - if(s && index(s,c)) { + if(s && strchr(s,c)) { morc = c; break; } diff --git a/games/hack/hack.u_init.c b/games/hack/hack.u_init.c index f61899d0bf1..2abb2cdb436 100644 --- a/games/hack/hack.u_init.c +++ b/games/hack/hack.u_init.c @@ -117,12 +117,12 @@ extern char readchar(); printf("\nAre you an experienced player? [ny] "); - while(!index("ynYN \n\004", (exper = readchar()))) + while(!strchr("ynYN \n\004", (exper = readchar()))) bell(); if(exper == '\004') /* Give him an opportunity to get out */ end_of_input(); printf("%c\n", exper); /* echo */ - if(index("Nn \n", exper)) { + if(strchr("Nn \n", exper)) { exper = 0; goto beginner; } @@ -321,7 +321,7 @@ register char *ep = getenv("INVENT"); register int type; while(ep && *ep) { type = atoi(ep); - ep = index(ep, ','); + ep = strchr(ep, ','); if(ep) while(*ep == ',' || *ep == ' ') ep++; if(type <= 0 || type > NROFOBJECTS) continue; trop->trotyp = type; @@ -343,7 +343,7 @@ register int type; plnamesuffix() { register char *p; - if(p = rindex(plname, '-')) { + if(p = strrchr(plname, '-')) { *p = 0; pl_character[0] = p[1]; pl_character[1] = 0; @@ -360,7 +360,7 @@ char pc; /* so that rolesyms[] is defined */ register char *cp; - if(cp = index(rolesyms, pc)) + if(cp = strchr(rolesyms, pc)) return(cp - rolesyms); return(-1); } diff --git a/games/hack/hack.unix.c b/games/hack/hack.unix.c index eb67a3d4d1b..f038795a7e0 100644 --- a/games/hack/hack.unix.c +++ b/games/hack/hack.unix.c @@ -19,7 +19,7 @@ static char rcsid[] = "$NetBSD: hack.unix.c,v 1.4 1996/02/06 22:47:25 jtc Exp $" #include <stdio.h> #include <errno.h> -#include "hack.h" /* mainly for index() which depends on BSD */ +#include "hack.h" #include <sys/types.h> /* for time_t and stat */ #include <sys/stat.h> @@ -100,7 +100,7 @@ gethdate(name) char *name; { register char *np; if(stat(name, &hbuf)) error("Cannot get status of %s.", - (np = rindex(name, '/')) ? np+1 : name); + (np = strrchr(name, '/')) ? np+1 : name); version using PATH from: seismo!gregc@ucsf-cgl.ARPA (Greg Couch) */ @@ -114,11 +114,11 @@ gethdate(name) char *name; { register char *np, *path; char filename[MAXPATHLEN+1]; - if (index(name, '/') != NULL || (path = getenv("PATH")) == NULL) + if (strchr(name, '/') != NULL || (path = getenv("PATH")) == NULL) path = ""; for (;;) { - if ((np = index(path, ':')) == NULL) + if ((np = strchr(path, ':')) == NULL) np = path + strlen(path); /* point to end str */ if (np - path <= 1) /* %% */ (void) strcpy(filename, name); @@ -134,7 +134,7 @@ char filename[MAXPATHLEN+1]; path = np + 1; } error("Cannot get status of %s.", - (np = rindex(name, '/')) ? np+1 : name); + (np = strrchr(name, '/')) ? np+1 : name); } uptodate(fd) { @@ -429,6 +429,6 @@ register char *s; { register char *lp; - while((lp = index(s, '.')) || (lp = index(s, '/'))) + while((lp = strchr(s, '.')) || (lp = strchr(s, '/'))) *lp = '_'; } diff --git a/games/hack/hack.zap.c b/games/hack/hack.zap.c index a282dc0e5b7..8b1c6318cfa 100644 --- a/games/hack/hack.zap.c +++ b/games/hack/hack.zap.c @@ -44,7 +44,7 @@ register struct obj *otmp; mtmp->mspeed = MFAST; break; case WAN_UNDEAD_TURNING: - if(index(UNDEAD,mtmp->data->mlet)) { + if(strchr(UNDEAD,mtmp->data->mlet)) { mtmp->mhp -= rnd(8); if(mtmp->mhp < 1) killed(mtmp); else mtmp->mflee = 1; @@ -557,20 +557,20 @@ register type; break; case -1: /* Dragon blazing fire */ case 1: /* fire */ - if(index("Dg", mon->data->mlet)) break; + if(strchr("Dg", mon->data->mlet)) break; tmp = d(6,6); - if(index("YF", mon->data->mlet)) tmp += 7; + if(strchr("YF", mon->data->mlet)) tmp += 7; break; case 2: /* sleep*/ mon->mfroz = 1; break; case 3: /* cold */ - if(index("YFgf", mon->data->mlet)) break; + if(strchr("YFgf", mon->data->mlet)) break; tmp = d(6,6); if(mon->data->mlet == 'D') tmp += 7; break; case 4: /* death*/ - if(index(UNDEAD, mon->data->mlet)) break; + if(strchr(UNDEAD, mon->data->mlet)) break; tmp = mon->mhp+1; break; } |