* interface supports that.
*/
if ((dln - dx) + 1 + hln + 1 + xln + 1 + tln + 1 + cln <= COLNO) {
- Sprintf(newbot2, "%s %s %s %s %s", dloc, hlth, expr, tmmv, cond);
+ Snprintf(newbot2, sizeof(newbot2), "%s %s %s %s %s", dloc, hlth, expr,
+ tmmv, cond);
} else {
if (dln + 1 + hln + 1 + xln + 1 + tln + 1 + cln + 1 > MAXCO) {
panic("bot2: second status line exceeds MAXCO (%u > %d)",
(dln + 1 + hln + 1 + xln + 1 + tln + 1 + cln + 1), MAXCO);
} else if ((dln - dx) + 1 + hln + 1 + xln + 1 + cln <= COLNO) {
- Sprintf(newbot2, "%s %s %s %s %s", dloc, hlth, expr, cond, tmmv);
+ Snprintf(newbot2, sizeof(newbot2), "%s %s %s %s %s", dloc, hlth,
+ expr, cond, tmmv);
} else if ((dln - dx) + 1 + hln + 1 + cln <= COLNO) {
- Sprintf(newbot2, "%s %s %s %s %s", dloc, hlth, cond, expr, tmmv);
+ Snprintf(newbot2, sizeof(newbot2), "%s %s %s %s %s", dloc, hlth,
+ cond, expr, tmmv);
} else {
- Sprintf(newbot2, "%s %s %s %s %s", hlth, cond, dloc, expr, tmmv);
+ Snprintf(newbot2, sizeof(newbot2), "%s %s %s %s %s", hlth, cond,
+ dloc, expr, tmmv);
}
/* only two or three consecutive spaces available to squeeze out */
mungspaces(newbot2);
tmpattr = hlattr2attrname(atr, attrbuf, BUFSZ);
if (tmpattr)
Sprintf(eos(clrbuf), "&%s", tmpattr);
- Sprintf(condbuf, "condition/%s/%s",
- conditionbitmask2str(cond_maps[i].bm), clrbuf);
+ Snprintf(condbuf, sizeof(condbuf), "condition/%s/%s",
+ conditionbitmask2str(cond_maps[i].bm), clrbuf);
status_hilite_linestr_add(BL_CONDITION, 0,
cond_maps[i].bm, condbuf);
}
if ((tmpattr = hlattr2attrname(attr, attrbuf, BUFSZ)) != 0)
Sprintf(eos(clrbuf), "&%s", tmpattr);
}
- Sprintf(buf, "%s/%s/%s", initblstats[hl->fld].fldname, behavebuf, clrbuf);
+ Snprintf(buf, sizeof(buf), "%s/%s/%s", initblstats[hl->fld].fldname,
+ behavebuf, clrbuf);
return buf;
}
add_menu(win, &nul_glyphinfo, &any, any.a_char, 0,
ATR_NONE, buf, MENU_ITEMFLAGS_NONE);
}
- Sprintf(prompt, "Extended Command: %s", cbuf);
+ Snprintf(prompt, sizeof(prompt), "Extended Command: %s", cbuf);
end_menu(win, prompt);
n = select_menu(win, PICK_ONE, &pick_list);
destroy_nhwindow(win);
Sprintf(buf2, "[%s]", spkey_name(j));
/* lines up with the other unassigned commands which use
"#%-20s ", but not with the other special keys */
- Sprintf(buf, "%-21s %s", buf2, misc_keys[i].desc);
+ Snprintf(buf, sizeof(buf), "%-21s %s", buf2,
+ misc_keys[i].desc);
putstr(datawin, 0, buf);
}
}
Strcpy(pbuf + (QBUFSZ - 1) - k - 4, "...?"); /* -4: "...?" */
}
- Sprintf(qbuf, "%s%s %s", promptprefix, pbuf, responsetype);
+ Snprintf(qbuf, sizeof(qbuf), "%s%s %s", promptprefix, pbuf,
+ responsetype);
*ans = '\0';
getlin(qbuf, ans);
(void) mungspaces(ans);
} else {
Sprintf(kbuf, "'%s'", visctrl(g.Cmd.spkeys[NHKF_GETPOS_PICK]));
}
- Sprintf(sbuf, "Type a %s when you are at the right place.", kbuf);
+ Snprintf(sbuf, sizeof(sbuf),
+ "Type a %s when you are at the right place.", kbuf);
putstr(tmpwin, 0, sbuf);
if (doing_what_is) {
Sprintf(sbuf,
Strcat(what, " and ");
Strcat(what, suit_simple_name(uarm));
}
- Sprintf(why, " without taking off your %s first", what);
+ Snprintf(why, sizeof(why), " without taking off your %s first",
+ what);
} else {
Strcpy(why, "; it's embedded");
}
(void) strsubst(tmpbuf, " herself", " yourself");
(void) strsubst(tmpbuf, " his ", " your ");
(void) strsubst(tmpbuf, " her ", " your ");
- Sprintf(buf, "%s%syou, %s%c", PREFIX, TAB, tmpbuf,
- --kncnt ? ',' : '.');
+ Snprintf(buf, sizeof(buf), "%s%syou, %s%c", PREFIX, TAB,
+ tmpbuf, --kncnt ? ',' : '.');
putstr(win, 0, buf);
}
for (bp = mptr->final_resting_place; bp; bp = bp->next) {
*/
if (cadaver && mnum != PM_ACID_BLOB && rotted > 5L && !Sick_resistance) {
/* Tainted meat */
- Sprintf(buf, "%s like %s could be tainted! %s", foodsmell, it_or_they,
- eat_it_anyway);
+ Snprintf(buf, sizeof(buf), "%s like %s could be tainted! %s",
+ foodsmell, it_or_they, eat_it_anyway);
if (yn_function(buf, ynchars, 'n') == 'n')
return 1;
else
return 2;
}
if (stoneorslime) {
- Sprintf(buf, "%s like %s could be something very dangerous! %s",
- foodsmell, it_or_they, eat_it_anyway);
+ Snprintf(buf, sizeof(buf),
+ "%s like %s could be something very dangerous! %s",
+ foodsmell, it_or_they, eat_it_anyway);
if (yn_function(buf, ynchars, 'n') == 'n')
return 1;
else
}
if (otmp->orotten || (cadaver && rotted > 3L)) {
/* Rotten */
- Sprintf(buf, "%s like %s could be rotten! %s", foodsmell, it_or_they,
- eat_it_anyway);
+ Snprintf(buf, sizeof(buf), "%s like %s could be rotten! %s",
+ foodsmell, it_or_they, eat_it_anyway);
if (yn_function(buf, ynchars, 'n') == 'n')
return 1;
else
}
if (cadaver && poisonous(&mons[mnum]) && !Poison_resistance) {
/* poisonous */
- Sprintf(buf, "%s like %s might be poisonous! %s", foodsmell,
- it_or_they, eat_it_anyway);
+ Snprintf(buf, sizeof(buf), "%s like %s might be poisonous! %s",
+ foodsmell, it_or_they, eat_it_anyway);
if (yn_function(buf, ynchars, 'n') == 'n')
return 1;
else
}
if (otmp->otyp == APPLE && otmp->cursed && !Sleep_resistance) {
/* causes sleep, for long enough to be dangerous */
- Sprintf(buf, "%s like %s might have been poisoned. %s", foodsmell,
- it_or_they, eat_it_anyway);
+ Snprintf(buf, sizeof(buf), "%s like %s might have been poisoned. %s",
+ foodsmell, it_or_they, eat_it_anyway);
return (yn_function(buf, ynchars, 'n') == 'n') ? 1 : 2;
}
if (cadaver && !vegetarian(&mons[mnum]) && !u.uconduct.unvegetarian
&& Role_if(PM_MONK)) {
- Sprintf(buf, "%s unhealthy. %s", foodsmell, eat_it_anyway);
+ Snprintf(buf, sizeof(buf), "%s unhealthy. %s", foodsmell,
+ eat_it_anyway);
if (yn_function(buf, ynchars, 'n') == 'n')
return 1;
else
return 2;
}
if (cadaver && acidic(&mons[mnum]) && !Acid_resistance) {
- Sprintf(buf, "%s rather acidic. %s", foodsmell, eat_it_anyway);
+ Snprintf(buf, sizeof(buf), "%s rather acidic. %s",
+ foodsmell, eat_it_anyway);
if (yn_function(buf, ynchars, 'n') == 'n')
return 1;
else
}
if (Upolyd && u.umonnum == PM_RUST_MONSTER && is_metallic(otmp)
&& otmp->oerodeproof) {
- Sprintf(buf, "%s disgusting to you right now. %s", foodsmell,
- eat_it_anyway);
+ Snprintf(buf, sizeof(buf), "%s disgusting to you right now. %s",
+ foodsmell, eat_it_anyway);
if (yn_function(buf, ynchars, 'n') == 'n')
return 1;
else
&& ((material == LEATHER || material == BONE
|| material == DRAGON_HIDE || material == WAX)
|| (cadaver && !vegan(&mons[mnum])))) {
- Sprintf(buf, "%s foul and unfamiliar to you. %s", foodsmell,
- eat_it_anyway);
+ Snprintf(buf, sizeof(buf), "%s foul and unfamiliar to you. %s",
+ foodsmell, eat_it_anyway);
if (yn_function(buf, ynchars, 'n') == 'n')
return 1;
else
&& ((material == LEATHER || material == BONE
|| material == DRAGON_HIDE)
|| (cadaver && !vegetarian(&mons[mnum])))) {
- Sprintf(buf, "%s unfamiliar to you. %s", foodsmell, eat_it_anyway);
+ Snprintf(buf, sizeof(buf), "%s unfamiliar to you. %s",
+ foodsmell, eat_it_anyway);
if (yn_function(buf, ynchars, 'n') == 'n')
return 1;
else
if (cadaver && mnum != PM_ACID_BLOB && rotted > 5L && Sick_resistance) {
/* Tainted meat with Sick_resistance */
- Sprintf(buf, "%s like %s could be tainted! %s",
- foodsmell, it_or_they, eat_it_anyway);
+ Snprintf(buf, sizeof(buf), "%s like %s could be tainted! %s",
+ foodsmell, it_or_they, eat_it_anyway);
if (yn_function(buf, ynchars, 'n') == 'n')
return 1;
else
*tmpbuf = highc(*tmpbuf); /* same adjustment as bottom line */
/* as in background_enlightenment, when poly'd we need to use the saved
gender in u.mfemale rather than the current you-as-monster gender */
- Sprintf(buf, "%s the %s's attributes:", tmpbuf,
- ((Upolyd ? u.mfemale : flags.female) && g.urole.name.f)
+ Snprintf(buf, sizeof(buf), "%s the %s's attributes:", tmpbuf,
+ ((Upolyd ? u.mfemale : flags.female) && g.urole.name.f)
? g.urole.name.f
: g.urole.name.m);
Sprintf(eos(tmpbuf), "%s in ",
pmname(&mons[g.youmonst.cham],
flags.female ? FEMALE : MALE));
- Sprintf(buf, "%s%s%s%s form", !final ? "currently " : "",
- altphrasing ? just_an(anbuf, tmpbuf) : "in ",
- tmpbuf, pmname(uasmon, flags.female ? FEMALE : MALE));
+ Snprintf(buf, sizeof(buf), "%s%s%s%s form",
+ !final ? "currently " : "",
+ altphrasing ? just_an(anbuf, tmpbuf) : "in ",
+ tmpbuf, pmname(uasmon, flags.female ? FEMALE : MALE));
you_are(buf, "");
}
int egdepth = observable_depth(&u.uz);
(void) endgamelevelname(tmpbuf, egdepth);
- Sprintf(buf, "in the endgame, on the %s%s",
- !strncmp(tmpbuf, "Plane", 5) ? "Elemental " : "", tmpbuf);
+ Snprintf(buf, sizeof(buf), "in the endgame, on the %s%s",
+ !strncmp(tmpbuf, "Plane", 5) ? "Elemental " : "", tmpbuf);
} else if (Is_knox(&u.uz)) {
/* this gives away the fact that the knox branch is only 1 level */
Sprintf(buf, "on the %s level", g.dungeons[u.uz.dnum].dname);
Strcat(tmpbuf, ", a primitive area");
else if (Is_bigroom(&u.uz) && !Blind)
Strcat(tmpbuf, ", a very big room");
- Sprintf(buf, "in %s, on %s", dgnbuf, tmpbuf);
+ Snprintf(buf, sizeof(buf), "in %s, on %s", dgnbuf, tmpbuf);
}
you_are(buf, "");
Strcat(buf, " and two weapons");
if (also3) {
Strcpy(pfx, "You also ");
- Sprintf(sfx, " %s", buf), buf[0] = '\0';
+ Snprintf(sfx, sizeof(sfx), " %s", buf), buf[0] = '\0';
verb_present = hav2 ? "have" : "are";
verb_past = hav2 ? "had" : "were";
}
: !digit(buf[2]) ? 4 : 0;
if (class_header)
++pfx;
- Sprintf(buftoo, "%*s%s", pfx, "", buf);
+ Snprintf(buftoo, sizeof(buftoo), "%*s%s", pfx, "", buf);
putstr(klwin, 0, buftoo);
}
/*
buf[0] = '\0';
switch (mattk->aatyp) {
case AT_BITE:
- Sprintf(buf, "%s bites", magr_name);
+ Snprintf(buf, sizeof(buf), "%s bites", magr_name);
break;
case AT_STNG:
- Sprintf(buf, "%s stings", magr_name);
+ Snprintf(buf, sizeof(buf), "%s stings", magr_name);
break;
case AT_BUTT:
- Sprintf(buf, "%s butts", magr_name);
+ Snprintf(buf, sizeof(buf), "%s butts", magr_name);
break;
case AT_TUCH:
- Sprintf(buf, "%s touches", magr_name);
+ Snprintf(buf, sizeof(buf), "%s touches", magr_name);
break;
case AT_TENT:
- Sprintf(buf, "%s tentacles suck", s_suffix(magr_name));
+ Snprintf(buf, sizeof(buf), "%s tentacles suck", s_suffix(magr_name));
break;
case AT_HUGS:
if (magr != u.ustuck) {
- Sprintf(buf, "%s squeezes", magr_name);
+ Snprintf(buf, sizeof(buf), "%s squeezes", magr_name);
break;
}
/*FALLTHRU*/
default:
if (!weaponhit || !mwep || !mwep->oartifact)
- Sprintf(buf, "%s hits", magr_name);
+ Snprintf(buf, sizeof(buf), "%s hits", magr_name);
break;
}
if (*buf)
|| (is_wc2_option(optname) && !wc2_supported(optname)))
continue;
Sprintf(buf2, "`%s'", optname);
- Sprintf(buf, "%-20s - %s%c", buf2, allopt[i].descr,
- allopt[i + 1].name ? ',' : '.');
+ Snprintf(buf, sizeof(buf), "%-20s - %s%c", buf2, allopt[i].descr,
+ allopt[i + 1].name ? ',' : '.');
putstr(datawin, 0, buf);
}
putstr(datawin, 0, "");
*firstmatch = look_buf;
if (*(*firstmatch)) {
- Sprintf(temp_buf, " (%s)", *firstmatch);
+ Snprintf(temp_buf, sizeof(temp_buf), " (%s)", *firstmatch);
(void) strncat(out_str, temp_buf,
BUFSZ - strlen(out_str) - 1);
found = 1; /* we have something to look up */
}
if (monbuf[0]) {
- Sprintf(temp_buf, " [seen: %s]", monbuf);
+ Snprintf(temp_buf, sizeof(temp_buf), " [seen: %s]", monbuf);
(void) strncat(out_str, temp_buf,
BUFSZ - strlen(out_str) - 1);
}
switch (obj->otyp) {
case POT_WATER:
- Sprintf(saddle_glows, "%s %s", buf, aobjnam(saddle, "glow"));
+ Snprintf(saddle_glows, sizeof(saddle_glows), "%s %s",
+ buf, aobjnam(saddle, "glow"));
affected = H2Opotion_dip(obj, saddle, useeit, saddle_glows);
break;
case POT_POLYMORPH:
here = levl[u.ux][u.uy].typ;
/* Is there a fountain to dip into here? */
if (IS_FOUNTAIN(here)) {
- Sprintf(qbuf, "%s%s into the fountain?", Dip_,
- flags.verbose ? obuf : shortestname);
+ Snprintf(qbuf, sizeof(qbuf), "%s%s into the fountain?", Dip_,
+ flags.verbose ? obuf : shortestname);
/* "Dip <the object> into the fountain?" */
if (yn(qbuf) == 'y') {
dipfountain(obj);
} else if (is_pool(u.ux, u.uy)) {
const char *pooltype = waterbody_name(u.ux, u.uy);
- Sprintf(qbuf, "%s%s into the %s?", Dip_,
- flags.verbose ? obuf : shortestname, pooltype);
+ Snprintf(qbuf, sizeof(qbuf), "%s%s into the %s?", Dip_,
+ flags.verbose ? obuf : shortestname, pooltype);
/* "Dip <the object> into the {pool, moat, &c}?" */
if (yn(qbuf) == 'y') {
if (Levitation) {
}
/* "What do you want to dip <the object> into? [xyz or ?*] " */
- Sprintf(qbuf, "dip %s into", flags.verbose ? obuf : shortestname);
+ Snprintf(qbuf, sizeof(qbuf), "dip %s into",
+ flags.verbose ? obuf : shortestname);
potion = getobj(qbuf, drink_ok, GETOBJ_NOFLAGS);
if (!potion)
return 0;
Sprintf(lets, "a-zA-%c", 'A' + nspells - 27);
for (;;) {
- Sprintf(qbuf, "Cast which spell? [%s *?]", lets);
+ Snprintf(qbuf, sizeof(qbuf), "Cast which spell? [%s *?]",
+ lets);
ilet = yn_function(qbuf, (char *) 0, '\0');
if (ilet == '*' || ilet == '?')
break; /* use menu mode */
topten_print_bold(linebuf);
} else
topten_print(linebuf);
- Sprintf(linebuf, "%15s %s", "", linebuf3);
+ Snprintf(linebuf, sizeof(linebuf), "%15s %s", "", linebuf3);
lngr = strlen(linebuf);
}
/* beginning of hp column not including padding */
trap_skipped = TRUE;
deal_with_floor_trap = FALSE;
} else {
- Sprintf(
- qbuf, "There %s and %s here. %s %s?",
- (boxcnt == 1) ? "is a container" : "are containers",
- an(trapdescr),
- (ttmp->ttyp == WEB) ? "Remove" : "Disarm", the_trap);
+ Snprintf(qbuf, sizeof(qbuf),
+ "There %s and %s here. %s %s?",
+ (boxcnt == 1) ? "is a container"
+ : "are containers",
+ an(trapdescr),
+ (ttmp->ttyp == WEB) ? "Remove"
+ : "Disarm",
+ the_trap);
switch (ynq(qbuf)) {
case 'q':
return 0;
else if (silverobj && saved_oname[0]) {
/* guard constructed format string against '%' in
saved_oname[] from xname(via cxname()) */
- Sprintf(silverobjbuf, "Your %s%s %s",
- strstri(saved_oname, "silver") ? "" : "silver ",
- saved_oname, vtense(saved_oname, "sear"));
+ Snprintf(silverobjbuf, sizeof(silverobjbuf), "Your %s%s %s",
+ strstri(saved_oname, "silver") ? "" : "silver ",
+ saved_oname, vtense(saved_oname, "sear"));
(void) strNsubst(silverobjbuf, "%", "%%", 0);
- Strcat(silverobjbuf, " %s!");
+ strncat(silverobjbuf, " %s!",
+ sizeof(silverobjbuf) - (strlen(silverobjbuf) + 1));
fmt = silverobjbuf;
} else
fmt = "The silver sears %s!";
}
prompt[count_off] = '\0';
- sprintf(choice, "%s%c", tmpchoice, '\033');
+ Snprintf(choice, sizeof(choice), "%s%c", tmpchoice, '\033');
if (strchr(tmpchoice, 't')) { /* Tutorial mode */
mvaddstr(0, 1, "New? Press t to enter a tutorial.");
}
Sprintf(plbuf, " %s", genders[GEND].adj);
else
*plbuf = '\0'; /* omit redundant gender */
- Sprintf(pbuf, "%s, %s%s %s %s", g.plname, aligns[ALGN].adj, plbuf,
- races[RACE].adj,
- (GEND == 1 && roles[ROLE].name.f) ? roles[ROLE].name.f
- : roles[ROLE].name.m);
+ Snprintf(pbuf, sizeof(pbuf), "%s, %s%s %s %s", g.plname,
+ aligns[ALGN].adj, plbuf, races[RACE].adj,
+ (GEND == 1 && roles[ROLE].name.f) ? roles[ROLE].name.f
+ : roles[ROLE].name.m);
add_menu(win, &nul_glyphinfo, &any, 0, 0, ATR_NONE, pbuf,
MENU_ITEMFLAGS_NONE);
/* blank separator */