X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fparsetime.c;h=8818f1cbe2cb8732d6476f6040bd9c41bbb3cd7d;hb=9f7c295af3d1743b9b9ee2b0e536384c27844473;hp=71af06572a64b9d6183566c7cf52a287eec11ec4;hpb=657d850f957a2dd703e3aab2d7cde4b0f9711c15;p=rrdtool.git diff --git a/src/parsetime.c b/src/parsetime.c index 71af065..8818f1c 100644 --- a/src/parsetime.c +++ b/src/parsetime.c @@ -139,7 +139,7 @@ struct SpecialToken { char *name; /* token name */ int value; /* token id */ }; -static struct SpecialToken VariousWords[] = { +static const struct SpecialToken VariousWords[] = { {"midnight", MIDNIGHT}, /* 00:00:00 of today or tomorrow */ {"noon", NOON}, /* 12:00:00 of today or tomorrow */ {"teatime", TEATIME}, /* 16:00:00 of today or tomorrow */ @@ -196,7 +196,7 @@ static struct SpecialToken VariousWords[] = { {NULL, 0} /*** SENTINEL ***/ }; -static struct SpecialToken TimeMultipliers[] = { +static const struct SpecialToken TimeMultipliers[] = { {"second", SECONDS}, /* seconds multiplier */ {"seconds", SECONDS}, /* (pluralized) */ {"sec", SECONDS}, /* (generic) */ @@ -232,7 +232,7 @@ static struct SpecialToken TimeMultipliers[] = { * required for us to be able distinguish between 'mon' as 'month' * and 'mon' as 'monday' */ -static struct SpecialToken *Specials; +static const struct SpecialToken *Specials; static const char **scp; /* scanner - pointer at arglist */ static char scc; /* scanner - count of remaining arguments */ @@ -326,10 +326,8 @@ static char *e( greater than zero if S1 is lexicographically less than, equal to or greater than S2. -- copied from GNU libc*/ static int mystrcasecmp( - s1, - s2) - const char *s1; - const char *s2; + const char *s1, + const char *s2) { const unsigned char *p1 = (const unsigned char *) s1; const unsigned char *p2 = (const unsigned char *) s2; @@ -391,7 +389,7 @@ static char *init_scanner( * token() fetches a token from the input stream */ static int token( - ) + void) { int idx; @@ -850,7 +848,7 @@ char *parsetime( ptv->type = ABSOLUTE_TIME; ptv->offset = 0; ptv->tm = *localtime(&now); - ptv->tm. tm_isdst = -1; /* mk time can figure this out for us ... */ + ptv->tm. tm_isdst = -1; /* mk time can figure dst by default ... */ token(); switch (sc_tokid) { @@ -980,8 +978,6 @@ char *parsetime( panic(e("unparsable trailing text: '...%s%s'", sc_token, sct)); } - ptv->tm. tm_isdst = -1; /* for mktime to guess DST status */ - if (ptv->type == ABSOLUTE_TIME) if (mktime(&ptv->tm) == -1) { /* normalize & check */ /* can happen for "nonexistent" times, e.g. around 3am */