mirror of
https://github.com/vattam/BSDGames.git
synced 2025-12-21 03:14:50 +00:00
Patch from Aaron Denney, fixing pluralization of singular fractions. Closes: #471762
This commit is contained in:
7
debian/changelog
vendored
7
debian/changelog
vendored
@@ -1,3 +1,10 @@
|
|||||||
|
bsdgames (2.17-13) UNRELEASED; urgency=low
|
||||||
|
|
||||||
|
* Patch from Aaron Denney, fixing pluralization of singular fractions.
|
||||||
|
Closes: #471762
|
||||||
|
|
||||||
|
-- Joey Hess <joeyh@debian.org> Thu, 20 Mar 2008 21:43:00 -0400
|
||||||
|
|
||||||
bsdgames (2.17-12) unstable; urgency=low
|
bsdgames (2.17-12) unstable; urgency=low
|
||||||
|
|
||||||
* Fix a bad cast in hunt that caused it to refuse to run on amd64 and likely
|
* Fix a bad cast in hunt that caused it to refuse to run on amd64 and likely
|
||||||
|
|||||||
@@ -78,9 +78,9 @@ static const char *const name1[] = {
|
|||||||
|
|
||||||
void convert(char *);
|
void convert(char *);
|
||||||
int main(int, char *[]);
|
int main(int, char *[]);
|
||||||
int number(const char *, int);
|
int number(const char *, int, int *);
|
||||||
void pfract(int);
|
void pfract(int, int);
|
||||||
int unit(int, const char *);
|
int unit(int, const char *, int *);
|
||||||
void usage(void) __attribute__((__noreturn__));
|
void usage(void) __attribute__((__noreturn__));
|
||||||
|
|
||||||
int lflag;
|
int lflag;
|
||||||
@@ -131,7 +131,7 @@ void
|
|||||||
convert(line)
|
convert(line)
|
||||||
char *line;
|
char *line;
|
||||||
{
|
{
|
||||||
int flen, len, rval;
|
int flen, len, rval, singular;
|
||||||
char *p, *fraction;
|
char *p, *fraction;
|
||||||
|
|
||||||
flen = 0;
|
flen = 0;
|
||||||
@@ -174,7 +174,7 @@ badnum: errx(1, "illegal number: %s", line);
|
|||||||
--len;
|
--len;
|
||||||
}
|
}
|
||||||
|
|
||||||
rval = len > 0 ? unit(len, line) : 0;
|
rval = len > 0 ? unit(len, line, &singular) : 0;
|
||||||
if (fraction != NULL && flen != 0)
|
if (fraction != NULL && flen != 0)
|
||||||
for (p = fraction; *p != '\0'; ++p)
|
for (p = fraction; *p != '\0'; ++p)
|
||||||
if (*p != '0') {
|
if (*p != '0') {
|
||||||
@@ -182,10 +182,10 @@ badnum: errx(1, "illegal number: %s", line);
|
|||||||
(void)printf("%sand%s",
|
(void)printf("%sand%s",
|
||||||
lflag ? " " : "",
|
lflag ? " " : "",
|
||||||
lflag ? " " : "\n");
|
lflag ? " " : "\n");
|
||||||
if (unit(flen, fraction)) {
|
if (unit(flen, fraction, &singular)) {
|
||||||
if (lflag)
|
if (lflag)
|
||||||
(void)printf(" ");
|
(void)printf(" ");
|
||||||
pfract(flen);
|
pfract(flen, singular);
|
||||||
rval = 1;
|
rval = 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -197,9 +197,10 @@ badnum: errx(1, "illegal number: %s", line);
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
unit(len, p)
|
unit(len, p, singular)
|
||||||
int len;
|
int len;
|
||||||
const char *p;
|
const char *p;
|
||||||
|
int *singular;
|
||||||
{
|
{
|
||||||
int off, rval;
|
int off, rval;
|
||||||
|
|
||||||
@@ -208,7 +209,7 @@ unit(len, p)
|
|||||||
if (len % 3) {
|
if (len % 3) {
|
||||||
off = len % 3;
|
off = len % 3;
|
||||||
len -= off;
|
len -= off;
|
||||||
if (number(p, off)) {
|
if (number(p, off, singular)) {
|
||||||
rval = 1;
|
rval = 1;
|
||||||
(void)printf(" %s%s",
|
(void)printf(" %s%s",
|
||||||
name3[len / 3], lflag ? " " : ".\n");
|
name3[len / 3], lflag ? " " : ".\n");
|
||||||
@@ -217,14 +218,16 @@ unit(len, p)
|
|||||||
}
|
}
|
||||||
for (; len > 3; p += 3) {
|
for (; len > 3; p += 3) {
|
||||||
len -= 3;
|
len -= 3;
|
||||||
if (number(p, 3)) {
|
if (number(p, 3, singular)) {
|
||||||
rval = 1;
|
rval = 1;
|
||||||
(void)printf(" %s%s",
|
(void)printf(" %s%s",
|
||||||
name3[len / 3], lflag ? " " : ".\n");
|
name3[len / 3], lflag ? " " : ".\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (number(p, len)) {
|
if (number(p, len, singular)) {
|
||||||
|
if (rval)
|
||||||
|
*singular = 0;
|
||||||
if (!lflag)
|
if (!lflag)
|
||||||
(void)printf(".\n");
|
(void)printf(".\n");
|
||||||
rval = 1;
|
rval = 1;
|
||||||
@@ -233,17 +236,20 @@ unit(len, p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
number(p, len)
|
number(p, len, singular)
|
||||||
const char *p;
|
const char *p;
|
||||||
int len;
|
int len;
|
||||||
|
int *singular;
|
||||||
{
|
{
|
||||||
int val, rval;
|
int val, rval;
|
||||||
|
|
||||||
rval = 0;
|
rval = 0;
|
||||||
|
*singular = 1;
|
||||||
switch (len) {
|
switch (len) {
|
||||||
case 3:
|
case 3:
|
||||||
if (*p != '0') {
|
if (*p != '0') {
|
||||||
rval = 1;
|
rval = 1;
|
||||||
|
*singular = 0;
|
||||||
(void)printf("%s hundred", name1[*p - '0']);
|
(void)printf("%s hundred", name1[*p - '0']);
|
||||||
}
|
}
|
||||||
++p;
|
++p;
|
||||||
@@ -262,33 +268,42 @@ number(p, len)
|
|||||||
}
|
}
|
||||||
rval = 1;
|
rval = 1;
|
||||||
}
|
}
|
||||||
|
if (val != 1)
|
||||||
|
*singular = 0;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
if (*p != '0') {
|
if (*p != '0') {
|
||||||
rval = 1;
|
rval = 1;
|
||||||
(void)printf("%s", name1[*p - '0']);
|
(void)printf("%s", name1[*p - '0']);
|
||||||
}
|
}
|
||||||
|
if (*p != '1')
|
||||||
|
*singular = 0;
|
||||||
}
|
}
|
||||||
return (rval);
|
return (rval);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
pfract(len)
|
pfract(len, singular)
|
||||||
int len;
|
int len;
|
||||||
|
int singular;
|
||||||
{
|
{
|
||||||
static const char *const pref[] = { "", "ten-", "hundred-" };
|
static const char *const pref[] = { "", "ten-", "hundred-" };
|
||||||
|
|
||||||
switch(len) {
|
switch(len) {
|
||||||
case 1:
|
case 1:
|
||||||
(void)printf("tenths.\n");
|
(void)printf("tenth");
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
(void)printf("hundredths.\n");
|
(void)printf("hundredth");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
(void)printf("%s%sths.\n", pref[len % 3], name3[len / 3]);
|
(void)printf("%s%sth", pref[len % 3], name3[len / 3]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (!singular) {
|
||||||
|
printf("s");
|
||||||
|
}
|
||||||
|
printf(".\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
minus
|
minus
|
||||||
one.
|
one.
|
||||||
tenths.
|
tenth.
|
||||||
|
|||||||
Reference in New Issue
Block a user