]> sjero.net Git - wget/blobdiff - src/iri.c
Quote some things that needed quoting.
[wget] / src / iri.c
index dce9e2ed0017a2a861a2f70f7474277cf2abfd16..1803ca710698f19048be43dcfb1164bbbede182d 100644 (file)
--- a/src/iri.c
+++ b/src/iri.c
@@ -39,7 +39,6 @@ as that of the covered work.  */
 #include <errno.h>
 
 #include "utils.h"
-#include "iri.h"
 
 /* RFC3987 section 3.1 mandates STD3 ASCII RULES */
 #define IDNA_FLAGS  IDNA_USE_STD3_ASCII_RULES
@@ -296,19 +295,32 @@ remote_to_utf8 (struct iri *i, const char *str, const char **new)
 struct iri *
 iri_new (void)
 {
-  struct iri *i = xmalloc (sizeof (struct iri));
+  struct iri *i = xmalloc (sizeof *i);
   i->uri_encoding = opt.encoding_remote ? xstrdup (opt.encoding_remote) : NULL;
   i->content_encoding = NULL;
+  i->orig_url = NULL;
   i->utf8_encode = opt.enable_iri;
   return i;
 }
 
+struct iri *iri_dup (const struct iri *src)
+{
+  struct iri *i = xmalloc (sizeof *i);
+  i->uri_encoding = src->uri_encoding ? xstrdup (src->uri_encoding) : NULL;
+  i->content_encoding = (src->content_encoding ?
+                         xstrdup (src->content_encoding) : NULL);
+  i->orig_url = src->orig_url ? xstrdup (src->orig_url) : NULL;
+  i->utf8_encode = src->utf8_encode;
+  return i;
+}
+
 /* Completely free an iri structure. */
 void
 iri_free (struct iri *i)
 {
   xfree_null (i->uri_encoding);
   xfree_null (i->content_encoding);
+  xfree_null (i->orig_url);
   xfree (i);
 }
 
@@ -317,7 +329,7 @@ iri_free (struct iri *i)
 void
 set_uri_encoding (struct iri *i, char *charset, bool force)
 {
-  DEBUGP (("URI encoding = `%s'\n", charset ? quote (charset) : "None"));
+  DEBUGP (("URI encoding = %s\n", charset ? quote (charset) : "None"));
   if (!force && opt.encoding_remote)
     return;
   if (i->uri_encoding)