diff --git a/src/ChangeLog b/src/ChangeLog index d0059adc..a97437ad 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2014-11-24 Tim Ruehsen + + * wget.h, test.c, main.c: Make program_name and program_argstring const + 2014-11-24 Tim Ruehsen * warc.c: Fix C89 compile errors using ./configure --without-libuuid diff --git a/src/main.c b/src/main.c index 6f5adf74..c657c649 100644 --- a/src/main.c +++ b/src/main.c @@ -1001,8 +1001,8 @@ There is NO WARRANTY, to the extent permitted by law.\n"), stdout) < 0) exit (WGET_EXIT_SUCCESS); } -char *program_name; /* Needed by lib/error.c. */ -char *program_argstring; /* Needed by wget_warc.c. */ +const char *program_name; /* Needed by lib/error.c. */ +const char *program_argstring; /* Needed by wget_warc.c. */ int main (int argc, char **argv) @@ -1044,7 +1044,7 @@ main (int argc, char **argv) /* Construct the arguments string. */ for (argstring_length = 1, i = 1; i < argc; i++) argstring_length += strlen (argv[i]) + 2 + 1; - p = program_argstring = malloc (argstring_length * sizeof (char)); + p = malloc (argstring_length * sizeof (char)); if (p == NULL) { fprintf (stderr, _("Memory allocation problem\n")); @@ -1062,6 +1062,7 @@ main (int argc, char **argv) *p++ = ' '; } *p = '\0'; + program_argstring = p; /* Load the hard-coded defaults. */ defaults (); diff --git a/src/test.c b/src/test.c index e19673ec..0a566607 100644 --- a/src/test.c +++ b/src/test.c @@ -51,7 +51,7 @@ const char *test_append_uri_pathel(void); const char *test_are_urls_equal(void); const char *test_is_robots_txt_url(void); -char *program_argstring = "TEST"; +const char *program_argstring = "TEST"; int tests_run; @@ -71,10 +71,10 @@ all_tests(void) return NULL; } -char *program_name; /* Needed by lib/error.c. */ +const char *program_name; /* Needed by lib/error.c. */ int -main (int argc _GL_UNUSED, char *argv[]) +main (int argc _GL_UNUSED, const char *argv[]) { const char *result; diff --git a/src/wget.h b/src/wget.h index 2b86557a..2823bb8c 100644 --- a/src/wget.h +++ b/src/wget.h @@ -313,8 +313,8 @@ typedef double SUM_SIZE_INT; #define MAX_INT_TO_STRING_LEN(x) ((sizeof(x) * 24082 / 10000) + 2) extern const char *exec_name; -extern char *program_name; -extern char *program_argstring; +extern const char *program_name; +extern const char *program_argstring; /* Document type ("dt") flags */ enum