summaryrefslogtreecommitdiff
path: root/lib/javacomp.c
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2020-12-12 04:18:54 +0100
committerBruno Haible <bruno@clisp.org>2020-12-12 04:18:54 +0100
commitc893594d0c33139efbc8d75e43eaed487116b58b (patch)
tree6e8f5d55f44b65d6e9567822b5da2cbf24351fbf /lib/javacomp.c
parent46c7e327c76f115bbdc6eee75fffa382559aa9d8 (diff)
downloadgnulib-c893594d0c33139efbc8d75e43eaed487116b58b.tar.gz
sh-quote, execute, spawn-pipe, etc.: Make better use of 'const'.
* lib/sh-quote.h (shell_quote_argv): Does not need write access to the elements of argv. * lib/sh-quote.c (shell_quote_argv): Likewise. * lib/windows-spawn.h (prepare_spawn): Add 'const' the argument type and the return type. * lib/windows-spawn.c (prepare_spawn): Likewise. * lib/os2-spawn.h (prepare_spawn): Likewise. * lib/os2-spawn.c (prepare_spawn): Likewise. * lib/execute.h (execute): Does not need write access to the elements of prog_argv. * lib/execute.c (execute): Likewise. * lib/spawn-pipe.h (create_pipe_out, create_pipe_in, create_pipe_bidi): Likewise. * lib/spawn-pipe.c (create_pipe, create_pipe_bidi, create_pipe_in, create_pipe_out): Likewise. * lib/pipe-filter.h (pipe_filter_ii_execute, pipe_filter_gi_create): Likewise. * lib/pipe-filter-ii.c (pipe_filter_ii_execute): Likewise. * lib/pipe-filter-gi.c (pipe_filter_gi_create): Likewise. * lib/javaexec.h (execute_fn): Does not need write access to the elements of prog_argv. * lib/javaexec.c (execute_java_class): Update variable types and remove casts to 'char *'. * lib/csharpexec.h (execute_fn): Does not need write access to the elements of prog_argv. * lib/csharpexec.c (execute_csharp_using_mono, execute_csharp_using_sscli): Update variable types and remove casts to 'char *'. * lib/javacomp.c (compile_using_envjavac, compile_using_gcj, compile_using_javac, compile_using_jikes, is_envjavac_gcj, is_envjavac_gcj43, is_gcj_present, is_gcj_43, is_javac_present, is_jikes_present): Update variable types and remove casts to 'char *'. * lib/javaversion.c (execute_and_read_line): Does not need write access to the elements of prog_argv. * lib/csharpcomp.c (compile_csharp_using_mono, compile_csharp_using_sscli): Update variable types and remove casts to 'char *'. * tests/test-sh-quote.c (main): Update variable types and remove casts to 'char *'. * tests/test-execute-main.c (main): Update variable types and remove casts to 'char *'. * tests/test-spawn-pipe-main.c (test_pipe): Update variable types and remove casts to 'char *'. * NEWS: Mention the changes.
Diffstat (limited to 'lib/javacomp.c')
-rw-r--r--lib/javacomp.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/lib/javacomp.c b/lib/javacomp.c
index c24bb69166..ca7a6fe658 100644
--- a/lib/javacomp.c
+++ b/lib/javacomp.c
@@ -288,7 +288,7 @@ compile_using_envjavac (const char *javac,
bool err;
unsigned int command_length;
char *command;
- char *argv[4];
+ const char *argv[4];
int exitstatus;
unsigned int i;
char *p;
@@ -367,8 +367,8 @@ compile_using_gcj (const char * const *java_sources,
{
bool err;
unsigned int argc;
- char **argv;
- char **argp;
+ const char **argv;
+ const char **argp;
char *fsource_arg;
char *ftarget_arg;
int exitstatus;
@@ -378,7 +378,7 @@ compile_using_gcj (const char * const *java_sources,
2 + (no_assert_option ? 1 : 0) + (fsource_option ? 1 : 0)
+ (ftarget_option ? 1 : 0) + (optimize ? 1 : 0) + (debug ? 1 : 0)
+ (directory != NULL ? 2 : 0) + java_sources_count;
- argv = (char **) xmalloca ((argc + 1) * sizeof (char *));
+ argv = (const char **) xmalloca ((argc + 1) * sizeof (const char *));
argp = argv;
*argp++ = "gcj";
@@ -410,10 +410,10 @@ compile_using_gcj (const char * const *java_sources,
if (directory != NULL)
{
*argp++ = "-d";
- *argp++ = (char *) directory;
+ *argp++ = directory;
}
for (i = 0; i < java_sources_count; i++)
- *argp++ = (char *) java_sources[i];
+ *argp++ = java_sources[i];
*argp = NULL;
/* Ensure argv length was correctly calculated. */
if (argp - argv != argc)
@@ -453,27 +453,27 @@ compile_using_javac (const char * const *java_sources,
{
bool err;
unsigned int argc;
- char **argv;
- char **argp;
+ const char **argv;
+ const char **argp;
int exitstatus;
unsigned int i;
argc =
1 + (source_option ? 2 : 0) + (target_option ? 2 : 0) + (optimize ? 1 : 0)
+ (debug ? 1 : 0) + (directory != NULL ? 2 : 0) + java_sources_count;
- argv = (char **) xmalloca ((argc + 1) * sizeof (char *));
+ argv = (const char **) xmalloca ((argc + 1) * sizeof (const char *));
argp = argv;
*argp++ = "javac";
if (source_option)
{
*argp++ = "-source";
- *argp++ = (char *) source_version;
+ *argp++ = source_version;
}
if (target_option)
{
*argp++ = "-target";
- *argp++ = (char *) target_version;
+ *argp++ = target_version;
}
if (optimize)
*argp++ = "-O";
@@ -482,10 +482,10 @@ compile_using_javac (const char * const *java_sources,
if (directory != NULL)
{
*argp++ = "-d";
- *argp++ = (char *) directory;
+ *argp++ = directory;
}
for (i = 0; i < java_sources_count; i++)
- *argp++ = (char *) java_sources[i];
+ *argp++ = java_sources[i];
*argp = NULL;
/* Ensure argv length was correctly calculated. */
if (argp - argv != argc)
@@ -519,15 +519,15 @@ compile_using_jikes (const char * const *java_sources,
{
bool err;
unsigned int argc;
- char **argv;
- char **argp;
+ const char **argv;
+ const char **argp;
int exitstatus;
unsigned int i;
argc =
1 + (optimize ? 1 : 0) + (debug ? 1 : 0) + (directory != NULL ? 2 : 0)
+ java_sources_count;
- argv = (char **) xmalloca ((argc + 1) * sizeof (char *));
+ argv = (const char **) xmalloca ((argc + 1) * sizeof (const char *));
argp = argv;
*argp++ = "jikes";
@@ -538,10 +538,10 @@ compile_using_jikes (const char * const *java_sources,
if (directory != NULL)
{
*argp++ = "-d";
- *argp++ = (char *) directory;
+ *argp++ = directory;
}
for (i = 0; i < java_sources_count; i++)
- *argp++ = (char *) java_sources[i];
+ *argp++ = java_sources[i];
*argp = NULL;
/* Ensure argv length was correctly calculated. */
if (argp - argv != argc)
@@ -635,7 +635,7 @@ is_envjavac_gcj (const char *javac)
"$JAVAC --version 2>/dev/null | sed -e 1q | grep gcj > /dev/null" */
unsigned int command_length;
char *command;
- char *argv[4];
+ const char *argv[4];
pid_t child;
int fd[1];
FILE *fp;
@@ -717,7 +717,7 @@ is_envjavac_gcj43 (const char *javac)
| sed -e '/^4\.[012]/d' | grep '^[4-9]' >/dev/null" */
unsigned int command_length;
char *command;
- char *argv[4];
+ const char *argv[4];
pid_t child;
int fd[1];
FILE *fp;
@@ -1406,7 +1406,7 @@ is_gcj_present (void)
"gcj --version 2> /dev/null | \
sed -e 's,^[^0-9]*,,' -e 1q | \
sed -e '/^3\.[01]/d' | grep '^[3-9]' > /dev/null" */
- char *argv[3];
+ const char *argv[3];
pid_t child;
int fd[1];
int exitstatus;
@@ -1522,7 +1522,7 @@ is_gcj_43 (void)
"gcj --version 2> /dev/null | \
sed -e 's,^[^0-9]*,,' -e 1q | \
sed -e '/^4\.[012]/d' | grep '^[4-9]'" */
- char *argv[3];
+ const char *argv[3];
pid_t child;
int fd[1];
int exitstatus;
@@ -1871,7 +1871,7 @@ is_javac_present (void)
if (!javac_tested)
{
/* Test for presence of javac: "javac 2> /dev/null ; test $? -le 2" */
- char *argv[2];
+ const char *argv[2];
int exitstatus;
argv[0] = "javac";
@@ -2138,7 +2138,7 @@ is_jikes_present (void)
if (!jikes_tested)
{
/* Test for presence of jikes: "jikes 2> /dev/null ; test $? = 1" */
- char *argv[2];
+ const char *argv[2];
int exitstatus;
argv[0] = "jikes";