construct a gerund (a verb formed by appending "ing" to a noun) */
| 360 | |
| 361 | /* construct a gerund (a verb formed by appending "ing" to a noun) */ |
| 362 | char * |
| 363 | ing_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) */ |
| 399 | char * |
no test coverage detected