Mercurial > hg > octave-lyh
comparison src/defaults.cc @ 3523:b80bbb43a1a9
[project @ 2000-02-02 10:25:52 by jwe]
author | jwe |
---|---|
date | Wed, 02 Feb 2000 10:26:25 +0000 |
parents | d14c483b3c12 |
children | 4abbfb1ca636 |
comparison
equal
deleted
inserted
replaced
3522:bd422cf62f0c | 3523:b80bbb43a1a9 |
---|---|
49 #include "ov.h" | 49 #include "ov.h" |
50 #include "toplev.h" | 50 #include "toplev.h" |
51 #include "variables.h" | 51 #include "variables.h" |
52 #include <version.h> | 52 #include <version.h> |
53 | 53 |
54 string Voctave_home; | 54 std::string Voctave_home; |
55 | 55 |
56 string Vbin_dir; | 56 std::string Vbin_dir; |
57 string Vinfo_dir; | 57 std::string Vinfo_dir; |
58 string Vdata_dir; | 58 std::string Vdata_dir; |
59 string Vlibexec_dir; | 59 std::string Vlibexec_dir; |
60 string Varch_lib_dir; | 60 std::string Varch_lib_dir; |
61 string Vlocal_arch_lib_dir; | 61 std::string Vlocal_arch_lib_dir; |
62 string Vfcn_file_dir; | 62 std::string Vfcn_file_dir; |
63 | 63 |
64 // The path that will be searched for programs that we execute. | 64 // The path that will be searched for programs that we execute. |
65 // (--exec-path path) | 65 // (--exec-path path) |
66 string Vexec_path; | 66 std::string Vexec_path; |
67 | 67 |
68 // Load path specified on command line. | 68 // Load path specified on command line. |
69 // (--path path; -p path) | 69 // (--path path; -p path) |
70 static string Vload_path; | 70 static std::string Vload_path; |
71 | 71 |
72 // The default load path with OCTAVE_HOME appropriately substituted. | 72 // The default load path with OCTAVE_HOME appropriately substituted. |
73 static string Vdefault_load_path; | 73 static std::string Vdefault_load_path; |
74 | 74 |
75 // And the cached directory path corresponding to Vload_path. | 75 // And the cached directory path corresponding to Vload_path. |
76 dir_path Vload_path_dir_path; | 76 dir_path Vload_path_dir_path; |
77 | 77 |
78 // Name of the editor to be invoked by the edit_history command. | 78 // Name of the editor to be invoked by the edit_history command. |
79 string Veditor; | 79 std::string Veditor; |
80 | 80 |
81 string Vimagepath; | 81 std::string Vimagepath; |
82 | 82 |
83 string Vlocal_site_defaults_file; | 83 std::string Vlocal_site_defaults_file; |
84 string Vsite_defaults_file; | 84 std::string Vsite_defaults_file; |
85 | 85 |
86 static string | 86 static string |
87 subst_octave_home (const string& s) | 87 subst_octave_home (const std::string& s) |
88 { | 88 { |
89 string retval; | 89 std::string retval; |
90 | 90 |
91 string prefix = OCTAVE_PREFIX; | 91 std::string prefix = OCTAVE_PREFIX; |
92 | 92 |
93 retval = s; | 93 retval = s; |
94 | 94 |
95 if (Voctave_home != prefix) | 95 if (Voctave_home != prefix) |
96 { | 96 { |
107 } | 107 } |
108 | 108 |
109 static void | 109 static void |
110 set_octave_home (void) | 110 set_octave_home (void) |
111 { | 111 { |
112 string oh = octave_env::getenv ("OCTAVE_HOME"); | 112 std::string oh = octave_env::getenv ("OCTAVE_HOME"); |
113 | 113 |
114 Voctave_home = oh.empty () ? string (OCTAVE_PREFIX) : oh; | 114 Voctave_home = oh.empty () ? std::string (OCTAVE_PREFIX) : oh; |
115 } | 115 } |
116 | 116 |
117 static void | 117 static void |
118 set_default_info_dir (void) | 118 set_default_info_dir (void) |
119 { | 119 { |
157 } | 157 } |
158 | 158 |
159 static void | 159 static void |
160 set_default_exec_path (void) | 160 set_default_exec_path (void) |
161 { | 161 { |
162 string octave_exec_path = octave_env::getenv ("OCTAVE_EXEC_PATH"); | 162 std::string octave_exec_path = octave_env::getenv ("OCTAVE_EXEC_PATH"); |
163 | 163 |
164 if (octave_exec_path.empty ()) | 164 if (octave_exec_path.empty ()) |
165 { | 165 { |
166 string shell_path = octave_env::getenv ("PATH"); | 166 std::string shell_path = octave_env::getenv ("PATH"); |
167 | 167 |
168 if (! shell_path.empty ()) | 168 if (! shell_path.empty ()) |
169 { | 169 { |
170 Vexec_path = string (":"); | 170 Vexec_path = std::string (":"); |
171 Vexec_path.append (shell_path); | 171 Vexec_path.append (shell_path); |
172 } | 172 } |
173 } | 173 } |
174 else | 174 else |
175 Vexec_path = string (octave_exec_path); | 175 Vexec_path = std::string (octave_exec_path); |
176 } | 176 } |
177 | 177 |
178 static void | 178 static void |
179 set_default_path (void) | 179 set_default_path (void) |
180 { | 180 { |
181 Vdefault_load_path = subst_octave_home (OCTAVE_FCNFILEPATH); | 181 Vdefault_load_path = subst_octave_home (OCTAVE_FCNFILEPATH); |
182 | 182 |
183 string oct_path = octave_env::getenv ("OCTAVE_PATH"); | 183 std::string oct_path = octave_env::getenv ("OCTAVE_PATH"); |
184 | 184 |
185 Vload_path = oct_path.empty () ? string (":") : oct_path; | 185 Vload_path = oct_path.empty () ? std::string (":") : oct_path; |
186 | 186 |
187 Vload_path_dir_path = dir_path (Vload_path, Vdefault_load_path); | 187 Vload_path_dir_path = dir_path (Vload_path, Vdefault_load_path); |
188 } | 188 } |
189 | 189 |
190 static void | 190 static void |
191 set_default_info_file (void) | 191 set_default_info_file (void) |
192 { | 192 { |
193 string std_info_file = subst_octave_home (OCTAVE_INFOFILE); | 193 std::string std_info_file = subst_octave_home (OCTAVE_INFOFILE); |
194 | 194 |
195 string oct_info_file = octave_env::getenv ("OCTAVE_INFO_FILE"); | 195 std::string oct_info_file = octave_env::getenv ("OCTAVE_INFO_FILE"); |
196 | 196 |
197 Vinfo_file = oct_info_file.empty () ? std_info_file : oct_info_file; | 197 Vinfo_file = oct_info_file.empty () ? std_info_file : oct_info_file; |
198 } | 198 } |
199 | 199 |
200 static void | 200 static void |
201 set_default_info_prog (void) | 201 set_default_info_prog (void) |
202 { | 202 { |
203 string oct_info_prog = octave_env::getenv ("OCTAVE_INFO_PROGRAM"); | 203 std::string oct_info_prog = octave_env::getenv ("OCTAVE_INFO_PROGRAM"); |
204 | 204 |
205 if (oct_info_prog.empty ()) | 205 if (oct_info_prog.empty ()) |
206 Vinfo_prog = "info"; | 206 Vinfo_prog = "info"; |
207 else | 207 else |
208 Vinfo_prog = string (oct_info_prog); | 208 Vinfo_prog = std::string (oct_info_prog); |
209 } | 209 } |
210 | 210 |
211 static void | 211 static void |
212 set_default_editor (void) | 212 set_default_editor (void) |
213 { | 213 { |
214 Veditor = "emacs"; | 214 Veditor = "emacs"; |
215 | 215 |
216 string env_editor = octave_env::getenv ("EDITOR"); | 216 std::string env_editor = octave_env::getenv ("EDITOR"); |
217 | 217 |
218 if (! env_editor.empty ()) | 218 if (! env_editor.empty ()) |
219 Veditor = env_editor; | 219 Veditor = env_editor; |
220 } | 220 } |
221 | 221 |
232 Vsite_defaults_file = subst_octave_home (OCTAVE_STARTUPFILEDIR); | 232 Vsite_defaults_file = subst_octave_home (OCTAVE_STARTUPFILEDIR); |
233 Vsite_defaults_file.append ("/octaverc"); | 233 Vsite_defaults_file.append ("/octaverc"); |
234 } | 234 } |
235 | 235 |
236 string | 236 string |
237 maybe_add_default_load_path (const string& pathstring) | 237 maybe_add_default_load_path (const std::string& pathstring) |
238 { | 238 { |
239 string retval; | 239 std::string retval; |
240 | 240 |
241 if (! pathstring.empty ()) | 241 if (! pathstring.empty ()) |
242 { | 242 { |
243 if (pathstring[0] == SEPCHAR) | 243 if (pathstring[0] == SEPCHAR) |
244 { | 244 { |
304 static int | 304 static int |
305 editor (void) | 305 editor (void) |
306 { | 306 { |
307 int status = 0; | 307 int status = 0; |
308 | 308 |
309 string s = builtin_string_variable ("EDITOR"); | 309 std::string s = builtin_string_variable ("EDITOR"); |
310 | 310 |
311 if (s.empty ()) | 311 if (s.empty ()) |
312 { | 312 { |
313 gripe_invalid_value_specified ("EDITOR"); | 313 gripe_invalid_value_specified ("EDITOR"); |
314 status = -1; | 314 status = -1; |
322 static int | 322 static int |
323 exec_path (void) | 323 exec_path (void) |
324 { | 324 { |
325 int status = 0; | 325 int status = 0; |
326 | 326 |
327 string s = builtin_string_variable ("EXEC_PATH"); | 327 std::string s = builtin_string_variable ("EXEC_PATH"); |
328 | 328 |
329 if (s.empty ()) | 329 if (s.empty ()) |
330 { | 330 { |
331 gripe_invalid_value_specified ("EXEC_PATH"); | 331 gripe_invalid_value_specified ("EXEC_PATH"); |
332 status = -1; | 332 status = -1; |
333 } | 333 } |
334 else | 334 else |
335 { | 335 { |
336 Vexec_path = s; | 336 Vexec_path = s; |
337 | 337 |
338 string std_path = Vlocal_arch_lib_dir + string (SEPCHAR_STR) | 338 std::string std_path = Vlocal_arch_lib_dir + std::string (SEPCHAR_STR) |
339 + Varch_lib_dir + string (SEPCHAR_STR) + Vbin_dir; | 339 + Varch_lib_dir + std::string (SEPCHAR_STR) + Vbin_dir; |
340 | 340 |
341 string path; | 341 std::string path; |
342 | 342 |
343 int eplen = Vexec_path.length (); | 343 int eplen = Vexec_path.length (); |
344 | 344 |
345 if (eplen > 0) | 345 if (eplen > 0) |
346 { | 346 { |
374 static int | 374 static int |
375 imagepath (void) | 375 imagepath (void) |
376 { | 376 { |
377 int status = 0; | 377 int status = 0; |
378 | 378 |
379 string s = builtin_string_variable ("IMAGEPATH"); | 379 std::string s = builtin_string_variable ("IMAGEPATH"); |
380 | 380 |
381 if (s.empty ()) | 381 if (s.empty ()) |
382 { | 382 { |
383 gripe_invalid_value_specified ("IMAGEPATH"); | 383 gripe_invalid_value_specified ("IMAGEPATH"); |
384 status = -1; | 384 status = -1; |
392 static int | 392 static int |
393 loadpath (void) | 393 loadpath (void) |
394 { | 394 { |
395 int status = 0; | 395 int status = 0; |
396 | 396 |
397 string s = builtin_string_variable ("LOADPATH"); | 397 std::string s = builtin_string_variable ("LOADPATH"); |
398 | 398 |
399 if (s.empty ()) | 399 if (s.empty ()) |
400 { | 400 { |
401 gripe_invalid_value_specified ("LOADPATH"); | 401 gripe_invalid_value_specified ("LOADPATH"); |
402 status = -1; | 402 status = -1; |