Mercurial > hg > octave-lyh
annotate src/defaults.cc @ 14429:eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
* data.cc, defaults.cc, dirfns.cc, file-io.cc, graphics.cc, mappers.cc,
oct-map.cc, octave.cc, ov-base.cc, ov-bool-mat.cc, ov-cell.cc,
ov-fcn-handle.cc, ov-fcn-inline.cc, ov-flt-re-mat.cc, ov-int16.cc, ov-int32.cc,
ov-int64.cc, ov-int8.cc, ov-null-mat.cc, ov-oncleanup.cc, ov-range.cc,
ov-re-mat.cc, ov-struct.cc, ov-typeinfo.cc, ov-uint16.cc, ov-uint32.cc,
ov-uint64.cc, ov-uint8.cc, ov.cc, pr-output.cc, pt-binop.cc, pt-eval.cc,
pt-idx.cc, pt-mat.cc, sighandlers.cc, strfns.cc, symtab.cc, syscalls.cc,
sysdep.cc, toplev.cc, utils.cc, variables.cc: Update %!tests in src/ directory
with Octave coding conventions.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Sun, 04 Mar 2012 12:21:10 -0800 |
parents | 72c96de7a403 |
children | 4e9dc46d4125 |
rev | line source |
---|---|
2203 | 1 /* |
2 | |
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
13951
diff
changeset
|
3 Copyright (C) 1996-2012 John W. Eaton |
2203 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
2203 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
2203 | 20 |
21 */ | |
22 | |
23 #ifdef HAVE_CONFIG_H | |
24 #include <config.h> | |
25 #endif | |
26 | |
27 #include <cstdlib> | |
28 | |
6114 | 29 #include <algorithm> |
3503 | 30 #include <iostream> |
2203 | 31 #include <string> |
32 | |
33 #include <sys/types.h> | |
34 #include <unistd.h> | |
35 | |
5814 | 36 #include "dir-ops.h" |
2926 | 37 #include "oct-env.h" |
4217 | 38 #include "file-stat.h" |
3174 | 39 #include "pathsearch.h" |
4217 | 40 #include "str-vec.h" |
2926 | 41 |
2492 | 42 #include <defaults.h> |
2203 | 43 #include "defun.h" |
44 #include "error.h" | |
3040 | 45 #include "file-ops.h" |
2203 | 46 #include "gripes.h" |
47 #include "help.h" | |
5395 | 48 #include "input.h" |
5832 | 49 #include "load-path.h" |
3185 | 50 #include "oct-obj.h" |
2390 | 51 #include "ov.h" |
4217 | 52 #include "parse.h" |
2203 | 53 #include "toplev.h" |
4217 | 54 #include "unwind-prot.h" |
2203 | 55 #include "variables.h" |
2492 | 56 #include <version.h> |
2203 | 57 |
3523 | 58 std::string Voctave_home; |
2203 | 59 |
3523 | 60 std::string Vbin_dir; |
61 std::string Vinfo_dir; | |
62 std::string Vdata_dir; | |
63 std::string Vlibexec_dir; | |
64 std::string Varch_lib_dir; | |
65 std::string Vlocal_arch_lib_dir; | |
5909 | 66 std::string Vlocal_api_arch_lib_dir; |
3597 | 67 std::string Vlocal_ver_arch_lib_dir; |
5814 | 68 |
69 std::string Vlocal_ver_oct_file_dir; | |
70 std::string Vlocal_api_oct_file_dir; | |
71 std::string Vlocal_oct_file_dir; | |
2203 | 72 |
5814 | 73 std::string Vlocal_ver_fcn_file_dir; |
74 std::string Vlocal_api_fcn_file_dir; | |
75 std::string Vlocal_fcn_file_dir; | |
76 | |
77 std::string Voct_file_dir; | |
78 std::string Vfcn_file_dir; | |
79 | |
80 std::string Vimage_dir; | |
4447 | 81 |
2203 | 82 // The path that will be searched for programs that we execute. |
83 // (--exec-path path) | |
5794 | 84 static std::string VEXEC_PATH; |
2203 | 85 |
86 // Name of the editor to be invoked by the edit_history command. | |
5794 | 87 std::string VEDITOR; |
2203 | 88 |
5814 | 89 static std::string VIMAGE_PATH; |
2203 | 90 |
3523 | 91 std::string Vlocal_site_defaults_file; |
92 std::string Vsite_defaults_file; | |
2203 | 93 |
6274 | 94 std::string |
3523 | 95 subst_octave_home (const std::string& s) |
2203 | 96 { |
3523 | 97 std::string retval; |
2203 | 98 |
3523 | 99 std::string prefix = OCTAVE_PREFIX; |
2203 | 100 |
101 retval = s; | |
102 | |
103 if (Voctave_home != prefix) | |
104 { | |
5275 | 105 octave_idx_type len = prefix.length (); |
6276 | 106 |
107 if (s.substr (0, len) == prefix) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
108 retval.replace (0, len, Voctave_home); |
2203 | 109 } |
110 | |
8007
a2ab20ba78f7
make file_ops a proper singleton class
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
111 if (file_ops::dir_sep_char () != '/') |
a2ab20ba78f7
make file_ops a proper singleton class
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
112 std::replace (retval.begin (), retval.end (), '/', |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
113 file_ops::dir_sep_char ()); |
6114 | 114 |
2203 | 115 return retval; |
116 } | |
117 | |
118 static void | |
119 set_octave_home (void) | |
120 { | |
3523 | 121 std::string oh = octave_env::getenv ("OCTAVE_HOME"); |
2203 | 122 |
3523 | 123 Voctave_home = oh.empty () ? std::string (OCTAVE_PREFIX) : oh; |
2203 | 124 } |
125 | |
126 static void | |
127 set_default_info_dir (void) | |
128 { | |
129 Vinfo_dir = subst_octave_home (OCTAVE_INFODIR); | |
130 } | |
131 | |
132 static void | |
3141 | 133 set_default_data_dir (void) |
134 { | |
135 Vdata_dir = subst_octave_home (OCTAVE_DATADIR); | |
136 } | |
137 | |
138 static void | |
139 set_default_libexec_dir (void) | |
140 { | |
141 Vlibexec_dir = subst_octave_home (OCTAVE_LIBEXECDIR); | |
142 } | |
143 | |
144 static void | |
2203 | 145 set_default_arch_lib_dir (void) |
146 { | |
147 Varch_lib_dir = subst_octave_home (OCTAVE_ARCHLIBDIR); | |
148 } | |
149 | |
150 static void | |
2439 | 151 set_default_local_arch_lib_dir (void) |
152 { | |
153 Vlocal_arch_lib_dir = subst_octave_home (OCTAVE_LOCALARCHLIBDIR); | |
154 } | |
155 | |
156 static void | |
5909 | 157 set_default_local_api_arch_lib_dir (void) |
158 { | |
159 Vlocal_api_arch_lib_dir = subst_octave_home (OCTAVE_LOCALAPIARCHLIBDIR); | |
160 } | |
161 | |
162 static void | |
3597 | 163 set_default_local_ver_arch_lib_dir (void) |
164 { | |
165 Vlocal_ver_arch_lib_dir = subst_octave_home (OCTAVE_LOCALVERARCHLIBDIR); | |
166 } | |
167 | |
168 static void | |
5814 | 169 set_default_local_ver_oct_file_dir (void) |
170 { | |
171 Vlocal_ver_oct_file_dir = subst_octave_home (OCTAVE_LOCALVEROCTFILEDIR); | |
172 } | |
173 | |
174 static void | |
175 set_default_local_api_oct_file_dir (void) | |
176 { | |
177 Vlocal_api_oct_file_dir = subst_octave_home (OCTAVE_LOCALAPIOCTFILEDIR); | |
178 } | |
179 | |
180 static void | |
181 set_default_local_oct_file_dir (void) | |
182 { | |
183 Vlocal_oct_file_dir = subst_octave_home (OCTAVE_LOCALOCTFILEDIR); | |
184 } | |
185 | |
186 static void | |
187 set_default_local_ver_fcn_file_dir (void) | |
188 { | |
189 Vlocal_ver_fcn_file_dir = subst_octave_home (OCTAVE_LOCALVERFCNFILEDIR); | |
190 } | |
191 | |
192 static void | |
193 set_default_local_api_fcn_file_dir (void) | |
194 { | |
195 Vlocal_api_fcn_file_dir = subst_octave_home (OCTAVE_LOCALAPIFCNFILEDIR); | |
196 } | |
197 | |
198 static void | |
199 set_default_local_fcn_file_dir (void) | |
200 { | |
201 Vlocal_fcn_file_dir = subst_octave_home (OCTAVE_LOCALFCNFILEDIR); | |
202 } | |
203 | |
204 static void | |
2203 | 205 set_default_fcn_file_dir (void) |
206 { | |
207 Vfcn_file_dir = subst_octave_home (OCTAVE_FCNFILEDIR); | |
208 } | |
209 | |
210 static void | |
5814 | 211 set_default_image_dir (void) |
212 { | |
213 Vimage_dir = subst_octave_home (OCTAVE_IMAGEDIR); | |
214 } | |
215 | |
216 static void | |
5397 | 217 set_default_oct_file_dir (void) |
218 { | |
219 Voct_file_dir = subst_octave_home (OCTAVE_OCTFILEDIR); | |
220 } | |
221 | |
222 static void | |
2203 | 223 set_default_bin_dir (void) |
224 { | |
225 Vbin_dir = subst_octave_home (OCTAVE_BINDIR); | |
226 } | |
227 | |
5814 | 228 void |
11294
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
229 set_exec_path (const std::string& path_arg) |
4447 | 230 { |
11294
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
231 std::string tpath = path_arg; |
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
232 |
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
233 if (tpath.empty ()) |
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
234 tpath = octave_env::getenv ("OCTAVE_EXEC_PATH"); |
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
235 |
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
236 if (tpath.empty ()) |
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
237 tpath = Vlocal_ver_arch_lib_dir + dir_path::path_sep_str () |
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
238 + Vlocal_api_arch_lib_dir + dir_path::path_sep_str () |
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
239 + Vlocal_arch_lib_dir + dir_path::path_sep_str () |
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
240 + Varch_lib_dir + dir_path::path_sep_str () |
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
241 + Vbin_dir; |
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
242 |
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
243 VEXEC_PATH = tpath; |
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
244 |
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
245 // FIXME -- should we really be modifying PATH in the environment? |
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
246 // The way things are now, Octave will ignore directories set in the |
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
247 // PATH with calls like |
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
248 // |
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
249 // setenv ("PATH", "/my/path"); |
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
250 // |
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
251 // To fix this, I think Octave should be searching the combination of |
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
252 // PATH and EXEC_PATH for programs that it executes instead of setting |
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
253 // the PATH in the environment and relying on the shell to do the |
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
254 // searching. |
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
255 |
5814 | 256 // This is static so that even if set_exec_path is called more than |
257 // once, shell_path is the original PATH from the environment, | |
258 // before we start modifying it. | |
259 static std::string shell_path = octave_env::getenv ("PATH"); | |
260 | |
261 if (! shell_path.empty ()) | |
11294
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
262 tpath = shell_path + dir_path::path_sep_str () + tpath; |
5814 | 263 |
11294
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
264 octave_env::putenv ("PATH", tpath); |
5814 | 265 } |
266 | |
267 void | |
268 set_image_path (const std::string& path) | |
269 { | |
270 VIMAGE_PATH = "."; | |
271 | |
272 std::string tpath = path; | |
273 | |
274 if (tpath.empty ()) | |
275 tpath = octave_env::getenv ("OCTAVE_IMAGE_PATH"); | |
276 | |
277 if (! tpath.empty ()) | |
8008
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
8007
diff
changeset
|
278 VIMAGE_PATH += dir_path::path_sep_str () + tpath; |
5814 | 279 |
5832 | 280 tpath = genpath (Vimage_dir, ""); |
281 | |
282 if (! tpath.empty ()) | |
8008
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
8007
diff
changeset
|
283 VIMAGE_PATH += dir_path::path_sep_str () + tpath; |
5814 | 284 } |
285 | |
2203 | 286 static void |
8865
eace5649a8b5
set default value for doc_cache_file variable
John W. Eaton <jwe@octave.org>
parents:
8008
diff
changeset
|
287 set_default_doc_cache_file (void) |
eace5649a8b5
set default value for doc_cache_file variable
John W. Eaton <jwe@octave.org>
parents:
8008
diff
changeset
|
288 { |
eace5649a8b5
set default value for doc_cache_file variable
John W. Eaton <jwe@octave.org>
parents:
8008
diff
changeset
|
289 std::string def_file = subst_octave_home (OCTAVE_DOC_CACHE_FILE); |
eace5649a8b5
set default value for doc_cache_file variable
John W. Eaton <jwe@octave.org>
parents:
8008
diff
changeset
|
290 |
eace5649a8b5
set default value for doc_cache_file variable
John W. Eaton <jwe@octave.org>
parents:
8008
diff
changeset
|
291 std::string env_file = octave_env::getenv ("OCTAVE_DOC_CACHE_FILE"); |
eace5649a8b5
set default value for doc_cache_file variable
John W. Eaton <jwe@octave.org>
parents:
8008
diff
changeset
|
292 |
eace5649a8b5
set default value for doc_cache_file variable
John W. Eaton <jwe@octave.org>
parents:
8008
diff
changeset
|
293 Vdoc_cache_file = env_file.empty () ? def_file : env_file; |
eace5649a8b5
set default value for doc_cache_file variable
John W. Eaton <jwe@octave.org>
parents:
8008
diff
changeset
|
294 } |
eace5649a8b5
set default value for doc_cache_file variable
John W. Eaton <jwe@octave.org>
parents:
8008
diff
changeset
|
295 |
eace5649a8b5
set default value for doc_cache_file variable
John W. Eaton <jwe@octave.org>
parents:
8008
diff
changeset
|
296 static void |
2203 | 297 set_default_info_file (void) |
298 { | |
3523 | 299 std::string std_info_file = subst_octave_home (OCTAVE_INFOFILE); |
2512 | 300 |
3523 | 301 std::string oct_info_file = octave_env::getenv ("OCTAVE_INFO_FILE"); |
2203 | 302 |
2926 | 303 Vinfo_file = oct_info_file.empty () ? std_info_file : oct_info_file; |
2203 | 304 } |
305 | |
306 static void | |
307 set_default_info_prog (void) | |
308 { | |
3523 | 309 std::string oct_info_prog = octave_env::getenv ("OCTAVE_INFO_PROGRAM"); |
2203 | 310 |
2926 | 311 if (oct_info_prog.empty ()) |
5794 | 312 Vinfo_program = "info"; |
2926 | 313 else |
5794 | 314 Vinfo_program = std::string (oct_info_prog); |
2203 | 315 } |
316 | |
4773 | 317 static void |
2203 | 318 set_default_editor (void) |
319 { | |
5794 | 320 VEDITOR = "emacs"; |
2203 | 321 |
3523 | 322 std::string env_editor = octave_env::getenv ("EDITOR"); |
2203 | 323 |
2926 | 324 if (! env_editor.empty ()) |
5794 | 325 VEDITOR = env_editor; |
2203 | 326 } |
327 | |
328 static void | |
329 set_local_site_defaults_file (void) | |
330 { | |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
331 std::string lsf = octave_env::getenv ("OCTAVE_SITE_INITFILE"); |
5781 | 332 |
333 if (lsf.empty ()) | |
334 { | |
335 Vlocal_site_defaults_file = subst_octave_home (OCTAVE_LOCALSTARTUPFILEDIR); | |
336 Vlocal_site_defaults_file.append ("/octaverc"); | |
337 } | |
338 else | |
339 Vlocal_site_defaults_file = lsf; | |
2203 | 340 } |
341 | |
342 static void | |
343 set_site_defaults_file (void) | |
344 { | |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
345 std::string sf = octave_env::getenv ("OCTAVE_VERSION_INITFILE"); |
5781 | 346 |
347 if (sf.empty ()) | |
348 { | |
349 Vsite_defaults_file = subst_octave_home (OCTAVE_STARTUPFILEDIR); | |
350 Vsite_defaults_file.append ("/octaverc"); | |
351 } | |
352 else | |
353 Vsite_defaults_file = sf; | |
2203 | 354 } |
355 | |
356 void | |
357 install_defaults (void) | |
358 { | |
359 // OCTAVE_HOME must be set first! | |
360 | |
361 set_octave_home (); | |
362 | |
363 set_default_info_dir (); | |
364 | |
3141 | 365 set_default_data_dir (); |
366 | |
367 set_default_libexec_dir (); | |
368 | |
2203 | 369 set_default_arch_lib_dir (); |
370 | |
5909 | 371 set_default_local_ver_arch_lib_dir (); |
372 set_default_local_api_arch_lib_dir (); | |
2439 | 373 set_default_local_arch_lib_dir (); |
374 | |
5814 | 375 set_default_local_ver_oct_file_dir (); |
376 set_default_local_api_oct_file_dir (); | |
377 set_default_local_oct_file_dir (); | |
2203 | 378 |
5814 | 379 set_default_local_ver_fcn_file_dir (); |
380 set_default_local_api_fcn_file_dir (); | |
381 set_default_local_fcn_file_dir (); | |
382 | |
383 set_default_fcn_file_dir (); | |
5397 | 384 set_default_oct_file_dir (); |
385 | |
5814 | 386 set_default_image_dir (); |
387 | |
2203 | 388 set_default_bin_dir (); |
389 | |
5814 | 390 set_exec_path (); |
4447 | 391 |
5814 | 392 set_image_path (); |
2203 | 393 |
8865
eace5649a8b5
set default value for doc_cache_file variable
John W. Eaton <jwe@octave.org>
parents:
8008
diff
changeset
|
394 set_default_doc_cache_file (); |
eace5649a8b5
set default value for doc_cache_file variable
John W. Eaton <jwe@octave.org>
parents:
8008
diff
changeset
|
395 |
2203 | 396 set_default_info_file (); |
397 | |
398 set_default_info_prog (); | |
399 | |
400 set_default_editor (); | |
401 | |
402 set_local_site_defaults_file (); | |
403 | |
404 set_site_defaults_file (); | |
405 } | |
406 | |
5794 | 407 DEFUN (EDITOR, args, nargout, |
408 "-*- texinfo -*-\n\ | |
10840 | 409 @deftypefn {Built-in Function} {@var{val} =} EDITOR ()\n\ |
5794 | 410 @deftypefnx {Built-in Function} {@var{old_val} =} EDITOR (@var{new_val})\n\ |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
12855
diff
changeset
|
411 @deftypefnx {Built-in Function} {} EDITOR (@var{new_val}, \"local\")\n\ |
5794 | 412 Query or set the internal variable that specifies the editor to\n\ |
9134
a3739e27b017
Update section 2.4 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9132
diff
changeset
|
413 use with the @code{edit_history} command. The default value is taken from\n\ |
10840 | 414 the environment variable @w{@env{EDITOR}} when Octave starts. If the\n\ |
415 environment variable is not initialized, @w{@env{EDITOR}} will be set to\n\ | |
5794 | 416 @code{\"emacs\"}.\n\ |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
12855
diff
changeset
|
417 \n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
12855
diff
changeset
|
418 When called from inside a function with the \"local\" option, the variable is\n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
12855
diff
changeset
|
419 changed locally for the function and any subroutines it calls. The original\n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
12855
diff
changeset
|
420 variable value is restored when exiting the function.\n\ |
5794 | 421 @seealso{edit_history}\n\ |
422 @end deftypefn") | |
2203 | 423 { |
5794 | 424 return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (EDITOR); |
2203 | 425 } |
426 | |
12851
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
427 /* |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
428 %!test |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
429 %! orig_val = EDITOR (); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
430 %! old_val = EDITOR ("X"); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
431 %! assert (orig_val, old_val); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
432 %! assert (EDITOR (), "X"); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
433 %! EDITOR (orig_val); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
434 %! assert (EDITOR (), orig_val); |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
435 |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
436 %!error (EDITOR (1, 2)) |
12851
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
437 */ |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
438 |
5794 | 439 DEFUN (EXEC_PATH, args, nargout, |
440 "-*- texinfo -*-\n\ | |
10840 | 441 @deftypefn {Built-in Function} {@var{val} =} EXEC_PATH ()\n\ |
5794 | 442 @deftypefnx {Built-in Function} {@var{old_val} =} EXEC_PATH (@var{new_val})\n\ |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
12855
diff
changeset
|
443 @deftypefnx {Built-in Function} {} EXEC_PATH (@var{new_val}, \"local\")\n\ |
5794 | 444 Query or set the internal variable that specifies a colon separated\n\ |
11294
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
445 list of directories to append to the shell PATH when executing external\n\ |
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
446 programs. The initial value of is taken from the environment variable\n\ |
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
447 @w{@env{OCTAVE_EXEC_PATH}}, but that value can be overridden by\n\ |
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
448 the command line argument @option{--exec-path PATH}.\n\ |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
12855
diff
changeset
|
449 \n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
12855
diff
changeset
|
450 When called from inside a function with the \"local\" option, the variable is\n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
12855
diff
changeset
|
451 changed locally for the function and any subroutines it calls. The original\n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
12855
diff
changeset
|
452 variable value is restored when exiting the function.\n\ |
5794 | 453 @end deftypefn") |
4217 | 454 { |
5794 | 455 octave_value retval = SET_NONEMPTY_INTERNAL_STRING_VARIABLE (EXEC_PATH); |
4217 | 456 |
11298
cb94bdc74670
defaults.cc (FEXEC_PATH): only call set_exec_path if nargin is greater than zero
John W. Eaton <jwe@octave.org>
parents:
11294
diff
changeset
|
457 if (args.length () > 0) |
cb94bdc74670
defaults.cc (FEXEC_PATH): only call set_exec_path if nargin is greater than zero
John W. Eaton <jwe@octave.org>
parents:
11294
diff
changeset
|
458 set_exec_path (VEXEC_PATH); |
2203 | 459 |
5794 | 460 return retval; |
2203 | 461 } |
462 | |
12851
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
463 /* |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
464 %!test |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
465 %! orig_val = EXEC_PATH (); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
466 %! old_val = EXEC_PATH ("X"); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
467 %! assert (orig_val, old_val); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
468 %! assert (EXEC_PATH (), "X"); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
469 %! EXEC_PATH (orig_val); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
470 %! assert (EXEC_PATH (), orig_val); |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
471 |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
472 %!error (EXEC_PATH (1, 2)) |
12851
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
473 */ |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
474 |
5814 | 475 DEFUN (IMAGE_PATH, args, nargout, |
5794 | 476 "-*- texinfo -*-\n\ |
10840 | 477 @deftypefn {Built-in Function} {@var{val} =} IMAGE_PATH ()\n\ |
5814 | 478 @deftypefnx {Built-in Function} {@var{old_val} =} IMAGE_PATH (@var{new_val})\n\ |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
12855
diff
changeset
|
479 @deftypefnx {Built-in Function} {} IMAGE_PATH (@var{new_val}, \"local\")\n\ |
5794 | 480 Query or set the internal variable that specifies a colon separated\n\ |
481 list of directories in which to search for image files.\n\ | |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
12855
diff
changeset
|
482 \n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
12855
diff
changeset
|
483 When called from inside a function with the \"local\" option, the variable is\n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
12855
diff
changeset
|
484 changed locally for the function and any subroutines it calls. The original\n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
12855
diff
changeset
|
485 variable value is restored when exiting the function.\n\ |
5794 | 486 @end deftypefn") |
487 { | |
5814 | 488 return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (IMAGE_PATH); |
5794 | 489 } |
490 | |
12851
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
491 /* |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
492 %!test |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
493 %! orig_val = IMAGE_PATH (); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
494 %! old_val = IMAGE_PATH ("X"); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
495 %! assert (orig_val, old_val); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
496 %! assert (IMAGE_PATH (), "X"); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
497 %! IMAGE_PATH (orig_val); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
498 %! assert (IMAGE_PATH (), orig_val); |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
499 |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
500 %!error (IMAGE_PATH (1, 2)) |
12851
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
501 */ |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
502 |
5780 | 503 DEFUN (OCTAVE_HOME, args, , |
504 "-*- texinfo -*-\n\ | |
505 @deftypefn {Built-in Function} {} OCTAVE_HOME ()\n\ | |
506 Return the name of the top-level Octave installation directory.\n\ | |
507 @end deftypefn") | |
508 { | |
509 octave_value retval; | |
2831 | 510 |
5780 | 511 if (args.length () == 0) |
512 retval = Voctave_home; | |
513 else | |
5823 | 514 print_usage (); |
5780 | 515 |
516 return retval; | |
5749 | 517 } |
3446 | 518 |
12851
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
519 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
520 %!assert (ischar (OCTAVE_HOME ())) |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
521 %!error OCTAVE_HOME (1) |
12851
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
522 */ |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
523 |
5749 | 524 DEFUNX ("OCTAVE_VERSION", FOCTAVE_VERSION, args, , |
525 "-*- texinfo -*-\n\ | |
526 @deftypefn {Built-in Function} {} OCTAVE_VERSION ()\n\ | |
527 Return the version number of Octave, as a string.\n\ | |
528 @end deftypefn") | |
529 { | |
530 octave_value retval; | |
531 | |
532 int nargin = args.length (); | |
533 | |
534 if (nargin == 0) | |
535 retval = OCTAVE_VERSION; | |
536 else | |
5823 | 537 print_usage (); |
5749 | 538 |
539 return retval; | |
2203 | 540 } |
12851
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
541 |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
542 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
543 %!assert (ischar (OCTAVE_VERSION ())) |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
544 %!error OCTAVE_VERSION (1) |
12851
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
545 */ |