-/* 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. */
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))
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;
}
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 ");
|| !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;
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) &&
!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;
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;
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;