Mercurial > hg > octave-lojdl
changeset 1121:46619c5ca048
[project @ 1995-02-17 15:45:07 by jwe]
author | jwe |
---|---|
date | Fri, 17 Feb 1995 15:45:26 +0000 |
parents | 3508c2ef142c |
children | 22f8e6d62e54 |
files | src/user-prefs.cc src/variables.cc src/variables.h |
diffstat | 3 files changed, 35 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/src/user-prefs.cc +++ b/src/user-prefs.cc @@ -704,7 +704,7 @@ if (s) { delete [] user_pref.loadpath; - user_pref.loadpath = s; + user_pref.loadpath = maybe_add_default_load_path (s); } else {
--- a/src/variables.cc +++ b/src/variables.cc @@ -378,6 +378,33 @@ return pager_binary; } +// Always returns a new string. + +char * +maybe_add_default_load_path (const char *p) +{ + static char *std_path = subst_octave_home (OCTAVE_FCNFILEPATH); + + char *pathstring = strsave (p); + + if (pathstring[0] == SEPCHAR) + { + char *tmp = pathstring; + pathstring = strconcat (std_path, pathstring); + delete [] tmp; + } + + int tmp_len = strlen (pathstring); + if (pathstring[tmp_len-1] == SEPCHAR) + { + char *tmp = pathstring; + pathstring = strconcat (pathstring, std_path); + delete [] tmp; + } + + return pathstring; +} + char * octave_lib_dir (void) { @@ -396,36 +423,14 @@ char * default_path (void) { + static char *std_path = subst_octave_home (OCTAVE_FCNFILEPATH); + + static char *oct_path = getenv ("OCTAVE_PATH"); + static char *pathstring = 0; delete [] pathstring; - static char *std_path = subst_octave_home (OCTAVE_FCNFILEPATH); - - char *oct_path = getenv ("OCTAVE_PATH"); - - if (oct_path) - { - pathstring = strsave (oct_path); - - if (pathstring[0] == SEPCHAR) - { - char *tmp = pathstring; - pathstring = strconcat (std_path, pathstring); - delete [] tmp; - } - - int tmp_len = strlen (pathstring); - if (pathstring[tmp_len-1] == SEPCHAR) - { - char *tmp = pathstring; - pathstring = strconcat (pathstring, std_path); - delete [] tmp; - } - } - else - pathstring = strsave (std_path); - - return pathstring; + return oct_path ? strsave (oct_path) : strsave (std_path); } char *