Mercurial > octave-nkf
changeset 20457:4262598620ae
Don't add duplicates to javaclasspath when run in home directory (bug #45683).
* ov-java.cc (initial_class_path): Get current working directory (cwd) and home
directory (home_dir). Don't read in javaclasspath.txt from home directory or
java install directory if either of these is the same as cwd.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 03 Aug 2015 15:24:32 -0700 |
parents | 6dc15d4cc17e |
children | 58b02a8d0fe9 |
files | libinterp/octave-value/ov-java.cc |
diffstat | 1 files changed, 22 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/octave-value/ov-java.cc Mon Aug 03 07:43:28 2015 -0700 +++ b/libinterp/octave-value/ov-java.cc Mon Aug 03 15:24:32 2015 -0700 @@ -350,6 +350,9 @@ // 2) User's home directory // 3) Octave installation directory where octave.jar resides + std::string cwd = octave_env::get_current_directory (); + std::string home_dir = octave_env::get_home_directory (); + // The filename is "javaclasspath.txt", but historically // has been "classpath.txt" so both are supported. std::string cp_list[] = {"javaclasspath.txt", "classpath.txt"}; @@ -372,25 +375,31 @@ // Try to find classpath file in the user's home directory. - cp_file = "~" + sep + filename; - cp_file = file_ops::tilde_expand (cp_file); - cp_exists = file_stat (cp_file); - if (cp_exists) + if (cwd != home_dir) { - // File found. Add its contents to the static classpath. - std::string classpath = read_classpath_txt (cp_file); - retval.append (classpath); + cp_file = "~" + sep + filename; + cp_file = file_ops::tilde_expand (cp_file); + cp_exists = file_stat (cp_file); + if (cp_exists) + { + // File found. Add its contents to the static classpath. + std::string classpath = read_classpath_txt (cp_file); + retval.append (classpath); + } } // Try to find classpath file in the Octave install directory. - cp_file = java_dir + sep + filename; - cp_exists = file_stat (cp_file); - if (cp_exists) + if (cwd != java_dir) { - // File found. Add its contents to the static classpath. - std::string classpath = read_classpath_txt (cp_file); - retval.append (classpath); + cp_file = java_dir + sep + filename; + cp_exists = file_stat (cp_file); + if (cp_exists) + { + // File found. Add its contents to the static classpath. + std::string classpath = read_classpath_txt (cp_file); + retval.append (classpath); + } } } }