]> sjero.net Git - wget/blobdiff - src/convert.c
[svn] Include ETA information in dot progress.
[wget] / src / convert.c
index 7ce42cb21b9291ee64135db236ec07c7ebff528d..8afef4c557e54dfaeab8905b1f111809575499c2 100644 (file)
@@ -31,17 +31,12 @@ so, delete this exception statement from your version.  */
 
 #include <stdio.h>
 #include <stdlib.h>
-#ifdef HAVE_STRING_H
-# include <string.h>
-#else
-# include <strings.h>
-#endif /* HAVE_STRING_H */
+#include <string.h>
 #ifdef HAVE_UNISTD_H
 # include <unistd.h>
 #endif /* HAVE_UNISTD_H */
 #include <errno.h>
 #include <assert.h>
-#include <sys/types.h>
 
 #include "wget.h"
 #include "convert.h"
@@ -58,7 +53,7 @@ struct hash_table *dl_url_file_map;
    conversion after Wget is done.  */
 struct hash_table *downloaded_html_set;
 
-static void convert_links PARAMS ((const char *, struct urlpos *));
+static void convert_links (const char *, struct urlpos *);
 
 /* This function is called when the retrieval is done to convert the
    links that have been downloaded.  It has to be called at the end of
@@ -173,17 +168,16 @@ convert_all_links (void)
 
   secs = ptimer_measure (timer) / 1000;
   ptimer_destroy (timer);
-  logprintf (LOG_VERBOSE, _("Converted %d files in %.*f seconds.\n"),
-            file_count, secs < 10 ? 3 : 1, secs);
+  logprintf (LOG_VERBOSE, _("Converted %d files in %s seconds.\n"),
+            file_count, print_decimal (secs));
 }
 
-static void write_backup_file PARAMS ((const char *, downloaded_file_t));
-static const char *replace_attr PARAMS ((const char *, int, FILE *,
-                                        const char *));
-static const char *replace_attr_refresh_hack PARAMS ((const char *, int, FILE *,
-                                                     const char *, int));
-static char *local_quote_string PARAMS ((const char *));
-static char *construct_relative PARAMS ((const char *, const char *));
+static void write_backup_file (const char *, downloaded_file_t);
+static const char *replace_attr (const char *, int, FILE *, const char *);
+static const char *replace_attr_refresh_hack (const char *, int, FILE *,
+                                             const char *, int);
+static char *local_quote_string (const char *);
+static char *construct_relative (const char *, const char *);
 
 /* Change the links in one HTML file.  LINKS is a list of links in the
    document, along with their positions and the desired direction of
@@ -388,7 +382,7 @@ construct_relative (const char *basefile, const char *linkfile)
     }
 
   /* Construct LINK as explained above. */
-  link = (char *)xmalloc (3 * basedirs + strlen (linkfile) + 1);
+  link = xmalloc (3 * basedirs + strlen (linkfile) + 1);
   for (i = 0; i < basedirs; i++)
     memcpy (link + 3 * i, "../", 3);
   strcpy (link + 3 * i, linkfile);
@@ -468,15 +462,14 @@ write_backup_file (const char *file, downloaded_file_t downloaded_file_return)
     }
 }
 
-static int find_fragment PARAMS ((const char *, int, const char **,
-                                 const char **));
+static bool find_fragment (const char *, int, const char **, const char **);
 
 /* Replace an attribute's original text with NEW_TEXT. */
 
 static const char *
 replace_attr (const char *p, int size, FILE *fp, const char *new_text)
 {
-  int quote_flag = 0;
+  bool quote_flag = false;
   char quote_char = '\"';      /* use "..." for quoting, unless the
                                   original value is quoted, in which
                                   case reuse its quoting char. */
@@ -492,7 +485,7 @@ replace_attr (const char *p, int size, FILE *fp, const char *new_text)
   if (*p == '\"' || *p == '\'')
     {
       quote_char = *p;
-      quote_flag = 1;
+      quote_flag = true;
       ++p;
       size -= 2;               /* disregard opening and closing quote */
     }
@@ -530,36 +523,36 @@ replace_attr_refresh_hack (const char *p, int size, FILE *fp,
 
 /* Find the first occurrence of '#' in [BEG, BEG+SIZE) that is not
    preceded by '&'.  If the character is not found, return zero.  If
-   the character is found, return 1 and set BP and EP to point to the
-   beginning and end of the region.
+   the character is found, return true and set BP and EP to point to
+   the beginning and end of the region.
 
    This is used for finding the fragment indentifiers in URLs.  */
 
-static int
+static bool
 find_fragment (const char *beg, int size, const char **bp, const char **ep)
 {
   const char *end = beg + size;
-  int saw_amp = 0;
+  bool saw_amp = false;
   for (; beg < end; beg++)
     {
       switch (*beg)
        {
        case '&':
-         saw_amp = 1;
+         saw_amp = true;
          break;
        case '#':
          if (!saw_amp)
            {
              *bp = beg;
              *ep = end;
-             return 1;
+             return true;
            }
          /* fallthrough */
        default:
-         saw_amp = 0;
+         saw_amp = false;
        }
     }
-  return 0;
+  return false;
 }
 
 /* Quote FILE for use as local reference to an HTML file.
@@ -630,9 +623,9 @@ local_quote_string (const char *file)
     dl_url_file_map = make_string_hash_table (0);      \
 } while (0)
 
-/* Return 1 if S1 and S2 are the same, except for "/index.html".  The
-   three cases in which it returns one are (substitute any substring
-   for "foo"):
+/* Return true if S1 and S2 are the same, except for "/index.html".
+   The three cases in which it returns one are (substitute any
+   substring for "foo"):
 
    m("foo/index.html", "foo/")  ==> 1
    m("foo/", "foo/index.html")  ==> 1
@@ -640,7 +633,7 @@ local_quote_string (const char *file)
    m("foo", "foo/"              ==> 1
    m("foo", "foo")              ==> 1  */
 
-static int
+static bool
 match_except_index (const char *s1, const char *s2)
 {
   int i;
@@ -653,14 +646,14 @@ match_except_index (const char *s1, const char *s2)
     /* Strings differ at the very beginning -- bail out.  We need to
        check this explicitly to avoid `lng - 1' reading outside the
        array.  */
-    return 0;
+    return false;
 
   if (!*s1 && !*s2)
     /* Both strings hit EOF -- strings are equal. */
-    return 1;
+    return true;
   else if (*s1 && *s2)
     /* Strings are randomly different, e.g. "/foo/bar" and "/foo/qux". */
-    return 0;
+    return false;
   else if (*s1)
     /* S1 is the longer one. */
     lng = s1;
@@ -679,7 +672,7 @@ match_except_index (const char *s1, const char *s2)
   if (*lng == '/' && *(lng + 1) == '\0')
     /* foo  */
     /* foo/ */
-    return 1;
+    return true;
 
   return 0 == strcmp (lng, "/index.html");
 }
@@ -837,7 +830,7 @@ register_html (const char *url, const char *file)
   string_set_add (downloaded_html_set, file);
 }
 
-static void downloaded_files_free PARAMS ((void));
+static void downloaded_files_free (void);
 
 /* Cleanup the data structures associated with this file.  */
 
@@ -992,7 +985,7 @@ html_quote_string (const char *s)
       else if (*s == ' ')
        i += 4;                 /* #32; */
     }
-  res = (char *)xmalloc (i + 1);
+  res = xmalloc (i + 1);
   s = b;
   for (p = res; *s; s++)
     {