Mercurial > hg > octave-jordi
annotate libinterp/interpfcn/defaults.cc @ 15195:2fc554ffbc28
split libinterp from src
* libinterp: New directory. Move all files from src directory here
except Makefile.am, main.cc, main-cli.cc, mkoctfile.in.cc,
mkoctfilr.in.sh, octave-config.in.cc, octave-config.in.sh.
* libinterp/Makefile.am: New file, extracted from src/Makefile.am.
* src/Makefile.am: Delete everything except targets and definitions
needed to build and link main and utility programs.
* Makefile.am (SUBDIRS): Include libinterp in the list.
* autogen.sh: Run config-module.sh in libinterp/dldfcn directory, not
src/dldfcn directory.
* configure.ac (AC_CONFIG_SRCDIR): Use libinterp/octave.cc, not
src/octave.cc.
(DL_LDFLAGS, LIBOCTINTERP): Use libinterp, not src.
(AC_CONFIG_FILES): Include libinterp/Makefile in the list.
* find-docstring-files.sh: Look in libinterp, not src.
* gui/src/Makefile.am (liboctgui_la_CPPFLAGS): Find header files in
libinterp, not src.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 18 Aug 2012 16:23:39 -0400 |
parents | src/interpfcn/defaults.cc@a87fa9132b72 |
children | bf0857c789f4 |
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 | |
15157
a87fa9132b72
provide Voct_etc_dir variable
John W. Eaton <jwe@octave.org>
parents:
15088
diff
changeset
|
77 std::string Voct_etc_dir; |
a87fa9132b72
provide Voct_etc_dir variable
John W. Eaton <jwe@octave.org>
parents:
15088
diff
changeset
|
78 |
5814 | 79 std::string Voct_file_dir; |
80 std::string Vfcn_file_dir; | |
81 | |
82 std::string Vimage_dir; | |
4447 | 83 |
2203 | 84 // The path that will be searched for programs that we execute. |
85 // (--exec-path path) | |
5794 | 86 static std::string VEXEC_PATH; |
2203 | 87 |
88 // Name of the editor to be invoked by the edit_history command. | |
5794 | 89 std::string VEDITOR; |
2203 | 90 |
5814 | 91 static std::string VIMAGE_PATH; |
2203 | 92 |
3523 | 93 std::string Vlocal_site_defaults_file; |
94 std::string Vsite_defaults_file; | |
2203 | 95 |
6274 | 96 std::string |
3523 | 97 subst_octave_home (const std::string& s) |
2203 | 98 { |
3523 | 99 std::string retval; |
2203 | 100 |
3523 | 101 std::string prefix = OCTAVE_PREFIX; |
2203 | 102 |
103 retval = s; | |
104 | |
105 if (Voctave_home != prefix) | |
106 { | |
5275 | 107 octave_idx_type len = prefix.length (); |
6276 | 108 |
109 if (s.substr (0, len) == prefix) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
110 retval.replace (0, len, Voctave_home); |
2203 | 111 } |
112 | |
8007
a2ab20ba78f7
make file_ops a proper singleton class
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
113 if (file_ops::dir_sep_char () != '/') |
a2ab20ba78f7
make file_ops a proper singleton class
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
114 std::replace (retval.begin (), retval.end (), '/', |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
115 file_ops::dir_sep_char ()); |
6114 | 116 |
2203 | 117 return retval; |
118 } | |
119 | |
120 static void | |
121 set_octave_home (void) | |
122 { | |
3523 | 123 std::string oh = octave_env::getenv ("OCTAVE_HOME"); |
2203 | 124 |
3523 | 125 Voctave_home = oh.empty () ? std::string (OCTAVE_PREFIX) : oh; |
2203 | 126 } |
127 | |
128 static void | |
129 set_default_info_dir (void) | |
130 { | |
131 Vinfo_dir = subst_octave_home (OCTAVE_INFODIR); | |
132 } | |
133 | |
134 static void | |
3141 | 135 set_default_data_dir (void) |
136 { | |
137 Vdata_dir = subst_octave_home (OCTAVE_DATADIR); | |
138 } | |
139 | |
140 static void | |
141 set_default_libexec_dir (void) | |
142 { | |
143 Vlibexec_dir = subst_octave_home (OCTAVE_LIBEXECDIR); | |
144 } | |
145 | |
146 static void | |
2203 | 147 set_default_arch_lib_dir (void) |
148 { | |
149 Varch_lib_dir = subst_octave_home (OCTAVE_ARCHLIBDIR); | |
150 } | |
151 | |
152 static void | |
2439 | 153 set_default_local_arch_lib_dir (void) |
154 { | |
155 Vlocal_arch_lib_dir = subst_octave_home (OCTAVE_LOCALARCHLIBDIR); | |
156 } | |
157 | |
158 static void | |
5909 | 159 set_default_local_api_arch_lib_dir (void) |
160 { | |
161 Vlocal_api_arch_lib_dir = subst_octave_home (OCTAVE_LOCALAPIARCHLIBDIR); | |
162 } | |
163 | |
164 static void | |
3597 | 165 set_default_local_ver_arch_lib_dir (void) |
166 { | |
167 Vlocal_ver_arch_lib_dir = subst_octave_home (OCTAVE_LOCALVERARCHLIBDIR); | |
168 } | |
169 | |
170 static void | |
5814 | 171 set_default_local_ver_oct_file_dir (void) |
172 { | |
173 Vlocal_ver_oct_file_dir = subst_octave_home (OCTAVE_LOCALVEROCTFILEDIR); | |
174 } | |
175 | |
176 static void | |
177 set_default_local_api_oct_file_dir (void) | |
178 { | |
179 Vlocal_api_oct_file_dir = subst_octave_home (OCTAVE_LOCALAPIOCTFILEDIR); | |
180 } | |
181 | |
182 static void | |
183 set_default_local_oct_file_dir (void) | |
184 { | |
185 Vlocal_oct_file_dir = subst_octave_home (OCTAVE_LOCALOCTFILEDIR); | |
186 } | |
187 | |
188 static void | |
189 set_default_local_ver_fcn_file_dir (void) | |
190 { | |
191 Vlocal_ver_fcn_file_dir = subst_octave_home (OCTAVE_LOCALVERFCNFILEDIR); | |
192 } | |
193 | |
194 static void | |
195 set_default_local_api_fcn_file_dir (void) | |
196 { | |
197 Vlocal_api_fcn_file_dir = subst_octave_home (OCTAVE_LOCALAPIFCNFILEDIR); | |
198 } | |
199 | |
200 static void | |
201 set_default_local_fcn_file_dir (void) | |
202 { | |
203 Vlocal_fcn_file_dir = subst_octave_home (OCTAVE_LOCALFCNFILEDIR); | |
204 } | |
205 | |
206 static void | |
2203 | 207 set_default_fcn_file_dir (void) |
208 { | |
209 Vfcn_file_dir = subst_octave_home (OCTAVE_FCNFILEDIR); | |
210 } | |
211 | |
212 static void | |
5814 | 213 set_default_image_dir (void) |
214 { | |
215 Vimage_dir = subst_octave_home (OCTAVE_IMAGEDIR); | |
216 } | |
217 | |
218 static void | |
15157
a87fa9132b72
provide Voct_etc_dir variable
John W. Eaton <jwe@octave.org>
parents:
15088
diff
changeset
|
219 set_default_oct_etc_dir (void) |
a87fa9132b72
provide Voct_etc_dir variable
John W. Eaton <jwe@octave.org>
parents:
15088
diff
changeset
|
220 { |
a87fa9132b72
provide Voct_etc_dir variable
John W. Eaton <jwe@octave.org>
parents:
15088
diff
changeset
|
221 Voct_etc_dir = subst_octave_home (OCTAVE_OCTETCDIR); |
a87fa9132b72
provide Voct_etc_dir variable
John W. Eaton <jwe@octave.org>
parents:
15088
diff
changeset
|
222 } |
a87fa9132b72
provide Voct_etc_dir variable
John W. Eaton <jwe@octave.org>
parents:
15088
diff
changeset
|
223 |
a87fa9132b72
provide Voct_etc_dir variable
John W. Eaton <jwe@octave.org>
parents:
15088
diff
changeset
|
224 static void |
5397 | 225 set_default_oct_file_dir (void) |
226 { | |
227 Voct_file_dir = subst_octave_home (OCTAVE_OCTFILEDIR); | |
228 } | |
229 | |
230 static void | |
2203 | 231 set_default_bin_dir (void) |
232 { | |
233 Vbin_dir = subst_octave_home (OCTAVE_BINDIR); | |
234 } | |
235 | |
5814 | 236 void |
11294
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
237 set_exec_path (const std::string& path_arg) |
4447 | 238 { |
11294
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
239 std::string tpath = path_arg; |
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
240 |
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
241 if (tpath.empty ()) |
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
242 tpath = octave_env::getenv ("OCTAVE_EXEC_PATH"); |
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
243 |
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
244 if (tpath.empty ()) |
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
245 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
|
246 + 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
|
247 + 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
|
248 + Varch_lib_dir + dir_path::path_sep_str () |
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
249 + Vbin_dir; |
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 VEXEC_PATH = tpath; |
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
252 |
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
253 // 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
|
254 // 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
|
255 // PATH with calls like |
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
256 // |
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
257 // setenv ("PATH", "/my/path"); |
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
258 // |
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
259 // 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
|
260 // 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
|
261 // 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
|
262 // searching. |
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
263 |
5814 | 264 // This is static so that even if set_exec_path is called more than |
265 // once, shell_path is the original PATH from the environment, | |
266 // before we start modifying it. | |
267 static std::string shell_path = octave_env::getenv ("PATH"); | |
268 | |
269 if (! shell_path.empty ()) | |
11294
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
270 tpath = shell_path + dir_path::path_sep_str () + tpath; |
5814 | 271 |
11294
e2a4f3478b7c
datetick.m: add missing semicolon
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
272 octave_env::putenv ("PATH", tpath); |
5814 | 273 } |
274 | |
275 void | |
276 set_image_path (const std::string& path) | |
277 { | |
278 VIMAGE_PATH = "."; | |
279 | |
280 std::string tpath = path; | |
281 | |
282 if (tpath.empty ()) | |
283 tpath = octave_env::getenv ("OCTAVE_IMAGE_PATH"); | |
284 | |
285 if (! tpath.empty ()) | |
8008
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
8007
diff
changeset
|
286 VIMAGE_PATH += dir_path::path_sep_str () + tpath; |
5814 | 287 |
5832 | 288 tpath = genpath (Vimage_dir, ""); |
289 | |
290 if (! tpath.empty ()) | |
8008
4d13a7a2f6ab
dir_path: use singleton class for static data members
John W. Eaton <jwe@octave.org>
parents:
8007
diff
changeset
|
291 VIMAGE_PATH += dir_path::path_sep_str () + tpath; |
5814 | 292 } |
293 | |
2203 | 294 static void |
8865
eace5649a8b5
set default value for doc_cache_file variable
John W. Eaton <jwe@octave.org>
parents:
8008
diff
changeset
|
295 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
|
296 { |
eace5649a8b5
set default value for doc_cache_file variable
John W. Eaton <jwe@octave.org>
parents:
8008
diff
changeset
|
297 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
|
298 |
eace5649a8b5
set default value for doc_cache_file variable
John W. Eaton <jwe@octave.org>
parents:
8008
diff
changeset
|
299 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
|
300 |
eace5649a8b5
set default value for doc_cache_file variable
John W. Eaton <jwe@octave.org>
parents:
8008
diff
changeset
|
301 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
|
302 } |
eace5649a8b5
set default value for doc_cache_file variable
John W. Eaton <jwe@octave.org>
parents:
8008
diff
changeset
|
303 |
eace5649a8b5
set default value for doc_cache_file variable
John W. Eaton <jwe@octave.org>
parents:
8008
diff
changeset
|
304 static void |
14614
4e9dc46d4125
handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents:
14429
diff
changeset
|
305 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
|
306 { |
4e9dc46d4125
handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents:
14429
diff
changeset
|
307 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
|
308 |
4e9dc46d4125
handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents:
14429
diff
changeset
|
309 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
|
310 |
4e9dc46d4125
handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents:
14429
diff
changeset
|
311 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
|
312 } |
4e9dc46d4125
handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents:
14429
diff
changeset
|
313 |
4e9dc46d4125
handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents:
14429
diff
changeset
|
314 static void |
2203 | 315 set_default_info_file (void) |
316 { | |
3523 | 317 std::string std_info_file = subst_octave_home (OCTAVE_INFOFILE); |
2512 | 318 |
3523 | 319 std::string oct_info_file = octave_env::getenv ("OCTAVE_INFO_FILE"); |
2203 | 320 |
2926 | 321 Vinfo_file = oct_info_file.empty () ? std_info_file : oct_info_file; |
2203 | 322 } |
323 | |
324 static void | |
325 set_default_info_prog (void) | |
326 { | |
3523 | 327 std::string oct_info_prog = octave_env::getenv ("OCTAVE_INFO_PROGRAM"); |
2203 | 328 |
2926 | 329 if (oct_info_prog.empty ()) |
5794 | 330 Vinfo_program = "info"; |
2926 | 331 else |
5794 | 332 Vinfo_program = std::string (oct_info_prog); |
2203 | 333 } |
334 | |
4773 | 335 static void |
2203 | 336 set_default_editor (void) |
337 { | |
5794 | 338 VEDITOR = "emacs"; |
2203 | 339 |
3523 | 340 std::string env_editor = octave_env::getenv ("EDITOR"); |
2203 | 341 |
2926 | 342 if (! env_editor.empty ()) |
5794 | 343 VEDITOR = env_editor; |
2203 | 344 } |
345 | |
346 static void | |
347 set_local_site_defaults_file (void) | |
348 { | |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
349 std::string lsf = octave_env::getenv ("OCTAVE_SITE_INITFILE"); |
5781 | 350 |
351 if (lsf.empty ()) | |
352 { | |
353 Vlocal_site_defaults_file = subst_octave_home (OCTAVE_LOCALSTARTUPFILEDIR); | |
354 Vlocal_site_defaults_file.append ("/octaverc"); | |
355 } | |
356 else | |
357 Vlocal_site_defaults_file = lsf; | |
2203 | 358 } |
359 | |
360 static void | |
361 set_site_defaults_file (void) | |
362 { | |
9132
eb1747dbd360
Update help strings for command line options
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
363 std::string sf = octave_env::getenv ("OCTAVE_VERSION_INITFILE"); |
5781 | 364 |
365 if (sf.empty ()) | |
366 { | |
367 Vsite_defaults_file = subst_octave_home (OCTAVE_STARTUPFILEDIR); | |
368 Vsite_defaults_file.append ("/octaverc"); | |
369 } | |
370 else | |
371 Vsite_defaults_file = sf; | |
2203 | 372 } |
373 | |
374 void | |
375 install_defaults (void) | |
376 { | |
377 // OCTAVE_HOME must be set first! | |
378 | |
379 set_octave_home (); | |
380 | |
381 set_default_info_dir (); | |
382 | |
3141 | 383 set_default_data_dir (); |
384 | |
385 set_default_libexec_dir (); | |
386 | |
2203 | 387 set_default_arch_lib_dir (); |
388 | |
5909 | 389 set_default_local_ver_arch_lib_dir (); |
390 set_default_local_api_arch_lib_dir (); | |
2439 | 391 set_default_local_arch_lib_dir (); |
392 | |
5814 | 393 set_default_local_ver_oct_file_dir (); |
394 set_default_local_api_oct_file_dir (); | |
395 set_default_local_oct_file_dir (); | |
2203 | 396 |
5814 | 397 set_default_local_ver_fcn_file_dir (); |
398 set_default_local_api_fcn_file_dir (); | |
399 set_default_local_fcn_file_dir (); | |
400 | |
15157
a87fa9132b72
provide Voct_etc_dir variable
John W. Eaton <jwe@octave.org>
parents:
15088
diff
changeset
|
401 set_default_oct_etc_dir (); |
a87fa9132b72
provide Voct_etc_dir variable
John W. Eaton <jwe@octave.org>
parents:
15088
diff
changeset
|
402 |
5814 | 403 set_default_fcn_file_dir (); |
5397 | 404 set_default_oct_file_dir (); |
405 | |
5814 | 406 set_default_image_dir (); |
407 | |
2203 | 408 set_default_bin_dir (); |
409 | |
5814 | 410 set_exec_path (); |
4447 | 411 |
5814 | 412 set_image_path (); |
2203 | 413 |
8865
eace5649a8b5
set default value for doc_cache_file variable
John W. Eaton <jwe@octave.org>
parents:
8008
diff
changeset
|
414 set_default_doc_cache_file (); |
eace5649a8b5
set default value for doc_cache_file variable
John W. Eaton <jwe@octave.org>
parents:
8008
diff
changeset
|
415 |
14614
4e9dc46d4125
handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents:
14429
diff
changeset
|
416 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
|
417 |
2203 | 418 set_default_info_file (); |
419 | |
420 set_default_info_prog (); | |
421 | |
422 set_default_editor (); | |
423 | |
424 set_local_site_defaults_file (); | |
425 | |
426 set_site_defaults_file (); | |
427 } | |
428 | |
5794 | 429 DEFUN (EDITOR, args, nargout, |
430 "-*- texinfo -*-\n\ | |
10840 | 431 @deftypefn {Built-in Function} {@var{val} =} EDITOR ()\n\ |
5794 | 432 @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
|
433 @deftypefnx {Built-in Function} {} EDITOR (@var{new_val}, \"local\")\n\ |
5794 | 434 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
|
435 use with the @code{edit_history} command. The default value is taken from\n\ |
10840 | 436 the environment variable @w{@env{EDITOR}} when Octave starts. If the\n\ |
437 environment variable is not initialized, @w{@env{EDITOR}} will be set to\n\ | |
5794 | 438 @code{\"emacs\"}.\n\ |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
12855
diff
changeset
|
439 \n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
12855
diff
changeset
|
440 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
|
441 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
|
442 variable value is restored when exiting the function.\n\ |
5794 | 443 @seealso{edit_history}\n\ |
444 @end deftypefn") | |
2203 | 445 { |
5794 | 446 return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (EDITOR); |
2203 | 447 } |
448 | |
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 %!test |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
451 %! orig_val = EDITOR (); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
452 %! old_val = EDITOR ("X"); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
453 %! assert (orig_val, old_val); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
454 %! assert (EDITOR (), "X"); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
455 %! EDITOR (orig_val); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
456 %! assert (EDITOR (), orig_val); |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
457 |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
458 %!error (EDITOR (1, 2)) |
12851
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
459 */ |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
460 |
5794 | 461 DEFUN (EXEC_PATH, args, nargout, |
462 "-*- texinfo -*-\n\ | |
10840 | 463 @deftypefn {Built-in Function} {@var{val} =} EXEC_PATH ()\n\ |
5794 | 464 @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
|
465 @deftypefnx {Built-in Function} {} EXEC_PATH (@var{new_val}, \"local\")\n\ |
5794 | 466 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
|
467 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
|
468 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
|
469 @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
|
470 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
|
471 \n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
12855
diff
changeset
|
472 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
|
473 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
|
474 variable value is restored when exiting the function.\n\ |
5794 | 475 @end deftypefn") |
4217 | 476 { |
5794 | 477 octave_value retval = SET_NONEMPTY_INTERNAL_STRING_VARIABLE (EXEC_PATH); |
4217 | 478 |
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
|
479 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
|
480 set_exec_path (VEXEC_PATH); |
2203 | 481 |
5794 | 482 return retval; |
2203 | 483 } |
484 | |
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 %!test |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
487 %! orig_val = EXEC_PATH (); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
488 %! old_val = EXEC_PATH ("X"); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
489 %! assert (orig_val, old_val); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
490 %! assert (EXEC_PATH (), "X"); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
491 %! EXEC_PATH (orig_val); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
492 %! 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
|
493 |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
494 %!error (EXEC_PATH (1, 2)) |
12851
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
495 */ |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
496 |
5814 | 497 DEFUN (IMAGE_PATH, args, nargout, |
5794 | 498 "-*- texinfo -*-\n\ |
10840 | 499 @deftypefn {Built-in Function} {@var{val} =} IMAGE_PATH ()\n\ |
5814 | 500 @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
|
501 @deftypefnx {Built-in Function} {} IMAGE_PATH (@var{new_val}, \"local\")\n\ |
5794 | 502 Query or set the internal variable that specifies a colon separated\n\ |
503 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
|
504 \n\ |
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
12855
diff
changeset
|
505 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
|
506 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
|
507 variable value is restored when exiting the function.\n\ |
5794 | 508 @end deftypefn") |
509 { | |
5814 | 510 return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (IMAGE_PATH); |
5794 | 511 } |
512 | |
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 %!test |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
515 %! orig_val = IMAGE_PATH (); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
516 %! old_val = IMAGE_PATH ("X"); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
517 %! assert (orig_val, old_val); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
518 %! assert (IMAGE_PATH (), "X"); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
519 %! IMAGE_PATH (orig_val); |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
520 %! 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
|
521 |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
522 %!error (IMAGE_PATH (1, 2)) |
12851
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
523 */ |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
524 |
5780 | 525 DEFUN (OCTAVE_HOME, args, , |
526 "-*- texinfo -*-\n\ | |
527 @deftypefn {Built-in Function} {} OCTAVE_HOME ()\n\ | |
528 Return the name of the top-level Octave installation directory.\n\ | |
529 @end deftypefn") | |
530 { | |
531 octave_value retval; | |
2831 | 532 |
5780 | 533 if (args.length () == 0) |
534 retval = Voctave_home; | |
535 else | |
5823 | 536 print_usage (); |
5780 | 537 |
538 return retval; | |
5749 | 539 } |
3446 | 540 |
12851
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
541 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
542 %!assert (ischar (OCTAVE_HOME ())) |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
543 %!error OCTAVE_HOME (1) |
12851
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
544 */ |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
545 |
5749 | 546 DEFUNX ("OCTAVE_VERSION", FOCTAVE_VERSION, args, , |
547 "-*- texinfo -*-\n\ | |
548 @deftypefn {Built-in Function} {} OCTAVE_VERSION ()\n\ | |
549 Return the version number of Octave, as a string.\n\ | |
550 @end deftypefn") | |
551 { | |
552 octave_value retval; | |
553 | |
554 int nargin = args.length (); | |
555 | |
556 if (nargin == 0) | |
557 retval = OCTAVE_VERSION; | |
558 else | |
5823 | 559 print_usage (); |
5749 | 560 |
561 return retval; | |
2203 | 562 } |
12851
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
563 |
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
564 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
565 %!assert (ischar (OCTAVE_VERSION ())) |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
566 %!error OCTAVE_VERSION (1) |
12851
7fce673b934a
codesprint: new tests for defaults.cc
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
567 */ |