Mercurial > octave-nkf
annotate src/interpfcn/defaults.cc @ 15088:60ff2cef569d
maint: Move core interpreter files with DEFUNS to interpfcn/ directory
* src/Makefile.am: Adjust build system for new location of files.
* interpfcn/module.mk: Add files and rules to build system.
* data.cc, data.h, debug.cc, debug.h, defaults.cc, defaults.in.h, defun.cc,
defun.h, dirfns.cc, dirfns.h, error.cc, error.h, file-io.cc, file-io.h,
graphics.cc, graphics.in.h, help.cc, help.h, input.cc, input.h, load-path.cc,
load-path.h, load-save.cc, load-save.h, ls-oct-ascii.cc, ls-oct-ascii.h,
oct-hist.cc, oct-hist.h, pager.cc, pager.h, pr-output.cc,
pr-output.h, profiler.cc, profiler.h, sighandlers.cc, sighandlers.h, symtab.cc,
symtab.h, sysdep.cc, sysdep.h, toplev.cc, toplev.h, utils.cc, utils.h,
variables.cc, variables.h: Move files to interpfcn/ directory
author | Rik <rik@octave.org> |
---|---|
date | Fri, 03 Aug 2012 09:31:37 -0700 |
parents | src/defaults.cc@4e9dc46d4125 |
children | a87fa9132b72 |
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 |
14614
4e9dc46d4125
handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents:
14429
diff
changeset
|
297 set_default_texi_macros_file (void) |
4e9dc46d4125
handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents:
14429
diff
changeset
|
298 { |
4e9dc46d4125
handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents:
14429
diff
changeset
|
299 std::string def_file = subst_octave_home (OCTAVE_TEXI_MACROS_FILE); |
4e9dc46d4125
handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents:
14429
diff
changeset
|
300 |
4e9dc46d4125
handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents:
14429
diff
changeset
|
301 std::string env_file = octave_env::getenv ("OCTAVE_TEXI_MACROS_FILE"); |
4e9dc46d4125
handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents:
14429
diff
changeset
|
302 |
4e9dc46d4125
handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents:
14429
diff
changeset
|
303 Vtexi_macros_file = env_file.empty () ? def_file : env_file; |
4e9dc46d4125
handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents:
14429
diff
changeset
|
304 } |
4e9dc46d4125
handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents:
14429
diff
changeset
|
305 |
4e9dc46d4125
handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents:
14429
diff
changeset
|
306 static void |
2203 | 307 set_default_info_file (void) |
308 { | |
3523 | 309 std::string std_info_file = subst_octave_home (OCTAVE_INFOFILE); |
2512 | 310 |
3523 | 311 std::string oct_info_file = octave_env::getenv ("OCTAVE_INFO_FILE"); |
2203 | 312 |
2926 | 313 Vinfo_file = oct_info_file.empty () ? std_info_file : oct_info_file; |
2203 | 314 } |
315 | |
316 static void | |
317 set_default_info_prog (void) | |
318 { | |
3523 | 319 std::string oct_info_prog = octave_env::getenv ("OCTAVE_INFO_PROGRAM"); |
2203 | 320 |
2926 | 321 if (oct_info_prog.empty ()) |
5794 | 322 Vinfo_program = "info"; |
2926 | 323 else |
5794 | 324 Vinfo_program = std::string (oct_info_prog); |
2203 | 325 } |
326 | |
4773 | 327 static void |
2203 | 328 set_default_editor (void) |
329 { | |
5794 | 330 VEDITOR = "emacs"; |
2203 | 331 |
3523 | 332 std::string env_editor = octave_env::getenv ("EDITOR"); |
2203 | 333 |
2926 | 334 if (! env_editor.empty ()) |
5794 | 335 VEDITOR = env_editor; |
2203 | 336 } |
337 | |
338 static void | |
339 set_local_site_defaults_file (void) | |
340 { | |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
341 std::string lsf = octave_env::getenv ("OCTAVE_SITE_INITFILE"); |
5781 | 342 |
343 if (lsf.empty ()) | |
344 { | |
345 Vlocal_site_defaults_file = subst_octave_home (OCTAVE_LOCALSTARTUPFILEDIR); | |
346 Vlocal_site_defaults_file.append ("/octaverc"); | |
347 } | |
348 else | |
349 Vlocal_site_defaults_file = lsf; | |
2203 | 350 } |
351 | |
352 static void | |
353 set_site_defaults_file (void) | |
354 { | |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
355 std::string sf = octave_env::getenv ("OCTAVE_VERSION_INITFILE"); |
5781 | 356 |
357 if (sf.empty ()) | |
358 { | |
359 Vsite_defaults_file = subst_octave_home (OCTAVE_STARTUPFILEDIR); | |
360 Vsite_defaults_file.append ("/octaverc"); | |
361 } | |
362 else | |
363 Vsite_defaults_file = sf; | |
2203 | 364 } |
365 | |
366 void | |
367 install_defaults (void) | |
368 { | |
369 // OCTAVE_HOME must be set first! | |
370 | |
371 set_octave_home (); | |
372 | |
373 set_default_info_dir (); | |
374 | |
3141 | 375 set_default_data_dir (); |
376 | |
377 set_default_libexec_dir (); | |
378 | |
2203 | 379 set_default_arch_lib_dir (); |
380 | |
5909 | 381 set_default_local_ver_arch_lib_dir (); |
382 set_default_local_api_arch_lib_dir (); | |
2439 | 383 set_default_local_arch_lib_dir (); |
384 | |
5814 | 385 set_default_local_ver_oct_file_dir (); |
386 set_default_local_api_oct_file_dir (); | |
387 set_default_local_oct_file_dir (); | |
2203 | 388 |
5814 | 389 set_default_local_ver_fcn_file_dir (); |
390 set_default_local_api_fcn_file_dir (); | |
391 set_default_local_fcn_file_dir (); | |
392 | |
393 set_default_fcn_file_dir (); | |
5397 | 394 set_default_oct_file_dir (); |
395 | |
5814 | 396 set_default_image_dir (); |
397 | |
2203 | 398 set_default_bin_dir (); |
399 | |
5814 | 400 set_exec_path (); |
4447 | 401 |
5814 | 402 set_image_path (); |
2203 | 403 |
8865
eace5649a8b5
set default value for doc_cache_file variable
John W. Eaton <jwe@octave.org>
parents:
8008
diff
changeset
|
404 set_default_doc_cache_file (); |
eace5649a8b5
set default value for doc_cache_file variable
John W. Eaton <jwe@octave.org>
parents:
8008
diff
changeset
|
405 |
14614
4e9dc46d4125
handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents:
14429
diff
changeset
|
406 set_default_texi_macros_file (); |
4e9dc46d4125
handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents:
14429
diff
changeset
|
407 |
2203 | 408 set_default_info_file (); |
409 | |
410 set_default_info_prog (); | |
411 | |
412 set_default_editor (); | |
413 | |
414 set_local_site_defaults_file (); | |
415 | |
416 set_site_defaults_file (); | |
417 } | |
418 | |
5794 | 419 DEFUN (EDITOR, args, nargout, |
420 "-*- texinfo -*-\n\ | |
10840 | 421 @deftypefn {Built-in Function} {@var{val} =} EDITOR ()\n\ |
5794 | 422 @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
|
423 @deftypefnx {Built-in Function} {} EDITOR (@var{new_val}, \"local\")\n\ |
5794 | 424 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
|
425 use with the @code{edit_history} command. The default value is taken from\n\ |
10840 | 426 the environment variable @w{@env{EDITOR}} when Octave starts. If the\n\ |
427 environment variable is not initialized, @w{@env{EDITOR}} will be set to\n\ | |
5794 | 428 @code{\"emacs\"}.\n\ |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
12855
diff
changeset
|
429 \n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
12855
diff
changeset
|
430 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
|
431 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
|
432 variable value is restored when exiting the function.\n\ |
5794 | 433 @seealso{edit_history}\n\ |
434 @end deftypefn") | |
2203 | 435 { |
5794 | 436 return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (EDITOR); |
2203 | 437 } |
438 | |
12851
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
439 /* |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
440 %!test |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
441 %! orig_val = EDITOR (); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
442 %! old_val = EDITOR ("X"); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
443 %! assert (orig_val, old_val); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
444 %! assert (EDITOR (), "X"); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
445 %! EDITOR (orig_val); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
446 %! assert (EDITOR (), orig_val); |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
447 |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
448 %!error (EDITOR (1, 2)) |
12851
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
449 */ |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
450 |
5794 | 451 DEFUN (EXEC_PATH, args, nargout, |
452 "-*- texinfo -*-\n\ | |
10840 | 453 @deftypefn {Built-in Function} {@var{val} =} EXEC_PATH ()\n\ |
5794 | 454 @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
|
455 @deftypefnx {Built-in Function} {} EXEC_PATH (@var{new_val}, \"local\")\n\ |
5794 | 456 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
|
457 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
|
458 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
|
459 @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
|
460 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
|
461 \n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
12855
diff
changeset
|
462 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
|
463 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
|
464 variable value is restored when exiting the function.\n\ |
5794 | 465 @end deftypefn") |
4217 | 466 { |
5794 | 467 octave_value retval = SET_NONEMPTY_INTERNAL_STRING_VARIABLE (EXEC_PATH); |
4217 | 468 |
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
|
469 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
|
470 set_exec_path (VEXEC_PATH); |
2203 | 471 |
5794 | 472 return retval; |
2203 | 473 } |
474 | |
12851
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
475 /* |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
476 %!test |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
477 %! orig_val = EXEC_PATH (); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
478 %! old_val = EXEC_PATH ("X"); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
479 %! assert (orig_val, old_val); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
480 %! assert (EXEC_PATH (), "X"); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
481 %! EXEC_PATH (orig_val); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
482 %! 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
|
483 |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
484 %!error (EXEC_PATH (1, 2)) |
12851
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
485 */ |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
486 |
5814 | 487 DEFUN (IMAGE_PATH, args, nargout, |
5794 | 488 "-*- texinfo -*-\n\ |
10840 | 489 @deftypefn {Built-in Function} {@var{val} =} IMAGE_PATH ()\n\ |
5814 | 490 @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
|
491 @deftypefnx {Built-in Function} {} IMAGE_PATH (@var{new_val}, \"local\")\n\ |
5794 | 492 Query or set the internal variable that specifies a colon separated\n\ |
493 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
|
494 \n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
12855
diff
changeset
|
495 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
|
496 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
|
497 variable value is restored when exiting the function.\n\ |
5794 | 498 @end deftypefn") |
499 { | |
5814 | 500 return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (IMAGE_PATH); |
5794 | 501 } |
502 | |
12851
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
503 /* |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
504 %!test |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
505 %! orig_val = IMAGE_PATH (); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
506 %! old_val = IMAGE_PATH ("X"); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
507 %! assert (orig_val, old_val); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
508 %! assert (IMAGE_PATH (), "X"); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
509 %! IMAGE_PATH (orig_val); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
510 %! 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
|
511 |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
512 %!error (IMAGE_PATH (1, 2)) |
12851
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
513 */ |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
514 |
5780 | 515 DEFUN (OCTAVE_HOME, args, , |
516 "-*- texinfo -*-\n\ | |
517 @deftypefn {Built-in Function} {} OCTAVE_HOME ()\n\ | |
518 Return the name of the top-level Octave installation directory.\n\ | |
519 @end deftypefn") | |
520 { | |
521 octave_value retval; | |
2831 | 522 |
5780 | 523 if (args.length () == 0) |
524 retval = Voctave_home; | |
525 else | |
5823 | 526 print_usage (); |
5780 | 527 |
528 return retval; | |
5749 | 529 } |
3446 | 530 |
12851
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
531 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
532 %!assert (ischar (OCTAVE_HOME ())) |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
533 %!error OCTAVE_HOME (1) |
12851
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
534 */ |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
535 |
5749 | 536 DEFUNX ("OCTAVE_VERSION", FOCTAVE_VERSION, args, , |
537 "-*- texinfo -*-\n\ | |
538 @deftypefn {Built-in Function} {} OCTAVE_VERSION ()\n\ | |
539 Return the version number of Octave, as a string.\n\ | |
540 @end deftypefn") | |
541 { | |
542 octave_value retval; | |
543 | |
544 int nargin = args.length (); | |
545 | |
546 if (nargin == 0) | |
547 retval = OCTAVE_VERSION; | |
548 else | |
5823 | 549 print_usage (); |
5749 | 550 |
551 return retval; | |
2203 | 552 } |
12851
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
553 |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
554 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
555 %!assert (ischar (OCTAVE_VERSION ())) |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
556 %!error OCTAVE_VERSION (1) |
12851
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
557 */ |