diff --git a/src/cookies/cookies.c b/src/cookies/cookies.c index 1a31c0c8..455beb44 100644 --- a/src/cookies/cookies.c +++ b/src/cookies/cookies.c @@ -456,9 +456,9 @@ set_cookie(struct uri *uri, unsigned char *str) #ifdef DEBUG_COOKIES { DBG("Got cookie %s = %s from %s, domain %s, " - "expires at %d, secure %d", cookie->name, + "expires at %"TIME_PRINT_FORMAT", secure %d", cookie->name, cookie->value, cookie->server->host, cookie->domain, - cookie->expires, cookie->secure); + (time_print_T) cookie->expires, cookie->secure); } #endif @@ -672,8 +672,8 @@ send_cookies(struct uri *uri) if (c->expires && c->expires <= now) { #ifdef DEBUG_COOKIES - DBG("Cookie %s=%s (exp %d) expired.", - c->name, c->value, c->expires); + DBG("Cookie %s=%s (exp %"TIME_PRINT_FORMAT") expired.", + c->name, c->value, (time_print_T) c->expires); #endif delete_cookie(c); @@ -878,12 +878,12 @@ save_cookies(struct terminal *term) { now = time(NULL); foreach (c, cookies) { if (!c->expires || c->expires <= now) continue; - if (secure_fprintf(ssi, "%s\t%s\t%s\t%s\t%s\t%ld\t%d\n", + if (secure_fprintf(ssi, "%s\t%s\t%s\t%s\t%s\t%"TIME_PRINT_FORMAT"\t%d\n", c->name, c->value, c->server->host, empty_string_or_(c->path), empty_string_or_(c->domain), - c->expires, c->secure) < 0) + (time_print_T) c->expires, c->secure) < 0) break; } diff --git a/src/globhist/globhist.c b/src/globhist/globhist.c index d7a16200..f73e3d2c 100644 --- a/src/globhist/globhist.c +++ b/src/globhist/globhist.c @@ -393,10 +393,11 @@ write_global_history(void) if (!ssi) return; foreachback (history_item, global_history.entries) { - if (secure_fprintf(ssi, "%s\t%s\t%ld\n", + if (secure_fprintf(ssi, "%s\t%s\t%"TIME_PRINT_FORMAT"\n", history_item->title, history_item->url, - history_item->last_visit) < 0) break; + (time_print_T) history_item->last_visit) < 0) + break; } if (!secure_close(ssi)) global_history.dirty = 0; diff --git a/src/util/time.h b/src/util/time.h index 6fa73b0b..5ff63650 100644 --- a/src/util/time.h +++ b/src/util/time.h @@ -19,6 +19,11 @@ typedef long milliseconds_T; /* Is using atol() in this way acceptable? It seems * non-portable to me; time_t might not be a long. -- Miciah */ #define str_to_time_t(s) ((time_t) atol(s)) +/* When formatting time_t values to be parsed with str_to_time_t, + * we first cast to time_print_T and then printf the result with + * TIME_PRINT_FORMAT. */ +typedef long time_print_T; +#define TIME_PRINT_FORMAT "ld" /* Redefine a timeval that has all fields signed so calculations * will be simplified on rare systems that define timeval with