1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00

Change function params to const in src/iri.[ch]

* iri.h, iri.c: Added const attribute for params of parse_charsset(),
	check_encoding_name(), idn_encode(), idn_decode(),
	remote_to_utf8(), set_uri_encoding(), set_content_encoding().
This commit is contained in:
Tim Rühsen 2015-07-01 15:54:26 +02:00
parent 77f5a27e65
commit 25c9b462bf
2 changed files with 20 additions and 19 deletions

View File

@ -53,8 +53,9 @@ as that of the covered work. */
/* Given a string containing "charset=XXX", return the encoding if found,
or NULL otherwise */
char *
parse_charset (char *str)
parse_charset (const char *str)
{
const char *end;
char *charset;
if (!str || !*str)
@ -65,14 +66,14 @@ parse_charset (char *str)
return NULL;
str += 8;
charset = str;
end = str;
/* sXXXav: which chars should be banned ??? */
while (*charset && !c_isspace (*charset))
charset++;
while (*end && !c_isspace (*end))
end++;
/* sXXXav: could strdupdelim return NULL ? */
charset = strdupdelim (str, charset);
charset = strdupdelim (str, end);
/* Do a minimum check on the charset value */
if (!check_encoding_name (charset))
@ -95,9 +96,9 @@ find_locale (void)
/* Basic check of an encoding name. */
bool
check_encoding_name (char *encoding)
check_encoding_name (const char *encoding)
{
char *s = encoding;
const char *s = encoding;
while (*s)
{
@ -266,7 +267,7 @@ _utf8_is_valid(const char *utf8)
/* Try to "ASCII encode" UTF-8 host. Return the new domain on success or NULL
on error. */
char *
idn_encode (struct iri *i, char *host)
idn_encode (const struct iri *i, const char *host)
{
int ret;
char *ascii_encoded;
@ -304,7 +305,7 @@ idn_encode (struct iri *i, char *host)
/* Try to decode an "ASCII encoded" host. Return the new domain in the locale
on success or NULL on error. */
char *
idn_decode (char *host)
idn_decode (const char *host)
{
char *new;
int ret;
@ -323,7 +324,7 @@ idn_decode (char *host)
/* Try to transcode string str from remote encoding to UTF-8. On success, *new
contains the transcoded string. *new content is unspecified otherwise. */
bool
remote_to_utf8 (struct iri *iri, const char *str, char **new)
remote_to_utf8 (const struct iri *iri, const char *str, char **new)
{
bool ret = false;
@ -397,7 +398,7 @@ iri_free (struct iri *i)
/* Set uri_encoding of struct iri i. If a remote encoding was specified, use
it unless force is true. */
void
set_uri_encoding (struct iri *i, char *charset, bool force)
set_uri_encoding (struct iri *i, const char *charset, bool force)
{
DEBUGP (("URI encoding = %s\n", charset ? quote (charset) : "None"));
if (!force && opt.encoding_remote)
@ -414,7 +415,7 @@ set_uri_encoding (struct iri *i, char *charset, bool force)
/* Set content_encoding of struct iri i. */
void
set_content_encoding (struct iri *i, char *charset)
set_content_encoding (struct iri *i, const char *charset)
{
DEBUGP (("URI content encoding = %s\n", charset ? quote (charset) : "None"));
if (opt.encoding_remote)

View File

@ -43,18 +43,18 @@ struct iri {
# include <idna.h>
# include <idn-free.h>
char *parse_charset (char *str);
char *parse_charset (const char *str);
char *find_locale (void);
bool check_encoding_name (char *encoding);
bool check_encoding_name (const char *encoding);
const char *locale_to_utf8 (const char *str);
char *idn_encode (struct iri *i, char *host);
char *idn_decode (char *host);
bool remote_to_utf8 (struct iri *i, const char *str, char **new);
char *idn_encode (const struct iri *i, const char *host);
char *idn_decode (const char *host);
bool remote_to_utf8 (const struct iri *i, const char *str, char **new);
struct iri *iri_new (void);
struct iri *iri_dup (const struct iri *);
void iri_free (struct iri *i);
void set_uri_encoding (struct iri *i, char *charset, bool force);
void set_content_encoding (struct iri *i, char *charset);
void set_uri_encoding (struct iri *i, const char *charset, bool force);
void set_content_encoding (struct iri *i, const char *charset);
#else /* ENABLE_IRI */