5832
|
1 /* |
|
2 |
|
3 Copyright (C) 2006 John W. Eaton |
|
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 |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
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 |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
|
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
20 02110-1301, USA. |
|
21 |
|
22 */ |
|
23 |
|
24 #ifdef HAVE_CONFIG_H |
|
25 #include <config.h> |
|
26 #endif |
|
27 |
|
28 #include <algorithm> |
|
29 |
|
30 #include "dir-ops.h" |
|
31 #include "file-ops.h" |
|
32 #include "file-stat.h" |
|
33 #include "oct-env.h" |
|
34 #include "pathsearch.h" |
|
35 |
|
36 #include "defaults.h" |
|
37 #include "defun.h" |
|
38 #include "input.h" |
|
39 #include "load-path.h" |
|
40 #include "pager.h" |
|
41 #include "parse.h" |
|
42 #include "toplev.h" |
|
43 #include "unwind-prot.h" |
|
44 #include "utils.h" |
|
45 |
|
46 load_path *load_path::instance = 0; |
|
47 load_path::hook_function_ptr load_path::add_hook = execute_pkg_add; |
|
48 load_path::hook_function_ptr load_path::remove_hook = execute_pkg_del; |
|
49 std::string load_path::command_line_path; |
|
50 |
|
51 static std::string Vsystem_path; |
|
52 |
|
53 void |
|
54 load_path::dir_info::update (void) |
|
55 { |
|
56 if (is_relative) |
|
57 initialize (); |
|
58 else |
|
59 { |
|
60 file_stat fs (dir_name); |
|
61 |
|
62 if (fs) |
|
63 { |
|
64 if (fs.mtime () != dir_mtime) |
|
65 initialize (); |
|
66 } |
|
67 else |
|
68 { |
|
69 std::string msg = fs.error (); |
|
70 warning ("load_path: %s: %s", dir_name.c_str (), msg.c_str ()); |
|
71 } |
|
72 } |
|
73 } |
|
74 |
|
75 void |
|
76 load_path::dir_info::initialize (void) |
|
77 { |
|
78 is_relative = ! octave_env::absolute_pathname (dir_name); |
|
79 |
|
80 file_stat fs (dir_name); |
|
81 |
|
82 if (fs) |
|
83 { |
|
84 dir_mtime = fs.mtime (); |
|
85 |
|
86 bool has_private_subdir = get_file_list (dir_name); |
|
87 |
|
88 if (! error_state) |
|
89 { |
|
90 if (has_private_subdir) |
|
91 { |
|
92 std::string pdn = dir_name + file_ops::dir_sep_str + "private"; |
|
93 |
|
94 get_private_function_map (pdn); |
|
95 } |
|
96 } |
|
97 } |
|
98 else |
|
99 { |
|
100 std::string msg = fs.error (); |
|
101 warning ("load_path: %s: %s", dir_name.c_str (), msg.c_str ()); |
|
102 } |
|
103 } |
|
104 |
|
105 bool |
|
106 load_path::dir_info::get_file_list (const std::string& d) |
|
107 { |
|
108 bool has_private_subdir = false; |
|
109 |
|
110 dir_entry dir (d); |
|
111 |
|
112 if (dir) |
|
113 { |
|
114 string_vector flist = dir.read (); |
|
115 |
|
116 octave_idx_type len = flist.length (); |
|
117 |
|
118 all_files.resize (len); |
|
119 fcn_files.resize (len); |
|
120 |
|
121 octave_idx_type all_files_count = 0; |
|
122 octave_idx_type fcn_files_count = 0; |
|
123 |
|
124 for (octave_idx_type i = 0; i < len; i++) |
|
125 { |
|
126 std::string fname = flist[i]; |
|
127 |
|
128 std::string full_name = d + file_ops::dir_sep_str + fname; |
|
129 |
|
130 file_stat fs (full_name); |
|
131 |
|
132 if (fs) |
|
133 { |
|
134 if (fs.is_dir ()) |
|
135 { |
|
136 if (! has_private_subdir && fname == "private") |
|
137 has_private_subdir = true; |
|
138 } |
|
139 else |
|
140 { |
|
141 all_files[all_files_count++] = fname; |
|
142 |
|
143 size_t pos = fname.rfind ('.'); |
|
144 |
|
145 if (pos != NPOS) |
|
146 { |
|
147 std::string ext = fname.substr (pos); |
|
148 |
5864
|
149 if (ext == ".m" || ext == ".oct" || ext == ".mex") |
5832
|
150 { |
|
151 std::string base = fname.substr (0, pos); |
|
152 |
|
153 if (valid_identifier (base)) |
|
154 fcn_files[fcn_files_count++] = fname; |
|
155 } |
|
156 } |
|
157 } |
|
158 } |
|
159 } |
|
160 |
|
161 all_files.resize (all_files_count); |
|
162 fcn_files.resize (fcn_files_count); |
|
163 } |
|
164 else |
|
165 { |
|
166 std::string msg = dir.error (); |
|
167 warning ("load_path: %s: %s", d.c_str (), msg.c_str ()); |
|
168 } |
|
169 |
|
170 return has_private_subdir; |
|
171 } |
|
172 |
|
173 void |
|
174 load_path::dir_info::get_private_function_map (const std::string& d) |
|
175 { |
|
176 dir_entry dir (d); |
|
177 |
|
178 if (dir) |
|
179 { |
|
180 string_vector flist = dir.read (); |
|
181 |
|
182 octave_idx_type len = flist.length (); |
|
183 |
|
184 for (octave_idx_type i = 0; i < len; i++) |
|
185 { |
|
186 std::string fname = flist[i]; |
|
187 |
|
188 std::string ext; |
|
189 std::string base = fname; |
|
190 |
|
191 size_t pos = fname.rfind ('.'); |
|
192 |
|
193 if (pos != NPOS) |
|
194 { |
|
195 base = fname.substr (0, pos); |
|
196 ext = fname.substr (pos); |
|
197 |
|
198 if (valid_identifier (base)) |
|
199 { |
|
200 int t = 0; |
|
201 |
|
202 if (ext == ".m") |
|
203 t = load_path::M_FILE; |
|
204 else if (ext == ".oct") |
|
205 t = load_path::OCT_FILE; |
5864
|
206 else if (ext == ".mex") |
|
207 t = load_path::MEX_FILE; |
5832
|
208 |
|
209 private_function_map[base] |= t; |
|
210 } |
|
211 } |
|
212 } |
|
213 } |
|
214 else |
|
215 { |
|
216 std::string msg = dir.error (); |
|
217 warning ("load_path: %s: %s", d.c_str (), msg.c_str ()); |
|
218 } |
|
219 } |
|
220 |
|
221 bool |
|
222 load_path::instance_ok (void) |
|
223 { |
|
224 bool retval = true; |
|
225 |
|
226 if (! instance) |
|
227 instance = new load_path (); |
|
228 |
|
229 if (! instance) |
|
230 { |
|
231 ::error ("unable to create load path object!"); |
|
232 |
|
233 retval = false; |
|
234 } |
|
235 |
|
236 return retval; |
|
237 } |
|
238 |
|
239 load_path::const_dir_info_list_iterator |
|
240 load_path::find_dir_info (const std::string& dir) const |
|
241 { |
|
242 const_dir_info_list_iterator retval = dir_info_list.begin (); |
|
243 |
|
244 while (retval != dir_info_list.end ()) |
|
245 { |
|
246 if (retval->dir_name == dir) |
|
247 break; |
|
248 |
|
249 retval++; |
|
250 } |
|
251 |
|
252 return retval; |
|
253 } |
|
254 |
|
255 load_path::dir_info_list_iterator |
|
256 load_path::find_dir_info (const std::string& dir) |
|
257 { |
|
258 dir_info_list_iterator retval = dir_info_list.begin (); |
|
259 |
|
260 while (retval != dir_info_list.end ()) |
|
261 { |
|
262 if (retval->dir_name == dir) |
|
263 break; |
|
264 |
|
265 retval++; |
|
266 } |
|
267 |
|
268 return retval; |
|
269 } |
|
270 |
|
271 bool |
|
272 load_path::contains (const std::string& dir) const |
|
273 { |
|
274 return find_dir_info (dir) != dir_info_list.end (); |
|
275 } |
|
276 |
|
277 void |
|
278 load_path::move (dir_info_list_iterator i, bool at_end) |
|
279 { |
|
280 if (dir_info_list.size () > 1) |
|
281 { |
|
282 dir_info di = *i; |
|
283 |
|
284 dir_info_list.erase (i); |
|
285 |
|
286 if (at_end) |
|
287 dir_info_list.push_back (di); |
|
288 else |
|
289 dir_info_list.push_front (di); |
|
290 |
|
291 std::string dir = di.dir_name; |
|
292 |
|
293 string_vector fcn_files = di.fcn_files; |
|
294 |
|
295 octave_idx_type len = fcn_files.length (); |
|
296 |
|
297 for (octave_idx_type k = 0; k < len; k++) |
|
298 { |
|
299 std::string fname = fcn_files[k]; |
|
300 |
|
301 std::string ext; |
|
302 std::string base = fname; |
|
303 |
|
304 size_t pos = fname.rfind ('.'); |
|
305 |
|
306 if (pos != NPOS) |
|
307 { |
|
308 base = fname.substr (0, pos); |
|
309 ext = fname.substr (pos); |
|
310 } |
|
311 |
|
312 std::list<file_info>& file_info_list = fcn_map[base]; |
|
313 |
|
314 if (file_info_list.size () == 1) |
|
315 continue; |
|
316 else |
|
317 { |
|
318 for (std::list<file_info>::iterator p = file_info_list.begin (); |
|
319 p != file_info_list.end (); |
|
320 p++) |
|
321 { |
|
322 if (p->dir_name == dir) |
|
323 { |
|
324 file_info& fi = *p; |
|
325 |
|
326 file_info_list.erase (p); |
|
327 |
|
328 if (at_end) |
|
329 file_info_list.push_back (fi); |
|
330 else |
|
331 file_info_list.push_front (fi); |
|
332 |
|
333 break; |
|
334 } |
|
335 } |
|
336 } |
|
337 } |
|
338 } |
|
339 } |
|
340 |
|
341 static void |
|
342 maybe_add_path_elts (std::string& path, const std::string& dir) |
|
343 { |
|
344 std::string tpath = genpath (dir); |
|
345 |
|
346 if (! tpath.empty ()) |
|
347 path += dir_path::path_sep_str + tpath; |
|
348 } |
|
349 |
|
350 void |
|
351 load_path::do_initialize (void) |
|
352 { |
|
353 Vsystem_path = ":"; |
|
354 |
|
355 maybe_add_path_elts (Vsystem_path, Vlocal_ver_oct_file_dir); |
|
356 maybe_add_path_elts (Vsystem_path, Vlocal_api_oct_file_dir); |
|
357 maybe_add_path_elts (Vsystem_path, Vlocal_oct_file_dir); |
|
358 maybe_add_path_elts (Vsystem_path, Vlocal_ver_fcn_file_dir); |
|
359 maybe_add_path_elts (Vsystem_path, Vlocal_api_fcn_file_dir); |
|
360 maybe_add_path_elts (Vsystem_path, Vlocal_fcn_file_dir); |
|
361 maybe_add_path_elts (Vsystem_path, Voct_file_dir); |
|
362 maybe_add_path_elts (Vsystem_path, Vfcn_file_dir); |
|
363 |
|
364 std::string tpath = load_path::command_line_path; |
|
365 |
|
366 if (tpath.empty ()) |
|
367 tpath = octave_env::getenv ("OCTAVE_LOADPATH"); |
|
368 |
|
369 std::string xpath = "."; |
|
370 |
|
371 if (! tpath.empty ()) |
|
372 xpath += dir_path::path_sep_str + tpath; |
|
373 |
|
374 if (Vsystem_path != ":") |
|
375 xpath += Vsystem_path; |
|
376 |
5867
|
377 do_set (xpath + ":::", false); |
5832
|
378 } |
|
379 |
|
380 void |
|
381 load_path::do_clear (void) |
|
382 { |
|
383 dir_info_list.clear (); |
|
384 fcn_map.clear (); |
5867
|
385 |
|
386 do_append (".", false); |
5832
|
387 } |
|
388 |
|
389 static std::list<std::string> |
|
390 split_path (const std::string& p) |
|
391 { |
|
392 std::list<std::string> retval; |
|
393 |
|
394 size_t beg = 0; |
|
395 size_t end = p.find (dir_path::path_sep_char); |
|
396 |
|
397 size_t len = p.length (); |
|
398 |
|
399 while (end != NPOS) |
|
400 { |
|
401 std::string elt = p.substr (beg, end-beg); |
|
402 |
|
403 if (! elt.empty ()) |
|
404 retval.push_back (elt); |
|
405 |
|
406 beg = end + 1; |
|
407 |
|
408 if (beg == len) |
|
409 break; |
|
410 |
|
411 end = p.find (dir_path::path_sep_char, beg); |
|
412 } |
|
413 |
|
414 std::string elt = p.substr (beg); |
|
415 |
|
416 if (! elt.empty ()) |
|
417 retval.push_back (elt); |
|
418 |
|
419 return retval; |
|
420 } |
|
421 |
|
422 void |
5867
|
423 load_path::do_set (const std::string& p, bool warn) |
5832
|
424 { |
|
425 do_clear (); |
|
426 |
|
427 std::list<std::string> elts = split_path (p); |
|
428 |
|
429 // Temporarily disable add hook. |
|
430 |
5854
|
431 unwind_protect_fptr (add_hook); |
5832
|
432 |
|
433 add_hook = 0; |
|
434 |
|
435 for (std::list<std::string>::const_iterator i = elts.begin (); |
|
436 i != elts.end (); |
|
437 i++) |
5867
|
438 do_append (*i, warn); |
5832
|
439 |
|
440 // Restore add hook and execute for all newly added directories. |
|
441 |
|
442 unwind_protect::run (); |
|
443 |
|
444 for (dir_info_list_iterator i = dir_info_list.begin (); |
|
445 i != dir_info_list.end (); |
|
446 i++) |
|
447 { |
|
448 if (add_hook) |
|
449 add_hook (i->dir_name); |
|
450 } |
|
451 } |
|
452 |
|
453 void |
5867
|
454 load_path::do_append (const std::string& dir, bool warn) |
5832
|
455 { |
|
456 if (! dir.empty ()) |
5867
|
457 do_add (dir, true, warn); |
|
458 } |
5832
|
459 |
5867
|
460 void |
|
461 load_path::do_prepend (const std::string& dir, bool warn) |
|
462 { |
|
463 if (! dir.empty ()) |
|
464 do_add (dir, false, warn); |
5832
|
465 } |
|
466 |
|
467 void |
5867
|
468 load_path::do_add (const std::string& dir, bool at_end, bool warn) |
5832
|
469 { |
5911
|
470 size_t len = dir.length (); |
|
471 |
|
472 if (len > 1 && dir.substr (len-2) == "//") |
|
473 warning_with_id ("Octave:recursive-path-search", |
|
474 "trailing `//' is no longer special in search path elements"); |
|
475 |
5867
|
476 dir_info_list_iterator i = find_dir_info (dir); |
|
477 |
|
478 if (i != dir_info_list.end ()) |
|
479 move (i, at_end); |
|
480 else |
5832
|
481 { |
5867
|
482 file_stat fs (dir); |
5832
|
483 |
5867
|
484 if (fs) |
5832
|
485 { |
5867
|
486 if (fs.is_dir ()) |
|
487 { |
|
488 dir_info di (dir); |
5832
|
489 |
5867
|
490 if (! error_state) |
|
491 { |
|
492 if (at_end) |
|
493 dir_info_list.push_back (di); |
|
494 else |
|
495 dir_info_list.push_front (di); |
|
496 |
|
497 add_to_fcn_map (di, true); |
5832
|
498 |
5867
|
499 if (add_hook) |
|
500 add_hook (dir); |
|
501 } |
5832
|
502 } |
5867
|
503 else if (warn) |
|
504 warning ("addpath: %s: not a directory", dir.c_str ()); |
5832
|
505 } |
5867
|
506 else if (warn) |
|
507 { |
|
508 std::string msg = fs.error (); |
|
509 warning ("addpath: %s: %s", dir.c_str (), msg.c_str ()); |
|
510 } |
|
511 } |
5832
|
512 |
5867
|
513 // FIXME -- is there a better way to do this? |
5832
|
514 |
5867
|
515 i = find_dir_info ("."); |
5832
|
516 |
5867
|
517 if (i != dir_info_list.end ()) |
5871
|
518 move (i, false); |
5867
|
519 else |
|
520 panic_impossible (); |
5832
|
521 } |
|
522 |
|
523 bool |
|
524 load_path::do_remove (const std::string& dir) |
|
525 { |
|
526 bool retval = false; |
|
527 |
|
528 if (! dir.empty ()) |
|
529 { |
|
530 if (dir == ".") |
5867
|
531 { |
|
532 warning ("rmpath: can't remove \".\" from path"); |
5832
|
533 |
5867
|
534 // Avoid additional warnings. |
5832
|
535 retval = true; |
5867
|
536 } |
|
537 else |
|
538 { |
|
539 dir_info_list_iterator i = find_dir_info (dir); |
5832
|
540 |
5867
|
541 if (i != dir_info_list.end ()) |
|
542 { |
|
543 retval = true; |
5832
|
544 |
5867
|
545 string_vector fcn_files = i->fcn_files; |
|
546 |
|
547 dir_info_list.erase (i); |
5832
|
548 |
5867
|
549 octave_idx_type len = fcn_files.length (); |
|
550 |
|
551 for (octave_idx_type k = 0; k < len; k++) |
|
552 { |
|
553 std::string fname = fcn_files[k]; |
5832
|
554 |
5867
|
555 std::string ext; |
|
556 std::string base = fname; |
|
557 |
|
558 size_t pos = fname.rfind ('.'); |
5832
|
559 |
5867
|
560 if (pos != NPOS) |
|
561 { |
|
562 base = fname.substr (0, pos); |
|
563 ext = fname.substr (pos); |
|
564 } |
|
565 |
|
566 std::list<file_info>& file_info_list = fcn_map[base]; |
5832
|
567 |
5867
|
568 for (std::list<file_info>::iterator p = file_info_list.begin (); |
|
569 p != file_info_list.end (); |
|
570 p++) |
|
571 { |
|
572 if (p->dir_name == dir) |
|
573 { |
|
574 file_info_list.erase (p); |
5832
|
575 |
5867
|
576 if (file_info_list.empty ()) |
|
577 fcn_map.erase (fname); |
|
578 |
|
579 break; |
|
580 } |
|
581 } |
5832
|
582 } |
|
583 |
5867
|
584 if (remove_hook) |
|
585 remove_hook (dir); |
5832
|
586 } |
|
587 } |
|
588 } |
|
589 |
|
590 return retval; |
|
591 } |
|
592 |
|
593 void |
|
594 load_path::do_update (void) const |
|
595 { |
|
596 // I don't see a better way to do this because we need to |
|
597 // preserve the correct directory ordering for new files that |
|
598 // have appeared. |
|
599 |
|
600 fcn_map.clear (); |
|
601 |
|
602 for (dir_info_list_iterator p = dir_info_list.begin (); |
|
603 p != dir_info_list.end (); |
|
604 p++) |
|
605 { |
|
606 dir_info& di = *p; |
|
607 |
|
608 di.update (); |
|
609 |
|
610 add_to_fcn_map (di, true); |
|
611 } |
|
612 } |
|
613 |
|
614 std::string |
|
615 load_path::do_find_fcn (const std::string& fcn, int type) const |
|
616 { |
|
617 std::string retval; |
|
618 |
|
619 update (); |
|
620 |
|
621 const_fcn_map_iterator p = fcn_map.find (fcn); |
|
622 |
|
623 if (p != fcn_map.end ()) |
|
624 { |
|
625 const std::list<file_info>& file_info_list = p->second; |
|
626 |
|
627 for (const_file_info_list_iterator i = file_info_list.begin (); |
|
628 i != file_info_list.end (); |
|
629 i++) |
|
630 { |
|
631 const file_info& fi = *i; |
|
632 |
|
633 int t = fi.types; |
|
634 |
|
635 retval = fi.dir_name + file_ops::dir_sep_str + fcn; |
|
636 |
|
637 if (type == load_path::OCT_FILE) |
|
638 { |
|
639 if ((type & t) == load_path::OCT_FILE) |
|
640 { |
|
641 retval += ".oct"; |
|
642 break; |
|
643 } |
|
644 } |
|
645 else if (type == load_path::M_FILE) |
|
646 { |
|
647 if ((type & t) == load_path::M_FILE) |
|
648 { |
|
649 retval += ".m"; |
|
650 break; |
|
651 } |
|
652 } |
5864
|
653 else if (type == load_path::MEX_FILE) |
|
654 { |
|
655 if ((type & t) == load_path::MEX_FILE) |
|
656 { |
|
657 retval += ".mex"; |
|
658 break; |
|
659 } |
|
660 } |
5832
|
661 else if (type == (load_path::M_FILE | load_path::OCT_FILE)) |
|
662 { |
|
663 if (t & load_path::OCT_FILE) |
|
664 { |
|
665 retval += ".oct"; |
|
666 break; |
|
667 } |
|
668 else if (t & load_path::M_FILE) |
|
669 { |
|
670 retval += ".m"; |
|
671 break; |
|
672 } |
|
673 } |
5864
|
674 else if (type == (load_path::M_FILE | load_path::MEX_FILE)) |
|
675 { |
|
676 if (t & load_path::MEX_FILE) |
|
677 { |
|
678 retval += ".mex"; |
|
679 break; |
|
680 } |
|
681 else if (t & load_path::M_FILE) |
|
682 { |
|
683 retval += ".m"; |
|
684 break; |
|
685 } |
|
686 } |
|
687 else if (type == (load_path::OCT_FILE | load_path::MEX_FILE)) |
|
688 { |
|
689 if (t & load_path::OCT_FILE) |
|
690 { |
|
691 retval += ".oct"; |
|
692 break; |
|
693 } |
|
694 else if (t & load_path::MEX_FILE) |
|
695 { |
|
696 retval += ".mex"; |
|
697 break; |
|
698 } |
|
699 } |
|
700 else if (type == (load_path::M_FILE | load_path::OCT_FILE |
|
701 | load_path::MEX_FILE)) |
|
702 { |
|
703 if (t & load_path::OCT_FILE) |
|
704 { |
|
705 retval += ".oct"; |
|
706 break; |
|
707 } |
|
708 else if (t & load_path::MEX_FILE) |
|
709 { |
|
710 retval += ".mex"; |
|
711 break; |
|
712 } |
|
713 else if (t & load_path::M_FILE) |
|
714 { |
|
715 retval += ".m"; |
|
716 break; |
|
717 } |
|
718 } |
5832
|
719 else |
|
720 error ("load_path::do_find_fcn: %s: invalid type code = %d", |
|
721 fcn.c_str (), type); |
|
722 } |
|
723 } |
|
724 |
|
725 return retval; |
|
726 } |
|
727 |
|
728 std::string |
|
729 load_path::do_find_file (const std::string& file) const |
|
730 { |
|
731 std::string retval; |
|
732 |
|
733 if (octave_env::absolute_pathname (file)) |
|
734 { |
|
735 file_stat fs (file); |
|
736 |
|
737 if (fs.exists ()) |
|
738 return file; |
|
739 } |
|
740 |
|
741 std::string dir_name; |
|
742 |
|
743 for (const_dir_info_list_iterator p = dir_info_list.begin (); |
|
744 p != dir_info_list.end (); |
|
745 p++) |
|
746 { |
|
747 string_vector all_files = p->all_files; |
|
748 |
|
749 octave_idx_type len = all_files.length (); |
|
750 |
|
751 for (octave_idx_type i = 0; i < len; i++) |
|
752 { |
|
753 if (all_files[i] == file) |
|
754 { |
|
755 dir_name = p->dir_name; |
|
756 break; |
|
757 } |
|
758 } |
|
759 } |
|
760 |
|
761 if (! dir_name.empty ()) |
|
762 retval = dir_name + file_ops::dir_sep_str + file; |
|
763 |
|
764 return retval; |
|
765 } |
|
766 |
|
767 std::string |
|
768 load_path::do_find_first_of (const string_vector& flist) const |
|
769 { |
|
770 std::string retval; |
|
771 |
|
772 std::string dir_name; |
|
773 std::string file_name; |
|
774 |
|
775 octave_idx_type flen = flist.length (); |
|
776 octave_idx_type rel_flen = 0; |
|
777 |
|
778 string_vector rel_flist (flen); |
|
779 |
|
780 for (octave_idx_type i = 0; i < flen; i++) |
|
781 { |
|
782 if (octave_env::absolute_pathname (flist[i])) |
|
783 { |
|
784 file_stat fs (flist[i]); |
|
785 |
|
786 if (fs.exists ()) |
|
787 return flist[i]; |
|
788 } |
|
789 else |
|
790 rel_flist[rel_flen++] = flist[i]; |
|
791 } |
|
792 |
|
793 rel_flist.resize (rel_flen); |
|
794 |
|
795 for (const_dir_info_list_iterator p = dir_info_list.begin (); |
|
796 p != dir_info_list.end (); |
|
797 p++) |
|
798 { |
|
799 string_vector all_files = p->all_files; |
|
800 |
|
801 octave_idx_type len = all_files.length (); |
|
802 |
|
803 for (octave_idx_type i = 0; i < len; i++) |
|
804 { |
|
805 |
|
806 for (octave_idx_type j = 0; j < rel_flen; j++) |
|
807 { |
|
808 if (all_files[i] == rel_flist[j]) |
|
809 { |
|
810 dir_name = p->dir_name; |
|
811 file_name = rel_flist[j]; |
|
812 break; |
|
813 } |
|
814 } |
|
815 } |
|
816 } |
|
817 |
|
818 if (! dir_name.empty ()) |
|
819 retval = dir_name + file_ops::dir_sep_str + file_name; |
|
820 |
|
821 return retval; |
|
822 } |
|
823 |
|
824 string_vector |
|
825 load_path::do_find_all_first_of (const string_vector& flist) const |
|
826 { |
|
827 std::list<std::string> retlist; |
|
828 |
|
829 std::string dir_name; |
|
830 std::string file_name; |
|
831 |
|
832 octave_idx_type flen = flist.length (); |
|
833 octave_idx_type rel_flen = 0; |
|
834 |
|
835 string_vector rel_flist (flen); |
|
836 |
|
837 for (octave_idx_type i = 0; i < flen; i++) |
|
838 { |
|
839 if (octave_env::absolute_pathname (flist[i])) |
|
840 { |
|
841 file_stat fs (flist[i]); |
|
842 |
|
843 if (fs.exists ()) |
|
844 retlist.push_back (flist[i]); |
|
845 } |
|
846 else |
|
847 rel_flist[rel_flen++] = flist[i]; |
|
848 } |
|
849 |
|
850 rel_flist.resize (rel_flen); |
|
851 |
|
852 for (const_dir_info_list_iterator p = dir_info_list.begin (); |
|
853 p != dir_info_list.end (); |
|
854 p++) |
|
855 { |
|
856 string_vector all_files = p->all_files; |
|
857 |
|
858 octave_idx_type len = all_files.length (); |
|
859 |
|
860 for (octave_idx_type i = 0; i < len; i++) |
|
861 { |
|
862 for (octave_idx_type j = 0; j < rel_flen; j++) |
|
863 { |
|
864 if (all_files[i] == rel_flist[j]) |
|
865 retlist.push_back |
|
866 (p->dir_name + file_ops::dir_sep_str + rel_flist[j]); |
|
867 } |
|
868 } |
|
869 } |
|
870 |
|
871 size_t retsize = retlist.size (); |
|
872 |
|
873 string_vector retval (retsize); |
|
874 |
|
875 for (size_t i = 0; i < retsize; i++) |
|
876 { |
|
877 retval[i] = retlist.front (); |
|
878 |
|
879 retlist.pop_front (); |
|
880 } |
|
881 |
|
882 return retval; |
|
883 } |
|
884 |
|
885 string_vector |
|
886 load_path::do_dirs (void) const |
|
887 { |
|
888 size_t len = dir_info_list.size (); |
|
889 |
|
890 string_vector retval (len); |
|
891 |
|
892 octave_idx_type k = 0; |
|
893 |
|
894 for (const_dir_info_list_iterator i = dir_info_list.begin (); |
|
895 i != dir_info_list.end (); |
|
896 i++) |
|
897 retval[k++] = i->dir_name; |
|
898 |
|
899 return retval; |
|
900 } |
|
901 |
|
902 std::list<std::string> |
|
903 load_path::do_dir_list (void) const |
|
904 { |
|
905 std::list<std::string> retval; |
|
906 |
|
907 for (const_dir_info_list_iterator i = dir_info_list.begin (); |
|
908 i != dir_info_list.end (); |
|
909 i++) |
|
910 retval.push_back (i->dir_name); |
|
911 |
|
912 return retval; |
|
913 } |
|
914 |
|
915 string_vector |
|
916 load_path::do_files (const std::string& dir) const |
|
917 { |
|
918 string_vector retval; |
|
919 |
|
920 const_dir_info_list_iterator i = find_dir_info (dir); |
|
921 |
|
922 if (i != dir_info_list.end ()) |
|
923 retval = i->fcn_files; |
|
924 |
|
925 return retval; |
|
926 } |
|
927 |
|
928 string_vector |
|
929 load_path::do_fcn_names (void) const |
|
930 { |
|
931 size_t len = fcn_map.size (); |
|
932 |
|
933 string_vector retval (len); |
|
934 |
|
935 octave_idx_type count = 0; |
|
936 |
|
937 for (const_fcn_map_iterator p = fcn_map.begin (); |
|
938 p != fcn_map.end (); |
|
939 p++) |
|
940 retval[count++] = p->first; |
|
941 |
|
942 return retval; |
|
943 } |
|
944 |
|
945 std::string |
|
946 load_path::do_path (void) const |
|
947 { |
|
948 std::string xpath; |
|
949 |
|
950 string_vector xdirs = load_path::dirs (); |
|
951 |
|
952 octave_idx_type len = xdirs.length (); |
|
953 |
|
954 if (len > 0) |
|
955 xpath = xdirs[0]; |
|
956 |
|
957 for (octave_idx_type i = 1; i < len; i++) |
|
958 xpath += dir_path::path_sep_str + xdirs[i]; |
|
959 |
|
960 return xpath; |
|
961 } |
|
962 |
|
963 void |
|
964 load_path::do_display (std::ostream& os) const |
|
965 { |
|
966 for (const_dir_info_list_iterator i = dir_info_list.begin (); |
|
967 i != dir_info_list.end (); |
|
968 i++) |
|
969 { |
|
970 string_vector fcn_files = i->fcn_files; |
|
971 |
|
972 if (! fcn_files.empty ()) |
|
973 { |
|
974 os << "\n*** function files in " << i->dir_name << ":\n\n"; |
|
975 |
|
976 fcn_files.list_in_columns (os); |
|
977 } |
|
978 |
|
979 #if defined (DEBUG_LOAD_PATH) |
|
980 |
|
981 const std::map<std::string, int>& private_function_map |
|
982 = i->private_function_map; |
|
983 |
|
984 if (private_function_map.size () > 0) |
|
985 { |
|
986 os << "private:\n"; |
|
987 |
|
988 for (std::map<std::string, int>::const_iterator p = private_function_map.begin (); |
|
989 p != private_function_map.end (); |
|
990 p++) |
|
991 { |
|
992 os << " " << p->first << " ("; |
|
993 |
|
994 bool printed_type = false; |
|
995 |
|
996 int types = p->second; |
|
997 |
|
998 if (types & load_path::OCT_FILE) |
|
999 { |
|
1000 os << "oct"; |
|
1001 printed_type = true; |
|
1002 } |
|
1003 |
5864
|
1004 if (types & load_path::MEX_FILE) |
|
1005 { |
|
1006 if (printed_type) |
|
1007 os << "|"; |
|
1008 os << "mex"; |
|
1009 printed_type = true; |
|
1010 } |
|
1011 |
5832
|
1012 if (types & load_path::M_FILE) |
|
1013 { |
|
1014 if (printed_type) |
|
1015 os << "|"; |
|
1016 os << "m"; |
|
1017 printed_type = true; |
|
1018 } |
|
1019 |
|
1020 os << ")\n"; |
|
1021 } |
|
1022 |
|
1023 os << "\n"; |
|
1024 } |
|
1025 #endif |
|
1026 } |
|
1027 |
|
1028 #if defined (DEBUG_LOAD_PATH) |
|
1029 |
|
1030 for (const_fcn_map_iterator i = fcn_map.begin (); |
|
1031 i != fcn_map.end (); |
|
1032 i++) |
|
1033 { |
|
1034 os << i->first << ":\n"; |
|
1035 |
|
1036 const std::list<file_info>& file_info_list = i->second; |
|
1037 |
|
1038 for (const_file_info_list_iterator p = file_info_list.begin (); |
|
1039 p != file_info_list.end (); |
|
1040 p++) |
|
1041 { |
|
1042 os << " " << p->dir_name << " ("; |
|
1043 |
|
1044 bool printed_type = false; |
|
1045 |
|
1046 if (p->types & load_path::OCT_FILE) |
|
1047 { |
|
1048 os << "oct"; |
|
1049 printed_type = true; |
|
1050 } |
|
1051 |
5864
|
1052 if (p->types & load_path::MEX_FILE) |
|
1053 { |
|
1054 if (printed_type) |
|
1055 os << "|"; |
|
1056 os << "mex"; |
|
1057 printed_type = true; |
|
1058 } |
|
1059 |
5832
|
1060 if (p->types & load_path::M_FILE) |
|
1061 { |
|
1062 if (printed_type) |
|
1063 os << "|"; |
|
1064 os << "m"; |
|
1065 printed_type = true; |
|
1066 } |
|
1067 |
|
1068 os << ")\n"; |
|
1069 } |
|
1070 } |
|
1071 |
|
1072 os << "\n"; |
|
1073 |
|
1074 #endif |
|
1075 } |
|
1076 |
|
1077 void |
|
1078 load_path::add_to_fcn_map (const dir_info& di, bool at_end) const |
|
1079 { |
|
1080 std::string dir_name = di.dir_name; |
|
1081 |
|
1082 string_vector fcn_files = di.fcn_files; |
|
1083 |
|
1084 octave_idx_type len = fcn_files.length (); |
|
1085 |
|
1086 for (octave_idx_type i = 0; i < len; i++) |
|
1087 { |
|
1088 std::string fname = fcn_files[i]; |
|
1089 |
|
1090 std::string ext; |
|
1091 std::string base = fname; |
|
1092 |
|
1093 size_t pos = fname.rfind ('.'); |
|
1094 |
|
1095 if (pos != NPOS) |
|
1096 { |
|
1097 base = fname.substr (0, pos); |
|
1098 ext = fname.substr (pos); |
|
1099 } |
|
1100 |
|
1101 std::list<file_info>& file_info_list = fcn_map[base]; |
|
1102 |
|
1103 file_info_list_iterator p = file_info_list.begin (); |
|
1104 |
|
1105 while (p != file_info_list.end ()) |
|
1106 { |
|
1107 if (p->dir_name == dir_name) |
|
1108 break; |
|
1109 |
|
1110 p++; |
|
1111 } |
|
1112 |
|
1113 int t = 0; |
|
1114 if (ext == ".m") |
|
1115 t = load_path::M_FILE; |
|
1116 else if (ext == ".oct") |
|
1117 t = load_path::OCT_FILE; |
5864
|
1118 else if (ext == ".mex") |
|
1119 t = load_path::MEX_FILE; |
5832
|
1120 |
|
1121 if (p == file_info_list.end ()) |
|
1122 { |
|
1123 file_info fi (dir_name, t); |
|
1124 |
|
1125 if (at_end) |
|
1126 file_info_list.push_back (fi); |
|
1127 else |
|
1128 file_info_list.push_front (fi); |
|
1129 } |
|
1130 else |
|
1131 { |
|
1132 file_info& fi = *p; |
|
1133 |
|
1134 fi.types |= t; |
|
1135 } |
|
1136 } |
|
1137 } |
|
1138 |
|
1139 std::string |
|
1140 genpath (const std::string& dirname, const string_vector& skip) |
|
1141 { |
|
1142 std::string retval; |
|
1143 |
5871
|
1144 dir_entry dir (dirname); |
5832
|
1145 |
|
1146 if (dir) |
|
1147 { |
|
1148 retval = dirname; |
|
1149 |
|
1150 string_vector dirlist = dir.read (); |
|
1151 |
|
1152 octave_idx_type len = dirlist.length (); |
|
1153 |
|
1154 for (octave_idx_type i = 0; i < len; i++) |
|
1155 { |
|
1156 std::string elt = dirlist[i]; |
|
1157 |
|
1158 // FIXME -- the caller should be able to specify the list of |
|
1159 // directories to skip in addition to "." and "..". |
|
1160 |
|
1161 bool skip_p = (elt == "." || elt == ".."); |
|
1162 |
|
1163 if (! skip_p) |
|
1164 { |
|
1165 for (octave_idx_type j = 0; j < skip.length (); j++) |
|
1166 { |
|
1167 skip_p = (elt == skip[j]); |
|
1168 if (skip_p) |
|
1169 break; |
|
1170 } |
|
1171 |
|
1172 if (! skip_p) |
|
1173 { |
5871
|
1174 std::string nm = dirname + file_ops::dir_sep_str + elt; |
5832
|
1175 |
|
1176 file_stat fs (nm); |
|
1177 |
|
1178 if (fs && fs.is_dir ()) |
|
1179 retval += dir_path::path_sep_str + genpath (nm); |
|
1180 } |
|
1181 } |
|
1182 } |
|
1183 } |
|
1184 |
|
1185 return retval; |
|
1186 } |
|
1187 |
|
1188 static void |
|
1189 execute_pkg_add_or_del (const std::string& dir, |
|
1190 const std::string& script_file) |
|
1191 { |
|
1192 if (! octave_interpreter_ready) |
|
1193 return; |
|
1194 |
|
1195 unwind_protect::begin_frame ("execute_pkg_add_or_del"); |
|
1196 |
|
1197 unwind_protect_bool (input_from_startup_file); |
|
1198 |
|
1199 input_from_startup_file = true; |
|
1200 |
|
1201 std::string file = dir + file_ops::dir_sep_str + script_file; |
|
1202 |
|
1203 file_stat fs = file_stat (file); |
|
1204 |
|
1205 if (fs.exists ()) |
|
1206 source_file (file); |
|
1207 |
|
1208 unwind_protect::run_frame ("execute_pkg_add_or_del"); |
|
1209 } |
|
1210 |
|
1211 void |
|
1212 execute_pkg_add (const std::string& dir) |
|
1213 { |
|
1214 execute_pkg_add_or_del (dir, "PKG_ADD"); |
|
1215 } |
|
1216 |
|
1217 void |
|
1218 execute_pkg_del (const std::string& dir) |
|
1219 { |
|
1220 execute_pkg_add_or_del (dir, "PKG_DEL"); |
|
1221 } |
|
1222 |
|
1223 DEFUN (genpath, args, , |
|
1224 "-*- texinfo -*-\n\ |
|
1225 @deftypefn {Built-in Function} {} genpath (@var{dir})\n\ |
|
1226 Return a path constructed from @var{dir} and all its subdiretories.\n\ |
|
1227 @end deftypefn") |
|
1228 { |
|
1229 octave_value retval; |
|
1230 |
|
1231 if (args.length () == 1) |
|
1232 { |
|
1233 std::string dirname = args(0).string_value (); |
|
1234 |
|
1235 if (! error_state) |
|
1236 retval = genpath (dirname); |
|
1237 else |
|
1238 error ("genpath: expecting argument to be a character string"); |
|
1239 } |
|
1240 else |
|
1241 print_usage (); |
|
1242 |
|
1243 return retval; |
|
1244 } |
|
1245 |
|
1246 DEFUN (rehash, , , |
|
1247 "-*- texinfo -*-\n\ |
|
1248 @deftypefn {Built-in Function} {} rehash ()\n\ |
|
1249 Reinitialize Octave's @code{LOADPATH} directory cache.\n\ |
|
1250 @end deftypefn") |
|
1251 { |
|
1252 octave_value_list retval; |
|
1253 |
|
1254 load_path::update (); |
|
1255 |
|
1256 // FIXME -- maybe we should rename this variable since it is being |
|
1257 // used for more than keeping track of the prompt time. |
|
1258 |
|
1259 // This will force updated functions to be found. |
|
1260 Vlast_prompt_time.stamp (); |
|
1261 |
|
1262 return retval; |
|
1263 } |
|
1264 |
|
1265 DEFUN (pathdef, , , |
|
1266 "-*- texinfo -*-\n\ |
|
1267 @deftypefn {Built-in Function} {@var{val} =} pathdef ()\n\ |
|
1268 Return the default list of directories in which to search for function\n\ |
|
1269 files.\n\ |
|
1270 @seealso{path, addpath, rmpath, genpath, savepath, pathsep}\n\ |
|
1271 @end deftypefn") |
|
1272 { |
|
1273 return octave_value (Vsystem_path); |
|
1274 } |
|
1275 |
|
1276 DEFUN (path, args, nargout, |
|
1277 "-*- texinfo -*-\n\ |
|
1278 @deftypefn {Function File} {} path (@dots{})\n\ |
|
1279 Modify or display Octave's @code{LOADPATH}.\n\ |
|
1280 \n\ |
|
1281 If @var{nargin} and @var{nargout} are zero, display the elements of\n\ |
|
1282 Octave's @code{LOADPATH} in an easy to read format.\n\ |
|
1283 \n\ |
|
1284 If @var{nargin} is zero and nargout is greater than zero, return the\n\ |
|
1285 current value of @code{LOADPATH}.\n\ |
|
1286 \n\ |
|
1287 If @var{nargin} is greater than zero, concatenate the arguments,\n\ |
|
1288 separating them with @code{pathsep()}. Set the internal search path\n\ |
|
1289 to the result and return it.\n\ |
|
1290 \n\ |
|
1291 No checks are made for duplicate elements.\n\ |
|
1292 @seealso{addpath, rmpath, genpath, pathdef, savepath, pathsep}\n\ |
|
1293 @end deftypefn") |
|
1294 { |
|
1295 octave_value retval; |
|
1296 |
|
1297 int argc = args.length () + 1; |
|
1298 |
|
1299 string_vector argv = args.make_argv ("path"); |
|
1300 |
|
1301 if (! error_state) |
|
1302 { |
|
1303 if (argc > 1) |
|
1304 { |
|
1305 std::string path = argv[1]; |
|
1306 |
|
1307 for (int i = 2; i < argc; i++) |
5867
|
1308 path += dir_path::path_sep_str + argv[i]; |
5832
|
1309 |
5867
|
1310 load_path::set (path, true); |
5832
|
1311 } |
|
1312 |
|
1313 if (nargout > 0) |
|
1314 retval = load_path::path (); |
|
1315 else if (argc == 1 && nargout == 0) |
|
1316 { |
|
1317 octave_stdout << "\nOctave's search path contains the following directories:\n\n"; |
|
1318 |
|
1319 string_vector dirs = load_path::dirs (); |
|
1320 |
|
1321 dirs.list_in_columns (octave_stdout); |
|
1322 |
|
1323 octave_stdout << "\n"; |
|
1324 } |
|
1325 } |
|
1326 |
|
1327 return retval; |
|
1328 } |
|
1329 |
|
1330 DEFCMD (addpath, args, nargout, |
|
1331 "-*- texinfo -*-\n\ |
|
1332 @deftypefn {Function File} {} addpath (@var{dir1}, @dots{})\n\ |
|
1333 @deftypefnx {Function File} {} addpath (@var{dir1}, @dots{}, @var{option})\n\ |
|
1334 Add @var{dir1}, @dots{} to the current function search path. If\n\ |
|
1335 @var{option} is @samp{\"-begin\"} or 0 (the default), prepend the\n\ |
|
1336 directory name to the current path. If @var{option} is @samp{\"-end\"}\n\ |
|
1337 or 1, append the directory name to the current path.\n\ |
|
1338 Directories added to the path must exist.\n\ |
|
1339 @seealso{path, rmpath, genpath, pathdef, savepath, pathsep}\n\ |
|
1340 @end deftypefn") |
|
1341 { |
|
1342 octave_value retval; |
|
1343 |
|
1344 // Originally written by Bill Denney and Etienne Grossman. Heavily |
|
1345 // modified and translated to C++ by jwe. |
|
1346 |
|
1347 if (nargout > 0) |
|
1348 retval = load_path::path (); |
|
1349 |
|
1350 int nargin = args.length (); |
|
1351 |
|
1352 if (nargin > 0) |
|
1353 { |
|
1354 bool append = false; |
|
1355 |
|
1356 octave_value option_arg = args(nargin-1); |
|
1357 |
|
1358 if (option_arg.is_string ()) |
|
1359 { |
|
1360 std::string option = option_arg.string_value (); |
|
1361 |
|
1362 if (option == "-end") |
|
1363 { |
|
1364 append = true; |
|
1365 nargin--; |
|
1366 } |
|
1367 else if (option == "-begin") |
|
1368 nargin--; |
|
1369 } |
|
1370 else if (option_arg.is_numeric_type ()) |
|
1371 { |
|
1372 int val = option_arg.int_value (); |
|
1373 |
|
1374 if (! error_state) |
|
1375 { |
|
1376 if (val == 0) |
|
1377 append = false; |
|
1378 else if (val == 1) |
|
1379 append = true; |
|
1380 else |
|
1381 { |
|
1382 error ("addpath: expecting final argument to be 1 or 0"); |
|
1383 return retval; |
|
1384 } |
|
1385 } |
|
1386 else |
|
1387 { |
|
1388 error ("addpath: expecting final argument to be 1 or 0"); |
|
1389 return retval; |
|
1390 } |
|
1391 } |
|
1392 |
|
1393 for (int i = 0; i < nargin; i++) |
|
1394 { |
|
1395 std::string arg = args(i).string_value (); |
|
1396 |
|
1397 if (! error_state) |
|
1398 { |
|
1399 std::list<std::string> dir_elts = split_path (arg); |
|
1400 |
|
1401 for (std::list<std::string>::const_iterator p = dir_elts.begin (); |
|
1402 p != dir_elts.end (); |
|
1403 p++) |
|
1404 { |
|
1405 std::string dir = *p; |
|
1406 |
|
1407 //dir = regexprep (dir_elts{j}, "//+", "/"); |
|
1408 //dir = regexprep (dir, "/$", ""); |
|
1409 |
5867
|
1410 if (append) |
|
1411 load_path::append (dir, true); |
5832
|
1412 else |
5867
|
1413 load_path::prepend (dir, true); |
5832
|
1414 } |
|
1415 } |
|
1416 else |
|
1417 error ("addpath: expecting all args to be character strings"); |
|
1418 } |
|
1419 } |
|
1420 else |
|
1421 print_usage (); |
|
1422 |
|
1423 return retval; |
|
1424 } |
|
1425 |
|
1426 DEFCMD (rmpath, args, nargout, |
|
1427 "-*- texinfo -*-\n\ |
|
1428 @deftypefn {Function File} {} rmpath (@var{dir1}, @dots{})\n\ |
|
1429 Remove @var{dir1}, @dots{} from the current function search path.\n\ |
|
1430 \n\ |
|
1431 @seealso{path, addpath, genpath, pathdef, savepath, pathsep}\n\ |
|
1432 @end deftypefn") |
|
1433 { |
|
1434 // Originally by Etienne Grossmann. Heavily modified and translated |
|
1435 // to C++ by jwe. |
|
1436 |
|
1437 octave_value retval; |
|
1438 |
|
1439 if (nargout > 0) |
|
1440 retval = load_path::path (); |
|
1441 |
|
1442 int nargin = args.length (); |
|
1443 |
|
1444 if (nargin > 0) |
|
1445 { |
|
1446 for (int i = 0; i < nargin; i++) |
|
1447 { |
|
1448 std::string arg = args(i).string_value (); |
|
1449 |
|
1450 if (! error_state) |
|
1451 { |
|
1452 std::list<std::string> dir_elts = split_path (arg); |
|
1453 |
|
1454 for (std::list<std::string>::const_iterator p = dir_elts.begin (); |
|
1455 p != dir_elts.end (); |
|
1456 p++) |
|
1457 { |
|
1458 std::string dir = *p; |
|
1459 |
|
1460 //dir = regexprep (dir_elts{j}, "//+", "/"); |
|
1461 //dir = regexprep (dir, "/$", ""); |
|
1462 |
|
1463 if (! load_path::remove (dir)) |
|
1464 warning ("rmpath: %s: not found", dir.c_str ()); |
|
1465 } |
|
1466 } |
|
1467 else |
|
1468 error ("addpath: expecting all args to be character strings"); |
|
1469 } |
|
1470 } |
|
1471 else |
|
1472 print_usage (); |
|
1473 |
|
1474 return retval; |
|
1475 } |
|
1476 |
|
1477 /* |
|
1478 ;;; Local Variables: *** |
|
1479 ;;; mode: C++ *** |
|
1480 ;;; End: *** |
|
1481 */ |