A number of C compiler suites have a math.h library that includes a yn()
function name that conflicts with NetHack's yn() macro:
"The y0(), y1(), and yn() functions are Bessel functions of the second kind,
for orders 0, 1, and n, respectively. The argument x must be positive. The
argument n should be greater than or equal to zero. If n is less than zero,
there will be a negative exponent in the result."

At one point, isaac64.h included math.h, although that has since been removed.

Some libraries used in NetHack (Qt for one) do include math.h and that required
build work-arounds to avoid the conflict.

Rename the NetHack macro from yn() to y_n() and avoid the math.h conflict
altogether, eliminating the need for that particular work-around.
This commit is contained in:
nhmall
2023-01-12 16:04:40 -05:00
parent 6e136c6f7d
commit ba5356603a
34 changed files with 57 additions and 59 deletions

View File

@@ -1370,7 +1370,7 @@ use_candle(struct obj **optr)
if ((q = strstri(qbuf, " to\033")) != 0)
Strcpy(q, " to ");
/* last, format final "attach candles to candelabrum?" query */
if (yn(safe_qbuf(qbuf, qbuf, "?", otmp, yname, thesimpleoname, "it"))
if (y_n(safe_qbuf(qbuf, qbuf, "?", otmp, yname, thesimpleoname, "it"))
== 'n') {
use_lamp(obj);
return;
@@ -2776,7 +2776,7 @@ use_trap(struct obj *otmp)
You("aren't very skilled at reaching from %s.", mon_nam(u.usteed));
Sprintf(buf, "Continue your attempt to set %s?",
the(trapname(ttyp, FALSE)));
if (yn(buf) == 'y') {
if (y_n(buf) == 'y') {
if (chance) {
switch (ttyp) {
case LANDMINE: /* set it off */

View File

@@ -415,7 +415,7 @@ savebones(int how, time_t when, struct obj *corpse)
if (nhfp) {
close_nhfile(nhfp);
if (wizard) {
if (yn("Bones file already exists. Replace it?") == 'y') {
if (y_n("Bones file already exists. Replace it?") == 'y') {
if (delete_bonesfile(&u.uz))
goto make_bones;
else
@@ -620,7 +620,7 @@ getbones(void)
} else {
ok = TRUE;
if (wizard) {
if (yn("Get bones?") == 'n') {
if (y_n("Get bones?") == 'n') {
close_nhfile(nhfp);
compress_bonesfile();
return 0;
@@ -679,7 +679,7 @@ getbones(void)
u.uroleplay.numbones++;
if (wizard) {
if (yn("Unlink bones?") == 'n') {
if (y_n("Unlink bones?") == 'n') {
compress_bonesfile();
return ok;
}

View File

@@ -6604,7 +6604,7 @@ paranoid_query(boolean be_paranoid, const char *prompt)
promptprefix = "\"Yes\" or \"No\": ";
} while (ParanoidConfirm && strcmpi(ans, "no") && --trylimit);
} else {
confirmed_ok = (yn(prompt) == 'y');
confirmed_ok = (y_n(prompt) == 'y');
}
return confirmed_ok;
}

View File

@@ -1125,7 +1125,7 @@ dodown(void)
if (on_level(&valley_level, &u.uz) && !u.uevent.gehennom_entered) {
You("are standing at the gate to Gehennom.");
pline("Unspeakable cruelty and harm lurk down there.");
if (yn("Are you sure you want to enter?") != 'y')
if (y_n("Are you sure you want to enter?") != 'y')
return ECMD_OK;
pline("So be it.");
u.uevent.gehennom_entered = 1; /* don't ask again */
@@ -1145,7 +1145,7 @@ dodown(void)
You("don't fit %s easily.", down_or_thru);
Sprintf(qbuf, "Try to squeeze %s?", down_or_thru);
if (yn(qbuf) == 'y') {
if (y_n(qbuf) == 'y') {
if (!rn2(3)) {
actn = "manage to squeeze";
losehp(Maybe_Half_Phys(rnd(4)),
@@ -1223,7 +1223,7 @@ doup(void)
if (ledger_no(&u.uz) == 1) {
if (iflags.debug_fuzzer)
return ECMD_OK;
if (yn("Beware, there will be no return! Still climb?") != 'y')
if (y_n("Beware, there will be no return! Still climb?") != 'y')
return ECMD_OK;
}
if (!next_to_u()) {

View File

@@ -1490,7 +1490,7 @@ consume_tin(const char *mesg)
what = the(what);
pline("It smells like %s.", what);
if (yn("Eat it?") == 'n') {
if (y_n("Eat it?") == 'n') {
if (Verbose(0, consume_tin1))
You("discard the open tin.");
if (!Hallucination)
@@ -1546,7 +1546,7 @@ consume_tin(const char *mesg)
tin->dknown = tin->known = 1;
}
if (yn("Eat it?") == 'n') {
if (y_n("Eat it?") == 'n') {
if (Verbose(0, consume_tin2))
You("discard the open tin.");
tin = costly_tin(COST_OPEN);

View File

@@ -203,7 +203,7 @@ dryup(coordxy x, coordxy y, boolean isyou)
return;
}
if (isyou && wizard) {
if (yn("Dry up fountain?") == 'n')
if (y_n("Dry up fountain?") == 'n')
return;
}
/* FIXME: sight-blocking clouds should use block_point() when

View File

@@ -107,7 +107,7 @@ picklock(void)
/* unfortunately we don't have a 'tknown' flag to record
"known to be trapped" so declining to disarm and then
retrying lock manipulation will find it all over again */
if (yn("You find a trap! Do you want to try to disarm it?") == 'y') {
if (y_n("You find a trap! Do you want to try to disarm it?") == 'y') {
const char *what;
boolean alreadyunlocked;

View File

@@ -1861,7 +1861,7 @@ doseduce(struct monst *mon)
" looks pretty. May I have it?\"", ring,
xname, simpleonames, "ring");
makeknown(RIN_ADORNMENT);
if (yn(qbuf) == 'n')
if (y_n(qbuf) == 'n')
continue;
} else
pline("%s decides she'd like %s, and takes it.",
@@ -1891,7 +1891,7 @@ doseduce(struct monst *mon)
" looks pretty. Would you wear it for me?\"",
ring, xname, simpleonames, "ring");
makeknown(RIN_ADORNMENT);
if (yn(qbuf) == 'n')
if (y_n(qbuf) == 'n')
continue;
} else {
pline("%s decides you'd look prettier wearing %s,",
@@ -2143,7 +2143,7 @@ mayberem(struct monst *mon,
} else if (rn2(20) < ACURR(A_CHA)) {
Sprintf(qbuf, "\"Shall I remove your %s, %s?\"", str,
(!rn2(2) ? "lover" : !rn2(2) ? "dear" : "sweetheart"));
if (yn(qbuf) == 'n')
if (y_n(qbuf) == 'n')
return;
} else {
char hairbuf[BUFSZ];

View File

@@ -887,7 +887,7 @@ doclassdisco(void)
but requires at least one artifact discovery for other styles
[could fix that by forcing the 'a' choice into the pick-class
menu when running in wizard mode] */
if (wizard && yn("Dump information about all artifacts?") == 'y') {
if (wizard && y_n("Dump information about all artifacts?") == 'y') {
dump_artifact_info(tmpwin);
ct = NROFARTIFACTS; /* non-zero vs zero is what matters below */
break;

View File

@@ -4611,7 +4611,7 @@ readobjnam(char *bp, struct obj *no_wish)
rn1cnt = 6 - d.gsize;
if (d.cnt > rn1cnt
&& (!wizard || gp.program_state.wizkit_wishing
|| yn("Override glob weight limit?") != 'y'))
|| y_n("Override glob weight limit?") != 'y'))
d.cnt = rn1cnt;
d.otmp->owt *= (unsigned) d.cnt;
}

View File

@@ -904,7 +904,7 @@ checkfile(char *inp, struct permonst *pm, boolean user_typed_name,
(int) (sizeof question - 1
- (strlen(question) + 2)));
Strcat(question, "\"?");
if (yn(question) == 'y')
if (y_n(question) == 'y')
yes_to_moreinfo = TRUE;
}
@@ -1868,7 +1868,7 @@ do_supplemental_info(char *name, struct permonst *pm, boolean without_asking)
copynchars(eos(question), entrytext,
(int) (sizeof question - 1 - (strlen(question) + 2)));
Strcat(question, "\"?");
if (yn(question) == 'y')
if (y_n(question) == 'y')
yes_to_moreinfo = TRUE;
}
if (yes_to_moreinfo) {

View File

@@ -626,7 +626,7 @@ polyself(int psflags)
if (controllable_poly) {
Sprintf(buf, "Become %s?",
an(pmname(&mons[mntmp], gvariant)));
if (yn(buf) != 'y')
if (y_n(buf) != 'y')
return;
}
}
@@ -1559,7 +1559,7 @@ dogaze(void)
Sprintf(qbuf, "Really %s %s?",
(adtyp == AD_CONF) ? "confuse" : "attack",
mon_nam(mtmp));
if (yn(qbuf) != 'y')
if (y_n(qbuf) != 'y')
continue;
}
setmangry(mtmp, TRUE);

View File

@@ -538,7 +538,7 @@ dodrink(void)
if (IS_FOUNTAIN(levl[u.ux][u.uy].typ)
/* not as low as floor level but similar restrictions apply */
&& can_reach_floor(FALSE)) {
if (yn("Drink from the fountain?") == 'y') {
if (y_n("Drink from the fountain?") == 'y') {
drinkfountain();
return ECMD_TIME;
}
@@ -548,7 +548,7 @@ dodrink(void)
if (IS_SINK(levl[u.ux][u.uy].typ)
/* not as low as floor level but similar restrictions apply */
&& can_reach_floor(FALSE)) {
if (yn("Drink from the sink?") == 'y') {
if (y_n("Drink from the sink?") == 'y') {
drinksink();
return ECMD_TIME;
}
@@ -556,7 +556,7 @@ dodrink(void)
}
/* Or are you surrounded by water? */
if (Underwater && !u.uswallow) {
if (yn("Drink the water around you?") == 'y') {
if (y_n("Drink the water around you?") == 'y') {
pline("Do you know what lives in this water?");
return ECMD_TIME;
}
@@ -2248,7 +2248,7 @@ dodip(void)
Snprintf(qbuf, sizeof(qbuf), "%s%s into the fountain?", Dip_,
Verbose(3, dodip1) ? obuf : shortestname);
/* "Dip <the object> into the fountain?" */
if (yn(qbuf) == 'y') {
if (y_n(qbuf) == 'y') {
obj->pickup_prev = 0;
dipfountain(obj);
return ECMD_TIME;
@@ -2260,7 +2260,7 @@ dodip(void)
Snprintf(qbuf, sizeof(qbuf), "%s%s into the %s?", Dip_,
Verbose(3, dodip2) ? obuf : shortestname, pooltype);
/* "Dip <the object> into the {pool, moat, &c}?" */
if (yn(qbuf) == 'y') {
if (y_n(qbuf) == 'y') {
if (Levitation) {
floating_above(pooltype);
} else if (u.usteed && !is_swimmer(u.usteed->data)

View File

@@ -2044,7 +2044,7 @@ dopray(void)
from the do-again buffer, so need to suppress this response too;
otherwise subsequent ^A would use this answer for "are you sure?"
and bypass confirmation */
if ((ParanoidPray ? YN(forcesuccess) : yn(forcesuccess)) == 'y') {
if ((ParanoidPray ? YN(forcesuccess) : y_n(forcesuccess)) == 'y') {
u.ublesscnt = 0;
if (u.uluck < 0)
u.uluck = 0;

View File

@@ -583,7 +583,7 @@ doread(void)
maintained illiterate conduct so far, and this mail
scroll didn't come from bones, ask for confirmation */
if (!u.uconduct.literate) {
if (!scroll->spe && yn(
if (!scroll->spe && y_n(
"Reading mail will violate \"illiterate\" conduct. Read anyway?"
) != 'y')
return ECMD_OK;
@@ -3064,7 +3064,7 @@ create_particular_creation(
Sprintf(buf, "Creating %s instead; force %s?",
mons[d->which].pmnames[NEUTRAL],
mons[firstchoice].pmnames[NEUTRAL]);
if (yn(buf) == 'y')
if (y_n(buf) == 'y')
d->which = firstchoice;
}
whichpm = &mons[d->which];

View File

@@ -715,7 +715,7 @@ doconsult(struct monst *oracl)
return ECMD_OK;
Sprintf(qbuf, "\"Then dost thou desire a major one?\" (%d %s)",
major_cost, currency((long) major_cost));
if (yn(qbuf) != 'y')
if (y_n(qbuf) != 'y')
return ECMD_OK;
u_pay = (umoney < (long) major_cost) ? (int) umoney : major_cost;
break;

View File

@@ -51,7 +51,7 @@ int
dosave(void)
{
clear_nhwindow(WIN_MESSAGE);
if (yn("Really save?") == 'n') {
if (y_n("Really save?") == 'n') {
clear_nhwindow(WIN_MESSAGE);
if (gm.multi > 0)
nomul(0);
@@ -118,7 +118,7 @@ dosave0(void)
close_nhfile(nhfp);
clear_nhwindow(WIN_MESSAGE);
There("seems to be an old save file.");
if (yn("Overwrite the old file?") == 'n') {
if (y_n("Overwrite the old file?") == 'n') {
nh_compress(fq_save);
goto done;
}

View File

@@ -1751,7 +1751,7 @@ dopayobj(
(void) safe_qbuf(qbuf, (char *) 0, qsfx, obj,
(quan == 1L) ? Doname2 : doname, ansimpleoname,
(quan == 1L) ? "that" : "those");
if (yn(qbuf) == 'n') {
if (y_n(qbuf) == 'n') {
buy = PAY_SKIP; /* don't want to buy */
} else if (quan < bp->bquan && !consumed) { /* partly used goods */
obj->quan = bp->bquan - save_quan; /* used up amount */
@@ -4492,7 +4492,7 @@ pay_for_damage(const char* dmgstr, boolean cant_mollify)
Sprintf(qbuf, "%sYou did %ld %s worth of damage!%s Pay?",
!animal ? cad(TRUE) : "", cost_of_damage,
currency(cost_of_damage), !animal ? "\"" : "");
if (yn(qbuf) != 'n') {
if (y_n(qbuf) != 'n') {
boolean is_seen, was_seen = canseemon(shkp),
was_outside = !inhishop(shkp);
coordxy sx = shkp->mx, sy = shkp->my;

View File

@@ -543,7 +543,7 @@ study_book(register struct obj* spellbook)
/* hero has just been told what spell this book is for; it may
have been undiscovered if spell was learned via divine gift */
makeknown(booktype);
if (yn("Refresh your memory anyway?") == 'n')
if (y_n("Refresh your memory anyway?") == 'n')
return 0;
}
@@ -565,7 +565,7 @@ study_book(register struct obj* spellbook)
Sprintf(qbuf,
"This spellbook is %sdifficult to comprehend. Continue?",
(read_ability < 12 ? "very " : ""));
if (yn(qbuf) != 'y') {
if (y_n(qbuf) != 'y') {
spellbook->in_use = FALSE;
return 1;
}

View File

@@ -170,7 +170,7 @@ doride(void)
if (u.usteed) {
dismount_steed(DISMOUNT_BYCHOICE);
} else if (getdir((char *) 0) && isok(u.ux + u.dx, u.uy + u.dy)) {
if (wizard && yn("Force the mount to succeed?") == 'y')
if (wizard && y_n("Force the mount to succeed?") == 'y')
forcemount = TRUE;
return (mount_steed(m_at(u.ux + u.dx, u.uy + u.dy), forcemount)
? ECMD_TIME : ECMD_OK);
@@ -220,7 +220,7 @@ mount_steed(
legs_in_no_shape("riding", FALSE);
Sprintf(qbuf, "Heal your leg%s?",
((HWounded_legs & BOTH_SIDES) == BOTH_SIDES) ? "s" : "");
if (force && wizard && yn(qbuf) == 'y')
if (force && wizard && y_n(qbuf) == 'y')
heal_legs(0);
else
return (FALSE);

View File

@@ -565,7 +565,7 @@ scrolltele(struct obj* scroll)
You_feel("disoriented for a moment.");
/* don't discover the scroll [at least not yet for wizard override];
disorientation doesn't reveal that this is a teleport attempt */
if (!wizard || yn("Override?") != 'y')
if (!wizard || y_n("Override?") != 'y')
return;
}
if (((Teleport_control || (scroll && scroll->blessed)) && !Stunned)
@@ -738,7 +738,7 @@ dotele(
if (trap) {
if (trap->ttyp == LEVEL_TELEP && trap->tseen) {
if (yn("There is a level teleporter here. Trigger it?") == 'y') {
if (y_n("There is a level teleporter here. Trigger it?") == 'y') {
level_tele_trap(trap, FORCETRAP);
/* deliberate jumping will always take time even if it doesn't
* work */
@@ -749,7 +749,7 @@ dotele(
trap_once = trap->once; /* trap may get deleted, save this */
if (trap->once) {
pline("This is a vault teleport, usable once only.");
if (yn("Jump in?") == 'n') {
if (y_n("Jump in?") == 'n') {
trap = 0;
} else {
deltrap(trap);

View File

@@ -1172,7 +1172,7 @@ enhance_weapon_skill(void)
/* player knows about #enhance, don't show tip anymore */
gc.context.enhance_tip = TRUE;
if (wizard && yn("Advance skills without practice?") == 'y')
if (wizard && y_n("Advance skills without practice?") == 'y')
speedy = TRUE;
do {