]> sjero.net Git - wget/blobdiff - src/http.c
The prefered way is to avoid #ifdef flooding, so take it that way. Introduce iri...
[wget] / src / http.c
index 682258c073c3d6bf5472f99c7962b7ac5f5e1f96..741ed2c003fb9a29855725c49fec1b86979c2d48 100644 (file)
@@ -49,6 +49,7 @@ as that of the covered work.  */
 #include "retr.h"
 #include "connect.h"
 #include "netrc.h"
+#include "iri.h"
 #ifdef HAVE_SSL
 # include "ssl.h"
 #endif
@@ -2040,32 +2041,16 @@ File %s already there; not retrieving.\n\n"), quote (hs->local_file));
       char *tmp = strchr (type, ';');
       if (tmp)
         {
-#ifdef ENABLE_IRI
+          /* sXXXav: only needed if IRI support is enabled */
           char *tmp2 = tmp + 1;
-#endif
 
           while (tmp > type && c_isspace (tmp[-1]))
             --tmp;
           *tmp = '\0';
 
-#ifdef ENABLE_IRI
-          if (opt.enable_iri && *tmp2 != '\0' &&
-              (tmp = strstr (tmp2, "charset=")) != NULL)
-            {
-              tmp += 8;
-              tmp2 = tmp;
-
-              while (*tmp2 && !c_isspace (*tmp2))
-                tmp2++;
-
-              if (tmp2 > tmp)
-                {
-                  *tmp2 = '\0';
-                  /* sXXXav : check given charset */
-                  logprintf (LOG_VERBOSE, "HTTP charset: `%s'\n", tmp);
-                }
-            }
-#endif
+          /* Try to get remote encoding if needed */
+          if (opt.enable_iri && !opt.encoding_remote)
+            /* xxx = */ parse_charset (tmp2);
         }
     }
   hs->newloc = resp_header_strdup (resp, "Location");
@@ -2931,7 +2916,7 @@ http_atotm (const char *time_string)
                                    Netscape cookie specification.) */
   };
   const char *oldlocale;
-  int i;
+  size_t i;
   time_t ret = (time_t) -1;
 
   /* Solaris strptime fails to recognize English month names in
@@ -3042,10 +3027,12 @@ digest_authentication_encode (const char *au, const char *user,
   au += 6;                      /* skip over `Digest' */
   while (extract_param (&au, &name, &value, ','))
     {
-      int i;
+      size_t i;
+      size_t namelen = name.e - name.b;
       for (i = 0; i < countof (options); i++)
-        if (name.e - name.b == strlen (options[i].name)
-            && 0 == strncmp (name.b, options[i].name, name.e - name.b))
+        if (namelen == strlen (options[i].name)
+            && 0 == strncmp (name.b, options[i].name,
+                             namelen))
           {
             *options[i].variable = strdupdelim (value.b, value.e);
             break;
@@ -3125,9 +3112,10 @@ username=\"%s\", realm=\"%s\", nonce=\"%s\", uri=\"%s\", response=\"%s\"",
    first argument and are followed by whitespace or terminating \0.
    The comparison is case-insensitive.  */
 #define STARTS(literal, b, e)                           \
-  ((e) - (b) >= STRSIZE (literal)                       \
+  ((e > b) \
+   && ((size_t) ((e) - (b))) >= STRSIZE (literal)   \
    && 0 == strncasecmp (b, literal, STRSIZE (literal))  \
-   && ((e) - (b) == STRSIZE (literal)                   \
+   && ((size_t) ((e) - (b)) == STRSIZE (literal)          \
        || c_isspace (b[STRSIZE (literal)])))
 
 static bool