From 2e5668919988fce4e523cbf2294698841b1106a0 Mon Sep 17 00:00:00 2001 From: markus schnalke Date: Tue, 27 Mar 2012 12:12:06 +0200 Subject: [PATCH] We have only numeric timezone support (e.g. +0200) from now on. That's an mmh decision. Pulled in from nmh is the following part: Removed use of tzset()/tzname in dtimezone(). They caused the returned timezone string to be for the user's current timezone, but the function is supposed to return the string representation of the timezone of its argument. Thanks to David Levine. --- h/tws.h | 7 +++---- sbr/dtime.c | 40 +++++++++++----------------------------- sbr/fmt_scan.c | 4 +--- uip/anno.c | 2 +- uip/forw.c | 2 +- uip/inc.c | 2 +- uip/msgchk.c | 2 +- uip/pick.c | 2 +- uip/slocal.c | 2 +- uip/spost.c | 2 +- 10 files changed, 22 insertions(+), 43 deletions(-) diff --git a/h/tws.h b/h/tws.h index 289a673..420275c 100644 --- a/h/tws.h +++ b/h/tws.h @@ -38,7 +38,6 @@ struct tws { #define TW_SZEXP 0x0004 /* explicitly given */ #define TW_DST 0x0010 /* daylight savings time */ -#define TW_ZONE 0x0020 /* use numeric timezones only */ #define TW_SUCC 0x0040 /* whether parsing was successful */ #define TW_YES 0x0040 /* yes, found */ @@ -53,13 +52,13 @@ extern char *tw_moty[]; /* ** prototypes */ -char *dtime(time_t *, int); -char *dtimenow(int); +char *dtime(time_t *); +char *dtimenow(void); char *dctime(struct tws *); struct tws *dlocaltimenow(void); struct tws *dlocaltime(time_t *); struct tws *dgmtime(time_t *); -char *dasctime(struct tws *, int); +char *dasctime(struct tws *); char *dtimezone(int, int); void twscopy(struct tws *, struct tws *); int twsort(struct tws *, struct tws *); diff --git a/sbr/dtime.c b/sbr/dtime.c index 1273112..738ffd5 100644 --- a/sbr/dtime.c +++ b/sbr/dtime.c @@ -197,20 +197,17 @@ dctime(struct tws *tw) /* ** Produce a date/time string of the form ** -** Mon, 16 Jun 1992 15:30:48 -700 (or) -** Mon, 16 Jun 1992 15:30:48 EDT +** Mon, 16 Jun 1992 15:30:48 -0700 ** -** for the current time, as specified by rfc822. -** The first form is required by rfc1123. +** for the current time, as specified by rfc822 and rfc1123. */ - char * -dtimenow(int alpha_timezone) +dtimenow(void) { time_t clock; time(&clock); - return dtime(&clock, alpha_timezone); + return dtime(&clock); } @@ -218,22 +215,14 @@ dtimenow(int alpha_timezone) ** Using a local calendar time value, produce ** a date/time string of the form ** -** Mon, 16 Jun 1992 15:30:48 -700 (or) -** Mon, 16 Jun 1992 15:30:48 EDT +** Mon, 16 Jun 1992 15:30:48 -0700 ** -** as specified by rfc822. The first form is required -** by rfc1123 for outgoing messages. +** as specified by rfc822 and rfc1123. */ - char * -dtime(time_t *clock, int alpha_timezone) +dtime(time_t *clock) { - if (alpha_timezone) - /* use alpha-numeric timezones */ - return dasctime(dlocaltime(clock), TW_NULL); - else - /* use numeric timezones */ - return dasctime(dlocaltime(clock), TW_ZONE); + return dasctime(dlocaltime(clock)); } @@ -245,9 +234,8 @@ dtime(time_t *clock, int alpha_timezone) ** ** as specified by rfc822 and rfc1123. */ - char * -dasctime(struct tws *tw, int flags) +dasctime(struct tws *tw) { char buffer[80]; static char result[80]; @@ -259,7 +247,7 @@ dasctime(struct tws *tw, int flags) if ((tw->tw_flags & TW_SZONE) == TW_SZNIL) result[0] = '\0'; else - snprintf(result, sizeof(result), " %s", dtimezone(tw->tw_zone, tw->tw_flags | flags)); + snprintf(result, sizeof(result), " %s", dtimezone(tw->tw_zone, tw->tw_flags)); snprintf(buffer, sizeof(buffer), "%02d %s %0*d %02d:%02d:%02d%s", tw->tw_mday, tw_moty[tw->tw_mon], @@ -279,9 +267,8 @@ dasctime(struct tws *tw, int flags) /* -** Get the timezone for given offset +** Get the timezone for given offset as numeric value. */ - char * dtimezone(int offset, int flags) { @@ -296,11 +283,6 @@ dtimezone(int offset, int flags) hours = offset / 60; } - if (!(flags & TW_ZONE) && mins == 0) { - tzset(); - return ((flags & TW_DST) ? tzname[1] : tzname[0]); - } - #ifdef ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST if (flags & TW_DST) hours += 1; diff --git a/sbr/fmt_scan.c b/sbr/fmt_scan.c index 5103dbd..113b8cf 100644 --- a/sbr/fmt_scan.c +++ b/sbr/fmt_scan.c @@ -607,10 +607,8 @@ fmt_scan(struct format *format, char *scanl, int width, int *dat) value = fmt->f_comp->c_tws->tw_flags & TW_DST; break; case FT_LS_822DATE: - str = dasctime(fmt->f_comp->c_tws , TW_ZONE); - break; case FT_LS_PRETTY: - str = dasctime(fmt->f_comp->c_tws, TW_NULL); + str = dasctime(fmt->f_comp->c_tws); break; case FT_LS_PERS: diff --git a/uip/anno.c b/uip/anno.c index b1d8667..3b1d137 100644 --- a/uip/anno.c +++ b/uip/anno.c @@ -604,7 +604,7 @@ annosbr(int fd, char *file, char *comp, char *text, int datesw, int delete, } if (datesw) { - fprintf(tmp, "%s: %s\n", comp, dtimenow(0)); + fprintf(tmp, "%s: %s\n", comp, dtimenow()); } if ((cp = text)) { do { diff --git a/uip/forw.c b/uip/forw.c index 53b0968..be1242b 100644 --- a/uip/forw.c +++ b/uip/forw.c @@ -325,7 +325,7 @@ build_form(char *form, char *digest, int volume, int issue) cptr->c_text = digest; FINDCOMP(cptr, "date"); if (cptr) - cptr->c_text = getcpy(dtimenow(0)); + cptr->c_text = getcpy(dtimenow()); dat[0] = issue; dat[1] = volume; diff --git a/uip/inc.c b/uip/inc.c index 98fffef..ee51219 100644 --- a/uip/inc.c +++ b/uip/inc.c @@ -337,7 +337,7 @@ main(int argc, char **argv) chmod(audfile, m_gmprot()); fprintf(aud, from ? "<> %s -ms %s\n" : "<> %s\n", - dtimenow(0), from); + dtimenow(), from); } #ifdef MHE diff --git a/uip/msgchk.c b/uip/msgchk.c index b5b02c9..e2707d3 100644 --- a/uip/msgchk.c +++ b/uip/msgchk.c @@ -231,7 +231,7 @@ checkmail(char *user, int datesw, int notifysw, int personal) if (notifysw) { if (datesw && st.st_atime) { - printf("; last read on %s", dtime(&st.st_atime, 1)); + printf("; last read on %s", dtime(&st.st_atime)); } printf("\n"); } diff --git a/uip/pick.c b/uip/pick.c index 3fb853c..7f8d39a 100644 --- a/uip/pick.c +++ b/uip/pick.c @@ -829,7 +829,7 @@ PRaction(struct nexus *n, int level) if (n->n_action == TWSaction) { fprintf(stderr, "TEMPORAL(%s) %s: %s\n", n->n_after ? "after" : "before", n->n_datef, - dasctime(&n->n_tws, TW_NULL)); + dasctime(&n->n_tws)); return; } fprintf(stderr, "UNKNOWN(0x%x)\n", diff --git a/uip/slocal.c b/uip/slocal.c index c0f0922..b83a268 100644 --- a/uip/slocal.c +++ b/uip/slocal.c @@ -319,7 +319,7 @@ main(int argc, char **argv) if (!(now = dlocaltimenow())) { adios(NULL, "unable to ascertain local time"); } - snprintf(ddate, sizeof(ddate), "Delivery-Date: %s\n", dtimenow(0)); + snprintf(ddate, sizeof(ddate), "Delivery-Date: %s\n", dtimenow()); /* ** Copy the message to a temporary file diff --git a/uip/spost.c b/uip/spost.c index 43d3d10..69d4708 100644 --- a/uip/spost.c +++ b/uip/spost.c @@ -477,7 +477,7 @@ finish_headers(FILE *out) char *resentstr = (msgstate == resent) ? "Resent-" : ""; if (!(msgflags & MDAT)) { - fprintf(out, "%sDate: %s\n", resentstr, dtimenow(0)); + fprintf(out, "%sDate: %s\n", resentstr, dtimenow()); } strncpy(from, getusername(), sizeof(from)); -- 1.7.10.4