From bug-octave-request at bevo dot che dot wisc dot edu Fri Oct 23 14:42:55 1998 Subject: Re: [patch] extra colon feature + problem with default loadpath From: "John W. Eaton" To: Rafael Laboissiere Cc: bug-octave at bevo dot che dot wisc dot edu Date: Fri, 23 Oct 1998 14:42:23 -0500 (CDT) On 23-Oct-1998, Rafael Laboissiere wrote: | Thanks for your reply. I understand that my patch introduces many | undesirable modifications in the octave source. In an afterthought, I | find that some of the modifications are really inappropriate | (like introducing Vload_path_default in liboctave). | | However, some features that I introduced (LOADPATH starting up with ":", | hiding the default path, as well as the expansion of doubled colon, but | for sure not that infamous misunderstanding about OCTAVE_PATH) should be | considered for next releases. OK, the code for setting LOADPATH, either from the environment, using the -p option when invoking Octave, or at the command line is clearly not right yet, as I see from the differences in the following: export OCTAVE_PATH="foobar:"; octave --> sets LOADPATH = foobar:.:/usr/local/... and Vload_path to the same value (after the patch in my previous message anyway). octave -p foobar: --> sets LOADPATH = foobar:, but with Vload_path set to include the default path. The more I think about it, I think this is correct -- Vload_path needs to be expanded, but LOADPATH should keep the value the user specified, just as you said in your original message. I now see that file_in_path *does* call maybe_add_default_path on the PATH arg. Duh. octave > LOADPATH = "foobar:" --> sets LOADPATH = foobar:, but with Vload_path set to include the default path, just as for the case of using the `-p PATH' option. So, I think the only problem is with the first case. How about the following patch (to be applied after my previous attempts)? Does it solve the problems? Thanks, jwe Fri Oct 23 12:07:32 1998 John W. Eaton * defaults.cc (Vdefault_load_path): New static variable. (set_default_path): Set it. (maybe_add_default_load_path): Use it. (symbols_of_defaults): Add DEFCONST for DEFAULT_LOADPATH. Thanks to Rafael Laboissiere . *** src/defaults.cc~ Fri Oct 23 12:19:09 1998 --- src/defaults.cc Fri Oct 23 14:33:51 1998 *************** *** 77,82 **** --- 77,85 ---- // (--path path; -p path) string Vload_path; + // The default load path with OCTAVE_HOME appropriately substituted. + static string Vdefault_load_path; + // And the cached directory path corresponding to Vload_path. dir_path Vload_path_dir_path; *************** *** 188,198 **** static void set_default_path (void) { ! string std_path = subst_octave_home (OCTAVE_FCNFILEPATH); char *oct_path = getenv ("OCTAVE_PATH"); ! Vload_path = oct_path ? maybe_add_default_load_path (oct_path) : std_path; Vload_path_dir_path = dir_path (Vload_path); } --- 191,202 ---- static void set_default_path (void) { ! Vdefault_load_path = subst_octave_home (OCTAVE_FCNFILEPATH); char *oct_path = getenv ("OCTAVE_PATH"); ! Vload_path ! = oct_path ? maybe_add_default_load_path (oct_path) : Vdefault_load_path; Vload_path_dir_path = dir_path (Vload_path); } *************** *** 246,267 **** string maybe_add_default_load_path (const string& pathstring) { - string std_path = subst_octave_home (OCTAVE_FCNFILEPATH); - string retval; if (! pathstring.empty ()) { if (pathstring[0] == SEPCHAR) { ! retval = std_path; retval.append (pathstring); } else retval = pathstring; if (pathstring[pathstring.length () - 1] == SEPCHAR) ! retval.append (std_path); size_t pos = 0; do --- 250,269 ---- string maybe_add_default_load_path (const string& pathstring) { string retval; if (! pathstring.empty ()) { if (pathstring[0] == SEPCHAR) { ! retval = Vdefault_load_path; retval.append (pathstring); } else retval = pathstring; if (pathstring[pathstring.length () - 1] == SEPCHAR) ! retval.append (Vdefault_load_path); size_t pos = 0; do *************** *** 269,275 **** pos = retval.find ("::"); if (pos != NPOS) ! retval.insert (pos+1, std_path); } while (pos != NPOS); } --- 271,277 ---- pos = retval.find ("::"); if (pos != NPOS) ! retval.insert (pos+1, Vdefault_load_path); } while (pos != NPOS); } *************** *** 457,464 **** DEFVAR (EXEC_PATH, Vexec_path, 0, exec_path, "colon separated list of directories to search for programs to run"); ! DEFVAR (LOADPATH, Vload_path, 0, octave_loadpath, ! "colon separated list of directories to search for scripts"); DEFVAR (IMAGEPATH, OCTAVE_IMAGEPATH, 0, imagepath, "colon separated list of directories to search for image files"); --- 459,472 ---- DEFVAR (EXEC_PATH, Vexec_path, 0, exec_path, "colon separated list of directories to search for programs to run"); ! DEFVAR (LOADPATH, ":", 0, octave_loadpath, ! "colon separated list of directories to search for scripts.\n\ ! The default value is \":\", which means to search the default list\n\ ! of directories, which may be found in the built-in constant\n\ ! DEFAULT_LOADPATH"); ! ! DEFCONST (DEFAULT_LOADPATH, Vdefault_load_path, ! "the default colon separated list of directories to search for scripts"); DEFVAR (IMAGEPATH, OCTAVE_IMAGEPATH, 0, imagepath, "colon separated list of directories to search for image files");