From 489452a23a072949937733016062fcf5a16fce72 Mon Sep 17 00:00:00 2001 From: hniksic Date: Sun, 14 Dec 2003 05:35:27 -0800 Subject: [PATCH] [svn] Declare the pointers to literal strings as `const'. --- src/ChangeLog | 21 +++++++++++++++++++++ src/cookies.c | 2 +- src/ftp-ls.c | 2 +- src/init.c | 2 +- src/main.c | 8 ++++---- src/netrc.c | 3 ++- src/progress.c | 4 ++-- src/retr.c | 2 +- src/url.c | 4 ++-- 9 files changed, 35 insertions(+), 13 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 9a10ea46..f5588fbc 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,24 @@ +2003-12-14 Hrvoje Niksic + + * url.c (url_file_name): Ditto. + (parse_errors): Ditto. + + * retr.c (retr_rate): Ditto. + + * progress.c (create_image): Ditto. + + * netrc.c (parse_netrc): Ditto. + + * main.c (struct cmdline_option): Ditto. + (redirect_output_signal): Ditto. + + * init.c (commands): Ditto. + + * ftp-ls.c (ftp_index): Ditto. + + * cookies.c (check_domain_match): Declare the pointer to a literal + string as `const'. + 2003-12-12 Hrvoje Niksic * retr.c (fd_read_body): Pass total size to progress_create, not diff --git a/src/cookies.c b/src/cookies.c index 72ef0a9d..98ab423c 100644 --- a/src/cookies.c +++ b/src/cookies.c @@ -783,7 +783,7 @@ check_domain_match (const char *cookie_domain, const char *host) { int i; int known_toplevel = 0; - static char *known_toplevel_domains[] = { + static const char *known_toplevel_domains[] = { ".com", ".edu", ".net", ".org", ".gov", ".mil", ".int" }; for (i = 0; i < countof (known_toplevel_domains); i++) diff --git a/src/ftp-ls.c b/src/ftp-ls.c index 5c853229..189bad93 100644 --- a/src/ftp-ls.c +++ b/src/ftp-ls.c @@ -867,7 +867,7 @@ ftp_index (const char *file, struct url *u, struct fileinfo *f) { /* #### Should we translate the months? Or, even better, use ISO 8601 dates? */ - static char *months[] = { + static const char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; diff --git a/src/init.c b/src/init.c index 6ece81cd..baafc09c 100644 --- a/src/init.c +++ b/src/init.c @@ -104,7 +104,7 @@ CMD_DECLARE (cmd_spec_useragent); cleanup() function below. */ static struct { - char *name; + const char *name; void *closure; int (*action) PARAMS ((const char *, const char *, void *)); } commands[] = { diff --git a/src/main.c b/src/main.c index 6391ebf2..951dc04b 100644 --- a/src/main.c +++ b/src/main.c @@ -145,7 +145,7 @@ struct cmdline_option { OPT__NO, OPT__PARENT, } type; - void *data; /* for standard options */ + const void *data; /* for standard options */ int argtype; /* for non-standard options */ }; @@ -992,9 +992,9 @@ Can't timestamp and not clobber old files at the same time.\n")); static RETSIGTYPE redirect_output_signal (int sig) { - char *signal_name = (sig == SIGHUP ? "SIGHUP" : - (sig == SIGUSR1 ? "SIGUSR1" : - "WTF?!")); + const char *signal_name = (sig == SIGHUP ? "SIGHUP" : + (sig == SIGUSR1 ? "SIGUSR1" : + "WTF?!")); log_request_redirect_output (signal_name); progress_schedule_redirect (); signal (sig, redirect_output_signal); diff --git a/src/netrc.c b/src/netrc.c index af2b2b49..5f9588ed 100644 --- a/src/netrc.c +++ b/src/netrc.c @@ -258,7 +258,8 @@ static acc_t * parse_netrc (const char *path) { FILE *fp; - char *line, *p, *tok, *premature_token; + char *line, *p, *tok; + const char *premature_token; acc_t *current, *retval; int ln, quote; diff --git a/src/progress.c b/src/progress.c index 33ccb7c9..9ff2f983 100644 --- a/src/progress.c +++ b/src/progress.c @@ -50,7 +50,7 @@ so, delete this exception statement from your version. */ #include "retr.h" struct progress_implementation { - char *name; + const char *name; int interactive; void *(*create) PARAMS ((long, long)); void (*update) PARAMS ((void *, long, double)); @@ -834,7 +834,7 @@ create_image (struct bar_progress *bp, double dl_total_time) /* " 1012.45K/s" */ if (hist->total_time && hist->total_bytes) { - static char *short_units[] = { "B/s", "K/s", "M/s", "G/s" }; + static const char *short_units[] = { "B/s", "K/s", "M/s", "G/s" }; int units = 0; /* Calculate the download speed using the history ring and recent data that hasn't made it to the ring yet. */ diff --git a/src/retr.c b/src/retr.c index 3415ff02..1aae6e23 100644 --- a/src/retr.c +++ b/src/retr.c @@ -485,7 +485,7 @@ char * retr_rate (long bytes, double msecs, int pad) { static char res[20]; - static char *rate_names[] = {"B/s", "KB/s", "MB/s", "GB/s" }; + static const char *rate_names[] = {"B/s", "KB/s", "MB/s", "GB/s" }; int units = 0; double dlrate = calc_rate (bytes, msecs, &units); diff --git a/src/url.c b/src/url.c index 2bbf84be..8baa9869 100644 --- a/src/url.c +++ b/src/url.c @@ -636,7 +636,7 @@ lowercase_str (char *str) return change; } -static char *parse_errors[] = { +static const char *parse_errors[] = { #define PE_NO_ERROR 0 N_("No error"), #define PE_UNSUPPORTED_SCHEME 1 @@ -1563,7 +1563,7 @@ url_file_name (const struct url *u) { struct growable fnres; - char *u_file, *u_query; + const char *u_file, *u_query; char *fname, *unique; fnres.base = NULL; -- 2.39.2