]> sjero.net Git - wget/blobdiff - src/iri.c
Quote some things that needed quoting.
[wget] / src / iri.c
index ea4046afca4504e12257c009f1e473cc741d5702..1803ca710698f19048be43dcfb1164bbbede182d 100644 (file)
--- a/src/iri.c
+++ b/src/iri.c
@@ -295,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);
 }
 
@@ -316,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)