]> granicus.if.org Git - nethack/commitdiff
Fix C343-108 (e- leaves prompt on screen)
authorPasi Kallinen <paxed@alt.org>
Fri, 20 Mar 2015 17:25:19 +0000 (19:25 +0200)
committerPasi Kallinen <paxed@alt.org>
Fri, 20 Mar 2015 17:25:24 +0000 (19:25 +0200)
You'll get "You mime eating something."

include/extern.h
src/hacklib.c
src/invent.c

index 23d10d32488c33408fda1cc2f3d6103a0c7b3ad2..1ba3e110fffb224faa9435c876c08886cf28e496 100644 (file)
@@ -813,6 +813,7 @@ E void FDECL(copynchars, (char *,const char *,int));
 E char FDECL(chrcasecpy, (int,int));
 E char *FDECL(strcasecpy, (char *,const char *));
 E char *FDECL(s_suffix, (const char *));
+E char *FDECL(ing_suffix, (const char *));
 E char *FDECL(xcrypt, (const char *,char *));
 E boolean FDECL(onlyspace, (const char *));
 E char *FDECL(tabexpand, (char *));
index fd4273074274c8af5dff81880d60c300147dc03c..005aa02b98248c583b43c97461cbe92193727050 100644 (file)
@@ -235,6 +235,39 @@ s_suffix(s)                /* return a name converted to possessive */
     return buf;
 }
 
+char *
+ing_suffix(s)
+     const char *s;
+{
+    const char *vowel = "aeiouy";
+    static char buf[BUFSZ];
+    char onoff[10];
+    char *p;
+    Strcpy(buf, s);
+    p = eos(buf);
+    onoff[0] = *p = *(p+1) = '\0';
+    if ((strlen(buf) > 4) &&
+       (!strcmpi(p-3, " on") ||
+        !strcmpi(p-4, " off") ||
+        !strcmpi(p-5, " with"))) {
+       p = strrchr(buf, ' ');
+       Strcpy(onoff, p);
+    }
+    if (!index(vowel, *(p-1)) && index(vowel, *(p-2)) && !index(vowel, *(p-3))) {
+       /* tip -> tipp + ing */
+       *p = *(p-1);
+       *(p+1) = '\0';
+    } else if (!strcmpi(p-2, "ie")) {  /* vie -> vy + ing */
+       *(p-2) = 'y';
+       *(p-1) = '\0';
+    } else if (*(p-1) == 'e')  /* grease -> greas + ing */
+       *(p-1) = '\0';
+    Strcat(buf, "ing");
+    if (onoff[0]) Strcat(buf, onoff);
+    return buf;
+}
+
+
 char *
 xcrypt(str, buf)       /* trivial text encryption routine (see makedefs) */
 const char *str;
index 24213c7e37823f18a0fd157a5f0273f88cd34909..66e7e73075f4a9991169de5fdbc65b86bc44a211 100644 (file)
@@ -972,7 +972,15 @@ register const char *let,*word;
                    return((struct obj *)0);
                }
                if(ilet == '-') {
-                       return(allownone ? &zeroobj : (struct obj *) 0);
+                   if (!allownone) {
+                       strcpy(buf, word);
+                       if ((bp = strstr(buf, " or ")) != NULL) {
+                           *bp = '\0';
+                           bp = (rn2(2) ? buf : (bp + 4));
+                       } else bp = buf;
+                       You("mime %s something.", ing_suffix(bp));
+                   }
+                   return(allownone ? &zeroobj : (struct obj *) 0);
                }
                if(ilet == def_oc_syms[COIN_CLASS].sym) {
                        if (!usegold) {