summaryrefslogtreecommitdiffstats
path: root/usr.bin/at/parsetime.c
diff options
context:
space:
mode:
authorjoerg <joerg@FreeBSD.org>1995-06-24 17:15:56 +0000
committerjoerg <joerg@FreeBSD.org>1995-06-24 17:15:56 +0000
commitdfc3543be3d2d49efe3406eb29d02ee23e662582 (patch)
tree8241ba413f0171b1ee976cb752fd2494e2924f2e /usr.bin/at/parsetime.c
parentfd01f43e658d52cbc2253a75308d7ba068b31364 (diff)
downloadFreeBSD-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).
Diffstat (limited to 'usr.bin/at/parsetime.c')
-rw-r--r--usr.bin/at/parsetime.c20
1 files changed, 10 insertions, 10 deletions
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);
OpenPOWER on IntegriCloud