diff options
author | joerg <joerg@FreeBSD.org> | 1995-06-24 17:15:56 +0000 |
---|---|---|
committer | joerg <joerg@FreeBSD.org> | 1995-06-24 17:15:56 +0000 |
commit | dfc3543be3d2d49efe3406eb29d02ee23e662582 (patch) | |
tree | 8241ba413f0171b1ee976cb752fd2494e2924f2e | |
parent | fd01f43e658d52cbc2253a75308d7ba068b31364 (diff) | |
download | FreeBSD-src-dfc3543be3d2d49efe3406eb29d02ee23e662582.zip FreeBSD-src-dfc3543be3d2d49efe3406eb29d02ee23e662582.tar.gz |
Make parsetime.c more consistent by using the (already declared) enum
type instead of int all over the place. (Cosmetic, enhances
debugging.)
Point out that a date specification _must_ follow the time of day
spec, in the man page. This clarifies the last point PR # of bin/483:
"at doesn't seem to ..." (the remainder has already been fixed with
version 1.3 of parsetime.c).
-rw-r--r-- | usr.bin/at/at.man | 4 | ||||
-rw-r--r-- | usr.bin/at/parsetime.c | 20 |
2 files changed, 13 insertions, 11 deletions
diff --git a/usr.bin/at/at.man b/usr.bin/at/at.man index 21e789c..d279ff8 100644 --- a/usr.bin/at/at.man +++ b/usr.bin/at/at.man @@ -1,4 +1,4 @@ -.\" $Id: at.man,v 1.3 1994/06/16 16:49:46 kernel Exp $ +.\" $Id: at.man,v 1.1 1995/04/12 02:42:31 ache Exp $ .Dd April 12, 1995 .Dt "AT" 1 .Os "FreeBSD 2.1" @@ -81,6 +81,8 @@ or .Ar MM/DD/YY or .Ar DD.MM.YY . +The specification of a date must follow the specification of +the time of day. You can also give times like .Op Nm now .Nm + Ar count \%time-units , diff --git a/usr.bin/at/parsetime.c b/usr.bin/at/parsetime.c index 867893c..88cc5ed 100644 --- a/usr.bin/at/parsetime.c +++ b/usr.bin/at/parsetime.c @@ -56,7 +56,7 @@ /* Structures and unions */ -enum { /* symbols */ +enum tok { /* symbols */ MIDNIGHT, NOON, TEATIME, PM, AM, TOMORROW, TODAY, NOW, MINUTES, HOURS, DAYS, WEEKS, @@ -69,8 +69,8 @@ enum { /* symbols */ /* parse translation table - table driven parsers can be your FRIEND! */ struct { - char *name; /* token name */ - int value; /* token id */ + const char *name; /* token name */ + enum tok value; /* token id */ int plural; /* is this plural? */ } Specials[] = { { "midnight", MIDNIGHT,0 }, /* 00:00:00 of today or tomorrow */ @@ -127,18 +127,18 @@ static int need; /* scanner - need to advance to next argument */ static char *sc_token; /* scanner - token buffer */ static size_t sc_len; /* scanner - lenght of token buffer */ -static int sc_tokid; /* scanner - token id */ +static enum tok sc_tokid; /* scanner - token id */ static int sc_tokplur; /* scanner - is token plural? */ -static char rcsid[] = "$Id: parsetime.c,v 1.3 1995/04/12 02:42:35 ache Exp $"; +static char rcsid[] = "$Id: parsetime.c,v 1.4 1995/05/30 06:29:25 rgrimes Exp $"; /* Local functions */ /* * parse a token, checking if it's something special to us */ -static int -parse_token(char *arg) +static enum tok +parse_token(const char *arg) { int i; @@ -172,7 +172,7 @@ init_scanner(int argc, char **argv) /* * token() fetches a token from the input stream */ -static int +static enum tok token() { int idx; @@ -250,7 +250,7 @@ plonk(int tok) * expect() gets a token and dies most horribly if it's not the token we want */ static void -expect(int desired) +expect(enum tok desired) { if (token() != desired) plonk(sc_tokid); /* and we die here... */ @@ -489,7 +489,7 @@ month(struct tm *tm) token(); if (sc_tokid == SLASH || sc_tokid == DOT) { - int sep; + enum tok sep; sep = sc_tokid; expect(NUMBER); |