diff --git a/doc/fixes35.0 b/doc/fixes35.0 index 45db2795a..fcd1b6997 100644 --- a/doc/fixes35.0 +++ b/doc/fixes35.0 @@ -90,6 +90,10 @@ losing a level while polymorphed affects hero's current monster HP as well as underlying normal HP mind flayer brain eating is subject to certain fatal targets and to cannibalism corpses of unique monsters in bones behaved incorrectly if revived or eaten +fix pluralization for "this tin smells like mother-in-laws" when hallucinating +try harder to keep pluralization straight when user assigns an already plural + value for named fruit +avoid false matches when looking up fruit names ("grapefruit" isn't "grape") Platform- and/or Interface-Specific Fixes diff --git a/src/objnam.c b/src/objnam.c index cc9dcac50..d416eff2e 100644 --- a/src/objnam.c +++ b/src/objnam.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)objnam.c 3.5 2005/01/31 */ +/* SCCS Id: @(#)objnam.c 3.5 2005/10/21 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -223,6 +223,7 @@ register struct obj *obj; register const char *actualn = OBJ_NAME(*ocl); register const char *dn = OBJ_DESCR(*ocl); register const char *un = ocl->oc_uname; + boolean pluralize = (obj->quan != 1L); buf = nextobuf() + PREFIX; /* leave room for "17 -3 " */ if (Role_if(PM_SAMURAI) && Japanese_item_name(typ)) @@ -326,7 +327,16 @@ register struct obj *obj; break; } } - if (!f) impossible("Bad fruit #%d?", obj->spe); + if (!f) { + impossible("Bad fruit #%d?", obj->spe); + Strcpy(buf, "fruit"); + } else if (pluralize) { + /* ick; already pluralized fruit names + are allowed--we want to try to avoid + adding a redundant plural suffix */ + Strcpy(buf, makeplural(makesingular(buf))); + pluralize = FALSE; + } break; } @@ -451,7 +461,7 @@ register struct obj *obj; default: Sprintf(buf,"glorkum %d %d %d", obj->oclass, typ, obj->spe); } - if (obj->quan != 1L) Strcpy(buf, makeplural(buf)); + if (pluralize) Strcpy(buf, makeplural(buf)); if (obj->onamelth && obj->dknown) { Strcat(buf, " named "); @@ -1360,7 +1370,8 @@ const char *oldstr; || !strncmp(spot, " with", 5) /* " with "? */ || !strncmp(spot, " de ", 4) || !strncmp(spot, " d'", 3) - || !strncmp(spot, " du ", 4)) { + || !strncmp(spot, " du ", 4) + || !strncmp(spot, "-in-", 4)) { excess = oldstr + (int) (spot - str); *spot = 0; break; @@ -1596,8 +1607,14 @@ const char *oldstr; bp = str; while (*bp == ' ') bp++; - /* find "cloves of garlic", "worthless pieces of blue glass" */ - if ((p = strstri(bp, "s of ")) != 0) { + /* find "cloves of garlic", "worthless pieces of blue glass", + "mothers-in-law"; note: this should probably be implemented + recursively since it can't recognize whether we should be + removing "es" rather than just "s" */ + if ((p = strstri(bp, " of ")) != 0 || + (p = strstri(bp, "-in-")) != 0) { + if (BSTRNCMP(bp, p-1, "s", 1)) return bp; /* wasn't plural */ + --p; /* back up to the 's' */ /* but don't singularize "gauntlets", "boots", "Eyes of the.." */ if (BSTRNCMPI(bp, p-3, "Eye", 3) && BSTRNCMP(bp, p-4, "boot", 4) && @@ -1931,7 +1948,8 @@ struct obj *no_wish; !strncmpi(bp, "rotted ", l=7)) { eroded2 = 1 + very; very = 0; - } else if (!strncmpi(bp, "partly eaten ", l=13)) { + } else if (!strncmpi(bp, "partly eaten ", l=13) || + !strncmpi(bp, "partially eaten ", l=16)) { halfeaten = 1; } else if (!strncmpi(bp, "historic ", l=9)) { ishistoric = 1; @@ -2308,7 +2326,10 @@ srch: typ = TIN; goto typfnd; } - /* Note: not strncmpi. 2 fruits, one capital, one not, are possible. */ + /* Note: not strcmpi. 2 fruits, one capital, one not, are possible. + Also not strncmp. We used to ignore trailing text with it, but + that resulted in "grapefruit" matching "grape" if the latter came + earlier than the former in the fruit list. */ { char *fp; int l, cntf; @@ -2334,22 +2355,32 @@ srch: iscursedf = 1; } else if (!strncmpi(fp, "uncursed ", l=9)) { uncursedf = 1; - } else if (!strncmpi(fp, "partly eaten ", l=13)) { + } else if (!strncmpi(fp, "partly eaten ", l=13) || + !strncmpi(fp, "partially eaten ", l=16)) { halfeatenf = 1; } else break; fp += l; } for(f=ffruit; f; f = f->nextf) { - char *f1 = f->fname, *f2 = makeplural(f->fname); + /* match type: 0=none, 1=exact, 2=singular, 3=plural */ + int ftyp = 0; - if(!strncmp(fp, f1, strlen(f1)) || - !strncmp(fp, f2, strlen(f2))) { + if (!strcmp(fp, f->fname)) ftyp = 1; + else if (!strcmp(fp, makesingular(f->fname))) ftyp = 2; + else if (!strcmp(fp, makeplural(f->fname))) ftyp = 3; + if (ftyp) { typ = SLIME_MOLD; blessed = blessedf; iscursed = iscursedf; uncursed = uncursedf; halfeaten = halfeatenf; + /* adjust count if user explicitly asked for + singular amount (can't happen unless fruit + has been given an already pluralized name) + or for plural amount */ + if (ftyp == 2 && !cntf) cntf = 1; + else if (ftyp == 3 && !cntf) cntf = 2; cnt = cntf; ftype = f->fid; goto typfnd;