diff options
author | ache <ache@FreeBSD.org> | 2001-03-21 15:41:02 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 2001-03-21 15:41:02 +0000 |
commit | e9ffe1d632ff6c99842ce712e7780d7ea8383fab (patch) | |
tree | 0b93159da5c0dd744f58beee638290b3f200e39d /usr.bin/calendar | |
parent | a2371a0b8c39a7e176daff1690eb14c0babc16df (diff) | |
download | FreeBSD-src-e9ffe1d632ff6c99842ce712e7780d7ea8383fab.zip FreeBSD-src-e9ffe1d632ff6c99842ce712e7780d7ea8383fab.tar.gz |
Don't attempt to parse %c, use nl_langinfo instead
Diffstat (limited to 'usr.bin/calendar')
-rw-r--r-- | usr.bin/calendar/io.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/usr.bin/calendar/io.c b/usr.bin/calendar/io.c index b9d49d5..51ab84b 100644 --- a/usr.bin/calendar/io.c +++ b/usr.bin/calendar/io.c @@ -51,6 +51,7 @@ static const char sccsid[] = "@(#)calendar.c 8.3 (Berkeley) 3/25/94"; #include <unistd.h> #include <err.h> #include <errno.h> +#include <langinfo.h> #include <locale.h> #include <string.h> #include <sys/uio.h> @@ -90,6 +91,7 @@ cal() int month; int day; int var; + static int d_first = -1; char buf[2048 + 1]; if ((fp = opencal()) == NULL) @@ -108,6 +110,7 @@ cal() continue; if (strncmp(buf, "LANG=", 5) == 0) { (void) setlocale(LC_ALL, buf + 5); + d_first = (*nl_langinfo(D_MD_ORDER) == 'd'); setnnames(); continue; } @@ -135,8 +138,10 @@ cal() var = 1; if (printing) { struct tm tm; - char dbuf[30]; + char dbuf[80]; + if (d_first < 0) + d_first = (*nl_langinfo(D_MD_ORDER) == 'd'); tm.tm_sec = 0; /* unused */ tm.tm_min = 0; /* unused */ tm.tm_hour = 0; /* unused */ @@ -144,10 +149,10 @@ cal() tm.tm_mon = month - 1; tm.tm_mday = day; tm.tm_year = tp->tm_year; /* unused */ - (void)strftime(dbuf, sizeof(dbuf), "%c", &tm); - dbuf[10] = '\0'; - (void)fprintf(fp, "%s%c%s\n", - dbuf + 4/* skip weekdays */, + (void)strftime(dbuf, sizeof(dbuf), + d_first ? "%e %b" : "%b %e", + &tm); + (void)fprintf(fp, "%s%c%s\n", dbuf, var ? '*' : ' ', p); } } |