]> sjero.net Git - wget/commitdiff
[svn] Applied Roger Beeman's mktime_from_utc fix published in
authorhniksic <devnull@localhost>
Wed, 25 Apr 2001 00:50:22 +0000 (17:50 -0700)
committerhniksic <devnull@localhost>
Wed, 25 Apr 2001 00:50:22 +0000 (17:50 -0700)
<Pine.HPX.4.02.10104181128180.6232-100000@mail1.cisco.com>.
Also, minor doc fixes.

src/ChangeLog
src/html-url.c
src/http.c

index 1512e1e9df4b8cea22f88bc4995bccbc88665dc4..ddc8036b1c3722587b6de0d494c5ff55c1d5b7f5 100644 (file)
@@ -1,3 +1,13 @@
+2001-04-25  Roger L. Beeman  <beeman@cisco.com>
+
+       * 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  <hniksic@arsdigita.com>
+
+       * html-url.c (get_urls_html): Fix documentation.
+
 2001-04-25  Hrvoje Niksic  <hniksic@arsdigita.com>
 
        * url.c (UNSAFE_CHAR): Reimplement using a static table.
index 16d64cb36ae12e9c2a6c0b065aa60590f81475b9..433c9dcae78e59f6c4e4778b79888c9e138d233c 100644 (file)
@@ -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 <base href=...> 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)
index 22fabdc6360793f05d7f4d160480a9af6adb9a39..42b2dbcb89c2cf67c1a575506eb9d320c41cb305 100644 (file)
@@ -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 <beeman@cisco.com>, with the help of
-   Mark Baushke <mdb@cisco.com> and the rest of the Gurus at CISCO.  */
+   Mark Baushke <mdb@cisco.com> 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