summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2014-04-08 14:21:16 +0200
committerHiltjo Posthuma <hiltjo@codemadness.org>2014-04-08 14:21:16 +0200
commit9526b568534577a39ac6810670c9421e5e521da9 (patch)
treef7401ec03ef9288c7263f29c142a1a7745196085
parent0e6e10da54b4e49da995a5b91c5654e345dfe323 (diff)
check mktime
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
-rw-r--r--sfeed.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/sfeed.c b/sfeed.c
index f739170..d00ecf9 100644
--- a/sfeed.c
+++ b/sfeed.c
@@ -341,7 +341,7 @@ parsetime(const char *s, char *buf, size_t bufsiz) {
NULL
};
char *p;
- int offset, i;
+ int i;
if(buf)
buf[0] = '\0';
@@ -349,20 +349,21 @@ parsetime(const char *s, char *buf, size_t bufsiz) {
for(i = 0; i < LEN(formats); i++) {
if((p = strptime(s, formats[i], &tm))) {
tm.tm_isdst = -1; /* don't use DST */
- t = mktime(&tm);
- offset = gettimetz(p, tz, sizeof(tz));
+ if((t = mktime(&tm)) == -1) /* error */
+ return t;
+ t -= gettimetz(p, tz, sizeof(tz));
if(buf)
snprintf(buf, bufsiz, "%04d-%02d-%02d %02d:%02d:%02d %-.16s",
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
tm.tm_hour, tm.tm_min, tm.tm_sec, tz);
- t -= offset;
break;
}
}
return t;
}
-static void /* print text, escape tabs, newline and carriage return etc */
+/* print text, escape tabs, newline and carriage return etc */
+static void
string_print(String *s) {
const char *p;
char buffer[BUFSIZ + 4];