42 lines
657 B
C
42 lines
657 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include "defs.h"
|
|
#include "objects.h"
|
|
|
|
char *capitalise(char *text) {
|
|
text[0] = toupper(text[0]);
|
|
return text;
|
|
}
|
|
|
|
int isvowel (char c) {
|
|
switch (c) {
|
|
case 'a':
|
|
case 'e':
|
|
case 'i':
|
|
case 'o':
|
|
case 'u':
|
|
return B_TRUE;
|
|
}
|
|
return B_FALSE;
|
|
}
|
|
|
|
// allocates and returns new string
|
|
char *makeplural(char *text) {
|
|
int newlen;
|
|
char *newtext;
|
|
char lastlet;
|
|
|
|
lastlet = text[strlen(text)-1];
|
|
switch (lastlet) {
|
|
case 's':
|
|
case 'o': // append "es"
|
|
asprintf(&newtext, "%ses",text);
|
|
break;
|
|
default: // append "s"
|
|
asprintf(&newtext, "%ss",text);
|
|
break;
|
|
}
|
|
return newtext;
|
|
}
|