From 9ae0328c3dc095848faf437f03027209ec963151 Mon Sep 17 00:00:00 2001 From: hniksic Date: Tue, 24 Apr 2001 17:50:22 -0700 Subject: [PATCH] [svn] Applied Roger Beeman's mktime_from_utc fix published in . Also, minor doc fixes. --- src/ChangeLog | 10 ++++++++++ src/html-url.c | 17 ++++++++++------- src/http.c | 40 +++++++++++++++++++++++++++------------- 3 files changed, 47 insertions(+), 20 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 1512e1e9..ddc8036b 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +2001-04-25 Roger L. Beeman + + * http.c (http_atotm): Initialize t.tm_isdst to 0. + (mktime_from_utc): Prevent mktime() from having discontinuities at + DST transition points. + +2001-04-25 Hrvoje Niksic + + * html-url.c (get_urls_html): Fix documentation. + 2001-04-25 Hrvoje Niksic * url.c (UNSAFE_CHAR): Reimplement using a static table. diff --git a/src/html-url.c b/src/html-url.c index 16d64cb3..433c9dca 100644 --- a/src/html-url.c +++ b/src/html-url.c @@ -365,7 +365,11 @@ handle_link (struct collect_urls_closure *closure, const char *link_uri, closure->tail = closure->head = newel; } -/* #### Document what this does. +/* Examine name and attributes of TAG and take appropriate action. + What will be done depends on TAG's category and attribute values. + Tags of TC_LINK category have attributes that contain links to + follow; tags of TC_SPEC category need to be handled specially. + #### It would be nice to split this into several functions. */ static void @@ -523,13 +527,12 @@ collect_tags_mapper (struct taginfo *tag, void *arg) } } -/* Scan FILE, retrieving links to HTML documents from it. Each link is - - Similar to get_urls_file, but for HTML files. FILE is scanned as - an HTML document. get_urls_html() constructs the URLs from the - relative href-s. +/* Analyze HTML tags FILE and construct a list of URLs referenced from + it. It merges relative links in FILE with THIS_URL. It is aware + of and does the right thing. - If SILENT is non-zero, do not barf on baseless relative links. */ + If dash_p_leaf_HTML is non-zero, only the elements needed to render + FILE ("non-external" links) will be returned. */ urlpos * get_urls_html (const char *file, const char *this_url, int dash_p_leaf_HTML, int *meta_disallow_follow) diff --git a/src/http.c b/src/http.c index 22fabdc6..42b2dbcb 100644 --- a/src/http.c +++ b/src/http.c @@ -1828,17 +1828,37 @@ The sizes do not match (local %ld) -- retrieving.\n"), local_size); than local timezone (mktime assumes the latter). Contributed by Roger Beeman , with the help of - Mark Baushke and the rest of the Gurus at CISCO. */ + Mark Baushke and the rest of the Gurus at CISCO. + Further improved by Roger with assistance from Edward J. Sabol + based on input by Jamie Zawinski. */ + static time_t mktime_from_utc (struct tm *t) { time_t tl, tb; + struct tm *tg; tl = mktime (t); if (tl == -1) - return -1; - tb = mktime (gmtime (&tl)); - return (tl <= tb ? (tl + (tl - tb)) : (tl - (tb - tl))); + { + t->tm_hour--; + tl = mktime (t); + if (tl == -1) + return -1; /* can't deal with output from strptime */ + tl += 3600; + } + tg = gmtime (&tl); + tg->tm_isdst = 0; + tb = mktime (tg); + if (tb == -1) + { + tg->tm_hour--; + tb = mktime (tg); + if (tb == -1) + return -1; /* can't deal with output from gmtime */ + tb += 3600; + } + return (tl - (tb - tl)); } /* Check whether the result of strptime() indicates success. @@ -1888,15 +1908,9 @@ http_atotm (char *time_string) { struct tm t; - /* Roger Beeman says: "This function dynamically allocates struct tm - t, but does no initialization. The only field that actually - needs initialization is tm_isdst, since the others will be set by - strptime. Since strptime does not set tm_isdst, it will return - the data structure with whatever data was in tm_isdst to begin - with. For those of us in timezones where DST can occur, there - can be a one hour shift depending on the previous contents of the - data area where the data structure is allocated." */ - t.tm_isdst = -1; + /* According to Roger Beeman, we need to initialize tm_isdst, since + strptime won't do it. */ + t.tm_isdst = 0; /* Note that under foreign locales Solaris strptime() fails to recognize English dates, which renders this function useless. I -- 2.39.2