(plurize): Fix initial length check to check for zero length of buf
not non-zero lengths of buf. (plurize): Change variable name size to len to improve readability.
This commit is contained in:
parent
079c231c7e
commit
58133fe575
1 changed files with 7 additions and 7 deletions
|
@ -60,21 +60,21 @@ iesplur(int n)
|
||||||
char *
|
char *
|
||||||
plurize(char *buf, int max_len, int n)
|
plurize(char *buf, int max_len, int n)
|
||||||
{
|
{
|
||||||
size_t size = strlen(buf);
|
size_t len = strlen(buf);
|
||||||
|
|
||||||
if (size || n <= 1)
|
if (!len || n <= 1)
|
||||||
return buf;
|
return buf;
|
||||||
|
|
||||||
switch(buf[size - 1]) {
|
switch(buf[len - 1]) {
|
||||||
case 'y':
|
case 'y':
|
||||||
buf[size - 1] = '\0';
|
buf[len - 1] = '\0';
|
||||||
strncat(buf, "ies", max_len - size - 1);
|
strncat(buf, "ies", max_len - len - 1);
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
strncat(buf, "es", max_len - size - 1);
|
strncat(buf, "es", max_len - len - 1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
strncat(buf, "s", max_len - size - 1);
|
strncat(buf, "s", max_len - len - 1);
|
||||||
}
|
}
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue