MCPcopy Create free account
hub / github.com/NetHack/NetHack / ing_suffix

Function ing_suffix

src/hacklib.c:362–396  ·  view source on GitHub ↗

construct a gerund (a verb formed by appending "ing" to a noun) */

Source from the content-addressed store, hash-verified

360
361/* construct a gerund (a verb formed by appending "ing" to a noun) */
362char *
363ing_suffix(const char *s)
364{
365 static const char vowel[] = "aeiouwy";
366 static char buf[BUFSZ];
367 char onoff[10];
368 char *p;
369
370 Strcpy(buf, s);
371 p = eos(buf);
372 onoff[0] = *p = *(p + 1) = '\0';
373 if ((p >= &buf[3] && !strcmpi(p - 3, " on"))
374 || (p >= &buf[4] && !strcmpi(p - 4, " off"))
375 || (p >= &buf[5] && !strcmpi(p - 5, " with"))) {
376 p = strrchr(buf, ' ');
377 Strcpy(onoff, p);
378 *p = '\0';
379 }
380 if (p >= &buf[2] && !strcmpi(p - 2, "er")) { /* slither + ing */
381 /* nothing here */
382 } else if (p >= &buf[3] && !strchr(vowel, *(p - 1))
383 && strchr(vowel, *(p - 2)) && !strchr(vowel, *(p - 3))) {
384 /* tip -> tipp + ing */
385 *p = *(p - 1);
386 *(p + 1) = '\0';
387 } else if (p >= &buf[2] && !strcmpi(p - 2, "ie")) { /* vie -> vy + ing */
388 *(p - 2) = 'y';
389 *(p - 1) = '\0';
390 } else if (p >= &buf[1] && *(p - 1) == 'e') /* grease -> greas + ing */
391 *(p - 1) = '\0';
392 Strcat(buf, "ing");
393 if (onoff[0])
394 Strcat(buf, onoff);
395 return buf;
396}
397
398/* trivial text encryption routine (see makedefs) */
399char *

Callers 5

do_attackFunction · 0.85
nhl_ing_suffixFunction · 0.85
swim_move_dangerFunction · 0.85
hatch_eggFunction · 0.85
mime_actionFunction · 0.85

Calls 2

eosFunction · 0.85
strrchrFunction · 0.85

Tested by

no test coverage detected