remove a bunch of variables which were set but never used as pointed out by gcc
[rrdtool.git] / src / rrd_parsetime.c
index c1aef0b..d8b96f3 100644 (file)
 
 /* Local headers */
 
-#include "rrd_tool.h"
 #include <stdarg.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+#include "rrd_tool.h"
 
 /* Structures and unions */
 
 enum {                  /* symbols */
     MIDNIGHT, NOON, TEATIME,
-    PM, AM, YESTERDAY, TODAY, TOMORROW, NOW, START, END,
+    PM, AM, YESTERDAY, TODAY, TOMORROW, NOW, START, END, EPOCH,
     SECONDS, MINUTES, HOURS, DAYS, WEEKS, MONTHS, YEARS,
     MONTHS_MINUTES,
     NUMBER, PLUS, MINUS, DOT, COLON, SLASH, ID, JUNK,
@@ -154,6 +157,7 @@ static const struct SpecialToken VariousWords[] = {
     {"s", START},
     {"end", END},
     {"e", END},
+    {"epoch", EPOCH},
 
     {"jan", JAN},
     {"feb", FEB},
@@ -483,7 +487,7 @@ static char *expect2(
  *              It also applies those m-guessing heuristics.
  */
 static char *plus_minus(
-    rrd_time_value_t *ptv,
+    rrd_time_value_t * ptv,
     int doop)
 {
     static int op = PLUS;
@@ -569,7 +573,7 @@ static char *plus_minus(
  * tod() computes the time of day (TIME-OF-DAY-SPEC)
  */
 static char *tod(
-    rrd_time_value_t *ptv)
+    rrd_time_value_t * ptv)
 {
     int       hour, minute = 0;
     int       tlen;
@@ -595,7 +599,7 @@ static char *tod(
         scc = scc_sv;
         sct = sct_sv;
         sc_tokid = sc_tokid_sv;
-        sprintf(sc_token, "%d", hour);
+        snprintf(sc_token, sc_len, "%d", hour);
         return TIME_OK;
     }
     if (sc_tokid == COLON) {
@@ -627,7 +631,7 @@ static char *tod(
         scc = scc_sv;
         sct = sct_sv;
         sc_tokid = sc_tokid_sv;
-        sprintf(sc_token, "%d", hour);
+        snprintf(sc_token, sc_len, "%d", hour);
         return TIME_OK;
     }
     ptv->tm.  tm_hour = hour;
@@ -646,7 +650,7 @@ static char *tod(
  * assign_date() assigns a date, adjusting year as appropriate
  */
 static char *assign_date(
-    rrd_time_value_t *ptv,
+    rrd_time_value_t * ptv,
     long mday,
     long mon,
     long year)
@@ -679,11 +683,10 @@ static char *assign_date(
  * day() picks apart DAY-SPEC-[12]
  */
 static char *day(
-    rrd_time_value_t *ptv)
+    rrd_time_value_t * ptv)
 {
     /* using time_t seems to help portability with 64bit oses */
     time_t    mday = 0, wday, mon, year = ptv->tm.tm_year;
-    int       tlen;
 
     switch (sc_tokid) {
     case YESTERDAY:
@@ -752,7 +755,6 @@ static char *day(
     case NUMBER:
         /* get numeric <sec since 1970>, MM/DD/[YY]YY, or DD.MM.[YY]YY
          */
-        tlen = strlen(sc_token);
         mon = atol(sc_token);
         if (mon > 10 * 365 * 24 * 60 * 60) {
             ptv->tm = *localtime(&mon);
@@ -833,7 +835,7 @@ static char *day(
  */
 char     *rrd_parsetime(
     const char *tspec,
-    rrd_time_value_t *ptv)
+    rrd_time_value_t * ptv)
 {
     time_t    now = time(NULL);
     int       hr = 0;
@@ -856,6 +858,9 @@ char     *rrd_parsetime(
     case MINUS:
         break;          /* jump to OFFSET-SPEC part */
 
+    case EPOCH:
+        ptv->type = RELATIVE_TO_EPOCH;
+        goto KeepItRelative;
     case START:
         ptv->type = RELATIVE_TO_START_TIME;
         goto KeepItRelative;
@@ -990,8 +995,8 @@ char     *rrd_parsetime(
 
 
 int rrd_proc_start_end(
-    rrd_time_value_t *start_tv,
-    rrd_time_value_t *end_tv,
+    rrd_time_value_t * start_tv,
+    rrd_time_value_t * end_tv,
     time_t *start,
     time_t *end)
 {