comparison src/defaults.cc @ 3192:bdf2186d4592

[project @ 1998-10-23 19:47:59 by jwe]
author jwe
date Fri, 23 Oct 1998 19:48:01 +0000
parents 9580887dd160
children 7a5a5da64756
comparison
equal deleted inserted replaced
3191:e4f4b2d26ee9 3192:bdf2186d4592
68 68
69 // Load path specified on command line. 69 // Load path specified on command line.
70 // (--path path; -p path) 70 // (--path path; -p path)
71 string Vload_path; 71 string Vload_path;
72 72
73 // The default load path with OCTAVE_HOME appropriately substituted.
74 static string Vdefault_load_path;
75
73 // And the cached directory path corresponding to Vload_path. 76 // And the cached directory path corresponding to Vload_path.
74 dir_path Vload_path_dir_path; 77 dir_path Vload_path_dir_path;
75 78
76 // Name of the editor to be invoked by the edit_history command. 79 // Name of the editor to be invoked by the edit_history command.
77 string Veditor; 80 string Veditor;
179 // `:', do both (which is useless, but the luser asked for it...). 182 // `:', do both (which is useless, but the luser asked for it...).
180 183
181 static void 184 static void
182 set_default_path (void) 185 set_default_path (void)
183 { 186 {
184 string std_path = subst_octave_home (OCTAVE_FCNFILEPATH); 187 Vdefault_load_path = subst_octave_home (OCTAVE_FCNFILEPATH);
185 188
186 string oct_path = octave_env::getenv ("OCTAVE_PATH"); 189 string oct_path = octave_env::getenv ("OCTAVE_PATH");
187 190
188 Vload_path = oct_path.empty () ? std_path : oct_path; 191 Vload_path = oct_path.empty ()
192 ? Vdefault_load_path : maybe_add_default_path (oct_path);
189 193
190 Vload_path_dir_path = dir_path (Vload_path); 194 Vload_path_dir_path = dir_path (Vload_path);
191 } 195 }
192 196
193 static void 197 static void
237 } 241 }
238 242
239 string 243 string
240 maybe_add_default_load_path (const string& pathstring) 244 maybe_add_default_load_path (const string& pathstring)
241 { 245 {
242 string std_path = subst_octave_home (OCTAVE_FCNFILEPATH);
243
244 string retval; 246 string retval;
245 247
246 if (! pathstring.empty ()) 248 if (! pathstring.empty ())
247 { 249 {
248 if (pathstring[0] == SEPCHAR) 250 if (pathstring[0] == SEPCHAR)
249 { 251 {
250 retval = std_path; 252 retval = Vdefault_load_path;
251 retval.append (pathstring); 253 retval.append (pathstring);
252 } 254 }
253 else 255 else
254 retval = pathstring; 256 retval = pathstring;
255 257
256 if (pathstring[pathstring.length () - 1] == SEPCHAR) 258 if (pathstring[pathstring.length () - 1] == SEPCHAR)
257 retval.append (std_path); 259 retval.append (Vdefault_load_path);
260
261 size_t pos = 0;
262 do
263 {
264 pos = retval.find ("::");
265
266 if (pos != NPOS)
267 retval.insert (pos+1, Vdefault_load_path);
268 }
269 while (pos != NPOS);
258 } 270 }
259 271
260 return retval; 272 return retval;
261 } 273 }
262 274
413 "name of the editor to be invoked by the edit_history command"); 425 "name of the editor to be invoked by the edit_history command");
414 426
415 DEFVAR (EXEC_PATH, Vexec_path, 0, exec_path, 427 DEFVAR (EXEC_PATH, Vexec_path, 0, exec_path,
416 "colon separated list of directories to search for programs to run"); 428 "colon separated list of directories to search for programs to run");
417 429
418 DEFVAR (LOADPATH, Vload_path, 0, loadpath, 430 DEFVAR (LOADPATH, ":", 0, octave_loadpath,
419 "colon separated list of directories to search for scripts"); 431 "colon separated list of directories to search for scripts.\n\
420 432 The default value is \":\", which means to search the default list\n\
433 of directories. The default list of directories may be found in\n\
434 the built-in constant DEFAULT_LOADPATH");
435
436 DEFCONST (DEFAULT_LOADPATH, Vdefault_load_path,
437 "the default colon separated list of directories to search for scripts");
438
421 DEFVAR (IMAGEPATH, OCTAVE_IMAGEPATH, 0, imagepath, 439 DEFVAR (IMAGEPATH, OCTAVE_IMAGEPATH, 0, imagepath,
422 "colon separated list of directories to search for image files"); 440 "colon separated list of directories to search for image files");
423 441
424 DEFCONST (OCTAVE_HOME, Voctave_home, 442 DEFCONST (OCTAVE_HOME, Voctave_home,
425 "top-level Octave installation directory"); 443 "top-level Octave installation directory");