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 |
|
377 do_set (xpath + ":::"); |
|
378 } |
|
379 |
|
380 void |
|
381 load_path::do_clear (void) |
|
382 { |
|
383 dir_info_list.clear (); |
|
384 fcn_map.clear (); |
|
385 } |
|
386 |
|
387 static std::list<std::string> |
|
388 split_path (const std::string& p) |
|
389 { |
|
390 std::list<std::string> retval; |
|
391 |
|
392 size_t beg = 0; |
|
393 size_t end = p.find (dir_path::path_sep_char); |
|
394 |
|
395 size_t len = p.length (); |
|
396 |
|
397 while (end != NPOS) |
|
398 { |
|
399 std::string elt = p.substr (beg, end-beg); |
|
400 |
|
401 if (! elt.empty ()) |
|
402 retval.push_back (elt); |
|
403 |
|
404 beg = end + 1; |
|
405 |
|
406 if (beg == len) |
|
407 break; |
|
408 |
|
409 end = p.find (dir_path::path_sep_char, beg); |
|
410 } |
|
411 |
|
412 std::string elt = p.substr (beg); |
|
413 |
|
414 if (! elt.empty ()) |
|
415 retval.push_back (elt); |
|
416 |
|
417 return retval; |
|
418 } |
|
419 |
|
420 void |
|
421 load_path::do_set (const std::string& p) |
|
422 { |
|
423 do_clear (); |
|
424 |
|
425 std::list<std::string> elts = split_path (p); |
|
426 |
|
427 // Temporarily disable add hook. |
|
428 |
5854
|
429 unwind_protect_fptr (add_hook); |
5832
|
430 |
|
431 add_hook = 0; |
|
432 |
|
433 for (std::list<std::string>::const_iterator i = elts.begin (); |
|
434 i != elts.end (); |
|
435 i++) |
|
436 do_append (*i); |
|
437 |
|
438 // Restore add hook and execute for all newly added directories. |
|
439 |
|
440 unwind_protect::run (); |
|
441 |
|
442 for (dir_info_list_iterator i = dir_info_list.begin (); |
|
443 i != dir_info_list.end (); |
|
444 i++) |
|
445 { |
|
446 if (add_hook) |
|
447 add_hook (i->dir_name); |
|
448 } |
|
449 } |
|
450 |
|
451 void |
|
452 load_path::do_append (const std::string& dir) |
|
453 { |
|
454 if (! dir.empty ()) |
|
455 { |
|
456 dir_info_list_iterator i = find_dir_info (dir); |
|
457 |
|
458 if (i != dir_info_list.end ()) |
|
459 move (i, true); |
|
460 else |
|
461 { |
|
462 dir_info di (dir); |
|
463 |
|
464 if (! error_state) |
|
465 { |
|
466 dir_info_list.push_back (di); |
|
467 |
|
468 add_to_fcn_map (di, true); |
|
469 |
|
470 if (add_hook) |
|
471 add_hook (dir); |
|
472 } |
|
473 } |
|
474 } |
|
475 } |
|
476 |
|
477 void |
|
478 load_path::do_prepend (const std::string& dir) |
|
479 { |
|
480 if (! dir.empty ()) |
|
481 { |
|
482 dir_info_list_iterator i = find_dir_info (dir); |
|
483 |
|
484 if (i != dir_info_list.end ()) |
|
485 move (i, false); |
|
486 else |
|
487 { |
|
488 dir_info di (dir); |
|
489 |
|
490 if (! error_state) |
|
491 { |
|
492 dir_info_list.push_front (di); |
|
493 |
|
494 add_to_fcn_map (di, false); |
|
495 |
|
496 if (add_hook) |
|
497 add_hook (dir); |
|
498 } |
|
499 } |
|
500 |
|
501 // FIXME -- is there a better way to do this? |
|
502 |
|
503 i = find_dir_info ("."); |
|
504 |
|
505 if (i != dir_info_list.end ()) |
|
506 move (i, false); |
|
507 else |
|
508 panic_impossible (); |
|
509 } |
|
510 } |
|
511 |
|
512 bool |
|
513 load_path::do_remove (const std::string& dir) |
|
514 { |
|
515 bool retval = false; |
|
516 |
|
517 if (! dir.empty ()) |
|
518 { |
|
519 if (dir == ".") |
|
520 warning ("rmpath: can't remove \".\" from path"); |
|
521 |
|
522 dir_info_list_iterator i = find_dir_info (dir); |
|
523 |
|
524 if (i != dir_info_list.end ()) |
|
525 { |
|
526 retval = true; |
|
527 |
|
528 string_vector fcn_files = i->fcn_files; |
|
529 |
|
530 dir_info_list.erase (i); |
|
531 |
|
532 octave_idx_type len = fcn_files.length (); |
|
533 |
|
534 for (octave_idx_type k = 0; k < len; k++) |
|
535 { |
|
536 std::string fname = fcn_files[k]; |
|
537 |
|
538 std::string ext; |
|
539 std::string base = fname; |
|
540 |
|
541 size_t pos = fname.rfind ('.'); |
|
542 |
|
543 if (pos != NPOS) |
|
544 { |
|
545 base = fname.substr (0, pos); |
|
546 ext = fname.substr (pos); |
|
547 } |
|
548 |
|
549 std::list<file_info>& file_info_list = fcn_map[base]; |
|
550 |
|
551 for (std::list<file_info>::iterator p = file_info_list.begin (); |
|
552 p != file_info_list.end (); |
|
553 p++) |
|
554 { |
|
555 if (p->dir_name == dir) |
|
556 { |
|
557 file_info_list.erase (p); |
|
558 |
|
559 if (file_info_list.empty ()) |
|
560 fcn_map.erase (fname); |
|
561 |
|
562 break; |
|
563 } |
|
564 } |
|
565 } |
|
566 |
|
567 if (remove_hook) |
|
568 remove_hook (dir); |
|
569 } |
|
570 } |
|
571 |
|
572 return retval; |
|
573 } |
|
574 |
|
575 void |
|
576 load_path::do_update (void) const |
|
577 { |
|
578 // I don't see a better way to do this because we need to |
|
579 // preserve the correct directory ordering for new files that |
|
580 // have appeared. |
|
581 |
|
582 fcn_map.clear (); |
|
583 |
|
584 for (dir_info_list_iterator p = dir_info_list.begin (); |
|
585 p != dir_info_list.end (); |
|
586 p++) |
|
587 { |
|
588 dir_info& di = *p; |
|
589 |
|
590 di.update (); |
|
591 |
|
592 add_to_fcn_map (di, true); |
|
593 } |
|
594 } |
|
595 |
|
596 std::string |
|
597 load_path::do_find_fcn (const std::string& fcn, int type) const |
|
598 { |
|
599 std::string retval; |
|
600 |
|
601 update (); |
|
602 |
|
603 const_fcn_map_iterator p = fcn_map.find (fcn); |
|
604 |
|
605 if (p != fcn_map.end ()) |
|
606 { |
|
607 const std::list<file_info>& file_info_list = p->second; |
|
608 |
|
609 for (const_file_info_list_iterator i = file_info_list.begin (); |
|
610 i != file_info_list.end (); |
|
611 i++) |
|
612 { |
|
613 const file_info& fi = *i; |
|
614 |
|
615 int t = fi.types; |
|
616 |
|
617 retval = fi.dir_name + file_ops::dir_sep_str + fcn; |
|
618 |
|
619 if (type == load_path::OCT_FILE) |
|
620 { |
|
621 if ((type & t) == load_path::OCT_FILE) |
|
622 { |
|
623 retval += ".oct"; |
|
624 break; |
|
625 } |
|
626 } |
|
627 else if (type == load_path::M_FILE) |
|
628 { |
|
629 if ((type & t) == load_path::M_FILE) |
|
630 { |
|
631 retval += ".m"; |
|
632 break; |
|
633 } |
|
634 } |
5864
|
635 else if (type == load_path::MEX_FILE) |
|
636 { |
|
637 if ((type & t) == load_path::MEX_FILE) |
|
638 { |
|
639 retval += ".mex"; |
|
640 break; |
|
641 } |
|
642 } |
5832
|
643 else if (type == (load_path::M_FILE | load_path::OCT_FILE)) |
|
644 { |
|
645 if (t & load_path::OCT_FILE) |
|
646 { |
|
647 retval += ".oct"; |
|
648 break; |
|
649 } |
|
650 else if (t & load_path::M_FILE) |
|
651 { |
|
652 retval += ".m"; |
|
653 break; |
|
654 } |
|
655 } |
5864
|
656 else if (type == (load_path::M_FILE | load_path::MEX_FILE)) |
|
657 { |
|
658 if (t & load_path::MEX_FILE) |
|
659 { |
|
660 retval += ".mex"; |
|
661 break; |
|
662 } |
|
663 else if (t & load_path::M_FILE) |
|
664 { |
|
665 retval += ".m"; |
|
666 break; |
|
667 } |
|
668 } |
|
669 else if (type == (load_path::OCT_FILE | load_path::MEX_FILE)) |
|
670 { |
|
671 if (t & load_path::OCT_FILE) |
|
672 { |
|
673 retval += ".oct"; |
|
674 break; |
|
675 } |
|
676 else if (t & load_path::MEX_FILE) |
|
677 { |
|
678 retval += ".mex"; |
|
679 break; |
|
680 } |
|
681 } |
|
682 else if (type == (load_path::M_FILE | load_path::OCT_FILE |
|
683 | load_path::MEX_FILE)) |
|
684 { |
|
685 if (t & load_path::OCT_FILE) |
|
686 { |
|
687 retval += ".oct"; |
|
688 break; |
|
689 } |
|
690 else if (t & load_path::MEX_FILE) |
|
691 { |
|
692 retval += ".mex"; |
|
693 break; |
|
694 } |
|
695 else if (t & load_path::M_FILE) |
|
696 { |
|
697 retval += ".m"; |
|
698 break; |
|
699 } |
|
700 } |
5832
|
701 else |
|
702 error ("load_path::do_find_fcn: %s: invalid type code = %d", |
|
703 fcn.c_str (), type); |
|
704 } |
|
705 } |
|
706 |
|
707 return retval; |
|
708 } |
|
709 |
|
710 std::string |
|
711 load_path::do_find_file (const std::string& file) const |
|
712 { |
|
713 std::string retval; |
|
714 |
|
715 if (octave_env::absolute_pathname (file)) |
|
716 { |
|
717 file_stat fs (file); |
|
718 |
|
719 if (fs.exists ()) |
|
720 return file; |
|
721 } |
|
722 |
|
723 std::string dir_name; |
|
724 |
|
725 for (const_dir_info_list_iterator p = dir_info_list.begin (); |
|
726 p != dir_info_list.end (); |
|
727 p++) |
|
728 { |
|
729 string_vector all_files = p->all_files; |
|
730 |
|
731 octave_idx_type len = all_files.length (); |
|
732 |
|
733 for (octave_idx_type i = 0; i < len; i++) |
|
734 { |
|
735 if (all_files[i] == file) |
|
736 { |
|
737 dir_name = p->dir_name; |
|
738 break; |
|
739 } |
|
740 } |
|
741 } |
|
742 |
|
743 if (! dir_name.empty ()) |
|
744 retval = dir_name + file_ops::dir_sep_str + file; |
|
745 |
|
746 return retval; |
|
747 } |
|
748 |
|
749 std::string |
|
750 load_path::do_find_first_of (const string_vector& flist) const |
|
751 { |
|
752 std::string retval; |
|
753 |
|
754 std::string dir_name; |
|
755 std::string file_name; |
|
756 |
|
757 octave_idx_type flen = flist.length (); |
|
758 octave_idx_type rel_flen = 0; |
|
759 |
|
760 string_vector rel_flist (flen); |
|
761 |
|
762 for (octave_idx_type i = 0; i < flen; i++) |
|
763 { |
|
764 if (octave_env::absolute_pathname (flist[i])) |
|
765 { |
|
766 file_stat fs (flist[i]); |
|
767 |
|
768 if (fs.exists ()) |
|
769 return flist[i]; |
|
770 } |
|
771 else |
|
772 rel_flist[rel_flen++] = flist[i]; |
|
773 } |
|
774 |
|
775 rel_flist.resize (rel_flen); |
|
776 |
|
777 for (const_dir_info_list_iterator p = dir_info_list.begin (); |
|
778 p != dir_info_list.end (); |
|
779 p++) |
|
780 { |
|
781 string_vector all_files = p->all_files; |
|
782 |
|
783 octave_idx_type len = all_files.length (); |
|
784 |
|
785 for (octave_idx_type i = 0; i < len; i++) |
|
786 { |
|
787 |
|
788 for (octave_idx_type j = 0; j < rel_flen; j++) |
|
789 { |
|
790 if (all_files[i] == rel_flist[j]) |
|
791 { |
|
792 dir_name = p->dir_name; |
|
793 file_name = rel_flist[j]; |
|
794 break; |
|
795 } |
|
796 } |
|
797 } |
|
798 } |
|
799 |
|
800 if (! dir_name.empty ()) |
|
801 retval = dir_name + file_ops::dir_sep_str + file_name; |
|
802 |
|
803 return retval; |
|
804 } |
|
805 |
|
806 string_vector |
|
807 load_path::do_find_all_first_of (const string_vector& flist) const |
|
808 { |
|
809 std::list<std::string> retlist; |
|
810 |
|
811 std::string dir_name; |
|
812 std::string file_name; |
|
813 |
|
814 octave_idx_type flen = flist.length (); |
|
815 octave_idx_type rel_flen = 0; |
|
816 |
|
817 string_vector rel_flist (flen); |
|
818 |
|
819 for (octave_idx_type i = 0; i < flen; i++) |
|
820 { |
|
821 if (octave_env::absolute_pathname (flist[i])) |
|
822 { |
|
823 file_stat fs (flist[i]); |
|
824 |
|
825 if (fs.exists ()) |
|
826 retlist.push_back (flist[i]); |
|
827 } |
|
828 else |
|
829 rel_flist[rel_flen++] = flist[i]; |
|
830 } |
|
831 |
|
832 rel_flist.resize (rel_flen); |
|
833 |
|
834 for (const_dir_info_list_iterator p = dir_info_list.begin (); |
|
835 p != dir_info_list.end (); |
|
836 p++) |
|
837 { |
|
838 string_vector all_files = p->all_files; |
|
839 |
|
840 octave_idx_type len = all_files.length (); |
|
841 |
|
842 for (octave_idx_type i = 0; i < len; i++) |
|
843 { |
|
844 for (octave_idx_type j = 0; j < rel_flen; j++) |
|
845 { |
|
846 if (all_files[i] == rel_flist[j]) |
|
847 retlist.push_back |
|
848 (p->dir_name + file_ops::dir_sep_str + rel_flist[j]); |
|
849 } |
|
850 } |
|
851 } |
|
852 |
|
853 size_t retsize = retlist.size (); |
|
854 |
|
855 string_vector retval (retsize); |
|
856 |
|
857 for (size_t i = 0; i < retsize; i++) |
|
858 { |
|
859 retval[i] = retlist.front (); |
|
860 |
|
861 retlist.pop_front (); |
|
862 } |
|
863 |
|
864 return retval; |
|
865 } |
|
866 |
|
867 string_vector |
|
868 load_path::do_dirs (void) const |
|
869 { |
|
870 size_t len = dir_info_list.size (); |
|
871 |
|
872 string_vector retval (len); |
|
873 |
|
874 octave_idx_type k = 0; |
|
875 |
|
876 for (const_dir_info_list_iterator i = dir_info_list.begin (); |
|
877 i != dir_info_list.end (); |
|
878 i++) |
|
879 retval[k++] = i->dir_name; |
|
880 |
|
881 return retval; |
|
882 } |
|
883 |
|
884 std::list<std::string> |
|
885 load_path::do_dir_list (void) const |
|
886 { |
|
887 std::list<std::string> retval; |
|
888 |
|
889 for (const_dir_info_list_iterator i = dir_info_list.begin (); |
|
890 i != dir_info_list.end (); |
|
891 i++) |
|
892 retval.push_back (i->dir_name); |
|
893 |
|
894 return retval; |
|
895 } |
|
896 |
|
897 string_vector |
|
898 load_path::do_files (const std::string& dir) const |
|
899 { |
|
900 string_vector retval; |
|
901 |
|
902 const_dir_info_list_iterator i = find_dir_info (dir); |
|
903 |
|
904 if (i != dir_info_list.end ()) |
|
905 retval = i->fcn_files; |
|
906 |
|
907 return retval; |
|
908 } |
|
909 |
|
910 string_vector |
|
911 load_path::do_fcn_names (void) const |
|
912 { |
|
913 size_t len = fcn_map.size (); |
|
914 |
|
915 string_vector retval (len); |
|
916 |
|
917 octave_idx_type count = 0; |
|
918 |
|
919 for (const_fcn_map_iterator p = fcn_map.begin (); |
|
920 p != fcn_map.end (); |
|
921 p++) |
|
922 retval[count++] = p->first; |
|
923 |
|
924 return retval; |
|
925 } |
|
926 |
|
927 std::string |
|
928 load_path::do_path (void) const |
|
929 { |
|
930 std::string xpath; |
|
931 |
|
932 string_vector xdirs = load_path::dirs (); |
|
933 |
|
934 octave_idx_type len = xdirs.length (); |
|
935 |
|
936 if (len > 0) |
|
937 xpath = xdirs[0]; |
|
938 |
|
939 for (octave_idx_type i = 1; i < len; i++) |
|
940 xpath += dir_path::path_sep_str + xdirs[i]; |
|
941 |
|
942 return xpath; |
|
943 } |
|
944 |
|
945 void |
|
946 load_path::do_display (std::ostream& os) const |
|
947 { |
|
948 for (const_dir_info_list_iterator i = dir_info_list.begin (); |
|
949 i != dir_info_list.end (); |
|
950 i++) |
|
951 { |
|
952 string_vector fcn_files = i->fcn_files; |
|
953 |
|
954 if (! fcn_files.empty ()) |
|
955 { |
|
956 os << "\n*** function files in " << i->dir_name << ":\n\n"; |
|
957 |
|
958 fcn_files.list_in_columns (os); |
|
959 } |
|
960 |
|
961 #if defined (DEBUG_LOAD_PATH) |
|
962 |
|
963 const std::map<std::string, int>& private_function_map |
|
964 = i->private_function_map; |
|
965 |
|
966 if (private_function_map.size () > 0) |
|
967 { |
|
968 os << "private:\n"; |
|
969 |
|
970 for (std::map<std::string, int>::const_iterator p = private_function_map.begin (); |
|
971 p != private_function_map.end (); |
|
972 p++) |
|
973 { |
|
974 os << " " << p->first << " ("; |
|
975 |
|
976 bool printed_type = false; |
|
977 |
|
978 int types = p->second; |
|
979 |
|
980 if (types & load_path::OCT_FILE) |
|
981 { |
|
982 os << "oct"; |
|
983 printed_type = true; |
|
984 } |
|
985 |
5864
|
986 if (types & load_path::MEX_FILE) |
|
987 { |
|
988 if (printed_type) |
|
989 os << "|"; |
|
990 os << "mex"; |
|
991 printed_type = true; |
|
992 } |
|
993 |
5832
|
994 if (types & load_path::M_FILE) |
|
995 { |
|
996 if (printed_type) |
|
997 os << "|"; |
|
998 os << "m"; |
|
999 printed_type = true; |
|
1000 } |
|
1001 |
|
1002 os << ")\n"; |
|
1003 } |
|
1004 |
|
1005 os << "\n"; |
|
1006 } |
|
1007 #endif |
|
1008 } |
|
1009 |
|
1010 #if defined (DEBUG_LOAD_PATH) |
|
1011 |
|
1012 for (const_fcn_map_iterator i = fcn_map.begin (); |
|
1013 i != fcn_map.end (); |
|
1014 i++) |
|
1015 { |
|
1016 os << i->first << ":\n"; |
|
1017 |
|
1018 const std::list<file_info>& file_info_list = i->second; |
|
1019 |
|
1020 for (const_file_info_list_iterator p = file_info_list.begin (); |
|
1021 p != file_info_list.end (); |
|
1022 p++) |
|
1023 { |
|
1024 os << " " << p->dir_name << " ("; |
|
1025 |
|
1026 bool printed_type = false; |
|
1027 |
|
1028 if (p->types & load_path::OCT_FILE) |
|
1029 { |
|
1030 os << "oct"; |
|
1031 printed_type = true; |
|
1032 } |
|
1033 |
5864
|
1034 if (p->types & load_path::MEX_FILE) |
|
1035 { |
|
1036 if (printed_type) |
|
1037 os << "|"; |
|
1038 os << "mex"; |
|
1039 printed_type = true; |
|
1040 } |
|
1041 |
5832
|
1042 if (p->types & load_path::M_FILE) |
|
1043 { |
|
1044 if (printed_type) |
|
1045 os << "|"; |
|
1046 os << "m"; |
|
1047 printed_type = true; |
|
1048 } |
|
1049 |
|
1050 os << ")\n"; |
|
1051 } |
|
1052 } |
|
1053 |
|
1054 os << "\n"; |
|
1055 |
|
1056 #endif |
|
1057 } |
|
1058 |
|
1059 void |
|
1060 load_path::add_to_fcn_map (const dir_info& di, bool at_end) const |
|
1061 { |
|
1062 std::string dir_name = di.dir_name; |
|
1063 |
|
1064 string_vector fcn_files = di.fcn_files; |
|
1065 |
|
1066 octave_idx_type len = fcn_files.length (); |
|
1067 |
|
1068 for (octave_idx_type i = 0; i < len; i++) |
|
1069 { |
|
1070 std::string fname = fcn_files[i]; |
|
1071 |
|
1072 std::string ext; |
|
1073 std::string base = fname; |
|
1074 |
|
1075 size_t pos = fname.rfind ('.'); |
|
1076 |
|
1077 if (pos != NPOS) |
|
1078 { |
|
1079 base = fname.substr (0, pos); |
|
1080 ext = fname.substr (pos); |
|
1081 } |
|
1082 |
|
1083 std::list<file_info>& file_info_list = fcn_map[base]; |
|
1084 |
|
1085 file_info_list_iterator p = file_info_list.begin (); |
|
1086 |
|
1087 while (p != file_info_list.end ()) |
|
1088 { |
|
1089 if (p->dir_name == dir_name) |
|
1090 break; |
|
1091 |
|
1092 p++; |
|
1093 } |
|
1094 |
|
1095 int t = 0; |
|
1096 if (ext == ".m") |
|
1097 t = load_path::M_FILE; |
|
1098 else if (ext == ".oct") |
|
1099 t = load_path::OCT_FILE; |
5864
|
1100 else if (ext == ".mex") |
|
1101 t = load_path::MEX_FILE; |
5832
|
1102 |
|
1103 if (p == file_info_list.end ()) |
|
1104 { |
|
1105 file_info fi (dir_name, t); |
|
1106 |
|
1107 if (at_end) |
|
1108 file_info_list.push_back (fi); |
|
1109 else |
|
1110 file_info_list.push_front (fi); |
|
1111 } |
|
1112 else |
|
1113 { |
|
1114 file_info& fi = *p; |
|
1115 |
|
1116 fi.types |= t; |
|
1117 } |
|
1118 } |
|
1119 } |
|
1120 |
|
1121 std::string |
|
1122 genpath (const std::string& dirname, const string_vector& skip) |
|
1123 { |
|
1124 std::string retval; |
|
1125 |
|
1126 std::string full_dirname = file_ops::tilde_expand (dirname); |
|
1127 |
|
1128 dir_entry dir (full_dirname); |
|
1129 |
|
1130 if (dir) |
|
1131 { |
|
1132 retval = dirname; |
|
1133 |
|
1134 string_vector dirlist = dir.read (); |
|
1135 |
|
1136 octave_idx_type len = dirlist.length (); |
|
1137 |
|
1138 for (octave_idx_type i = 0; i < len; i++) |
|
1139 { |
|
1140 std::string elt = dirlist[i]; |
|
1141 |
|
1142 // FIXME -- the caller should be able to specify the list of |
|
1143 // directories to skip in addition to "." and "..". |
|
1144 |
|
1145 bool skip_p = (elt == "." || elt == ".."); |
|
1146 |
|
1147 if (! skip_p) |
|
1148 { |
|
1149 for (octave_idx_type j = 0; j < skip.length (); j++) |
|
1150 { |
|
1151 skip_p = (elt == skip[j]); |
|
1152 if (skip_p) |
|
1153 break; |
|
1154 } |
|
1155 |
|
1156 if (! skip_p) |
|
1157 { |
|
1158 std::string nm = full_dirname + file_ops::dir_sep_str + elt; |
|
1159 |
|
1160 file_stat fs (nm); |
|
1161 |
|
1162 if (fs && fs.is_dir ()) |
|
1163 retval += dir_path::path_sep_str + genpath (nm); |
|
1164 } |
|
1165 } |
|
1166 } |
|
1167 } |
|
1168 |
|
1169 return retval; |
|
1170 } |
|
1171 |
|
1172 static void |
|
1173 execute_pkg_add_or_del (const std::string& dir, |
|
1174 const std::string& script_file) |
|
1175 { |
|
1176 if (! octave_interpreter_ready) |
|
1177 return; |
|
1178 |
|
1179 unwind_protect::begin_frame ("execute_pkg_add_or_del"); |
|
1180 |
|
1181 unwind_protect_bool (input_from_startup_file); |
|
1182 |
|
1183 input_from_startup_file = true; |
|
1184 |
|
1185 std::string file = dir + file_ops::dir_sep_str + script_file; |
|
1186 |
|
1187 file_stat fs = file_stat (file); |
|
1188 |
|
1189 if (fs.exists ()) |
|
1190 source_file (file); |
|
1191 |
|
1192 unwind_protect::run_frame ("execute_pkg_add_or_del"); |
|
1193 } |
|
1194 |
|
1195 void |
|
1196 execute_pkg_add (const std::string& dir) |
|
1197 { |
|
1198 execute_pkg_add_or_del (dir, "PKG_ADD"); |
|
1199 } |
|
1200 |
|
1201 void |
|
1202 execute_pkg_del (const std::string& dir) |
|
1203 { |
|
1204 execute_pkg_add_or_del (dir, "PKG_DEL"); |
|
1205 } |
|
1206 |
|
1207 DEFUN (genpath, args, , |
|
1208 "-*- texinfo -*-\n\ |
|
1209 @deftypefn {Built-in Function} {} genpath (@var{dir})\n\ |
|
1210 Return a path constructed from @var{dir} and all its subdiretories.\n\ |
|
1211 @end deftypefn") |
|
1212 { |
|
1213 octave_value retval; |
|
1214 |
|
1215 if (args.length () == 1) |
|
1216 { |
|
1217 std::string dirname = args(0).string_value (); |
|
1218 |
|
1219 if (! error_state) |
|
1220 retval = genpath (dirname); |
|
1221 else |
|
1222 error ("genpath: expecting argument to be a character string"); |
|
1223 } |
|
1224 else |
|
1225 print_usage (); |
|
1226 |
|
1227 return retval; |
|
1228 } |
|
1229 |
|
1230 DEFUN (rehash, , , |
|
1231 "-*- texinfo -*-\n\ |
|
1232 @deftypefn {Built-in Function} {} rehash ()\n\ |
|
1233 Reinitialize Octave's @code{LOADPATH} directory cache.\n\ |
|
1234 @end deftypefn") |
|
1235 { |
|
1236 octave_value_list retval; |
|
1237 |
|
1238 load_path::update (); |
|
1239 |
|
1240 // FIXME -- maybe we should rename this variable since it is being |
|
1241 // used for more than keeping track of the prompt time. |
|
1242 |
|
1243 // This will force updated functions to be found. |
|
1244 Vlast_prompt_time.stamp (); |
|
1245 |
|
1246 return retval; |
|
1247 } |
|
1248 |
|
1249 DEFUN (pathdef, , , |
|
1250 "-*- texinfo -*-\n\ |
|
1251 @deftypefn {Built-in Function} {@var{val} =} pathdef ()\n\ |
|
1252 Return the default list of directories in which to search for function\n\ |
|
1253 files.\n\ |
|
1254 @seealso{path, addpath, rmpath, genpath, savepath, pathsep}\n\ |
|
1255 @end deftypefn") |
|
1256 { |
|
1257 return octave_value (Vsystem_path); |
|
1258 } |
|
1259 |
|
1260 DEFUN (path, args, nargout, |
|
1261 "-*- texinfo -*-\n\ |
|
1262 @deftypefn {Function File} {} path (@dots{})\n\ |
|
1263 Modify or display Octave's @code{LOADPATH}.\n\ |
|
1264 \n\ |
|
1265 If @var{nargin} and @var{nargout} are zero, display the elements of\n\ |
|
1266 Octave's @code{LOADPATH} in an easy to read format.\n\ |
|
1267 \n\ |
|
1268 If @var{nargin} is zero and nargout is greater than zero, return the\n\ |
|
1269 current value of @code{LOADPATH}.\n\ |
|
1270 \n\ |
|
1271 If @var{nargin} is greater than zero, concatenate the arguments,\n\ |
|
1272 separating them with @code{pathsep()}. Set the internal search path\n\ |
|
1273 to the result and return it.\n\ |
|
1274 \n\ |
|
1275 No checks are made for duplicate elements.\n\ |
|
1276 @seealso{addpath, rmpath, genpath, pathdef, savepath, pathsep}\n\ |
|
1277 @end deftypefn") |
|
1278 { |
|
1279 octave_value retval; |
|
1280 |
|
1281 int argc = args.length () + 1; |
|
1282 |
|
1283 string_vector argv = args.make_argv ("path"); |
|
1284 |
|
1285 if (! error_state) |
|
1286 { |
|
1287 if (argc > 1) |
|
1288 { |
|
1289 std::string path = argv[1]; |
|
1290 |
|
1291 for (int i = 2; i < argc; i++) |
|
1292 path += dir_path::path_sep_str; |
|
1293 |
|
1294 size_t plen = path.length (); |
|
1295 |
|
1296 if (! ((plen == 1 && path[0] == ':') |
|
1297 || (plen > 1 |
|
1298 && path.substr (0, 2) == ("." + dir_path::path_sep_str)))) |
|
1299 path = "." + dir_path::path_sep_str + path; |
|
1300 |
|
1301 load_path::set (path); |
|
1302 } |
|
1303 |
|
1304 if (nargout > 0) |
|
1305 retval = load_path::path (); |
|
1306 else if (argc == 1 && nargout == 0) |
|
1307 { |
|
1308 octave_stdout << "\nOctave's search path contains the following directories:\n\n"; |
|
1309 |
|
1310 string_vector dirs = load_path::dirs (); |
|
1311 |
|
1312 dirs.list_in_columns (octave_stdout); |
|
1313 |
|
1314 octave_stdout << "\n"; |
|
1315 } |
|
1316 } |
|
1317 |
|
1318 return retval; |
|
1319 } |
|
1320 |
|
1321 DEFCMD (addpath, args, nargout, |
|
1322 "-*- texinfo -*-\n\ |
|
1323 @deftypefn {Function File} {} addpath (@var{dir1}, @dots{})\n\ |
|
1324 @deftypefnx {Function File} {} addpath (@var{dir1}, @dots{}, @var{option})\n\ |
|
1325 Add @var{dir1}, @dots{} to the current function search path. If\n\ |
|
1326 @var{option} is @samp{\"-begin\"} or 0 (the default), prepend the\n\ |
|
1327 directory name to the current path. If @var{option} is @samp{\"-end\"}\n\ |
|
1328 or 1, append the directory name to the current path.\n\ |
|
1329 Directories added to the path must exist.\n\ |
|
1330 @seealso{path, rmpath, genpath, pathdef, savepath, pathsep}\n\ |
|
1331 @end deftypefn") |
|
1332 { |
|
1333 octave_value retval; |
|
1334 |
|
1335 // Originally written by Bill Denney and Etienne Grossman. Heavily |
|
1336 // modified and translated to C++ by jwe. |
|
1337 |
|
1338 if (nargout > 0) |
|
1339 retval = load_path::path (); |
|
1340 |
|
1341 int nargin = args.length (); |
|
1342 |
|
1343 if (nargin > 0) |
|
1344 { |
|
1345 bool append = false; |
|
1346 |
|
1347 octave_value option_arg = args(nargin-1); |
|
1348 |
|
1349 if (option_arg.is_string ()) |
|
1350 { |
|
1351 std::string option = option_arg.string_value (); |
|
1352 |
|
1353 if (option == "-end") |
|
1354 { |
|
1355 append = true; |
|
1356 nargin--; |
|
1357 } |
|
1358 else if (option == "-begin") |
|
1359 nargin--; |
|
1360 } |
|
1361 else if (option_arg.is_numeric_type ()) |
|
1362 { |
|
1363 int val = option_arg.int_value (); |
|
1364 |
|
1365 if (! error_state) |
|
1366 { |
|
1367 if (val == 0) |
|
1368 append = false; |
|
1369 else if (val == 1) |
|
1370 append = true; |
|
1371 else |
|
1372 { |
|
1373 error ("addpath: expecting final argument to be 1 or 0"); |
|
1374 return retval; |
|
1375 } |
|
1376 } |
|
1377 else |
|
1378 { |
|
1379 error ("addpath: expecting final argument to be 1 or 0"); |
|
1380 return retval; |
|
1381 } |
|
1382 } |
|
1383 |
|
1384 std::list<std::string> xpath = load_path::dir_list (); |
|
1385 |
|
1386 // Strip "." for now. Calling path to set the path will restore it. |
|
1387 |
|
1388 xpath.remove ("."); |
|
1389 |
|
1390 for (int i = 0; i < nargin; i++) |
|
1391 { |
|
1392 std::string arg = args(i).string_value (); |
|
1393 |
|
1394 if (! error_state) |
|
1395 { |
|
1396 std::list<std::string> dir_elts = split_path (arg); |
|
1397 |
|
1398 for (std::list<std::string>::const_iterator p = dir_elts.begin (); |
|
1399 p != dir_elts.end (); |
|
1400 p++) |
|
1401 { |
|
1402 std::string dir = *p; |
|
1403 |
|
1404 //dir = regexprep (dir_elts{j}, "//+", "/"); |
|
1405 //dir = regexprep (dir, "/$", ""); |
|
1406 |
|
1407 if (dir == "." && append) |
|
1408 warning ("addpath: \".\" is always first in the path"); |
|
1409 |
|
1410 file_stat fs (dir); |
|
1411 |
|
1412 if (fs) |
|
1413 { |
|
1414 if (fs.is_dir ()) |
|
1415 { |
|
1416 if (append) |
|
1417 load_path::append (dir); |
|
1418 else |
|
1419 load_path::prepend (dir); |
|
1420 } |
|
1421 else |
|
1422 warning ("addpath: %s: not a directory", dir.c_str ()); |
|
1423 } |
|
1424 else |
|
1425 { |
|
1426 std::string msg = fs.error (); |
|
1427 warning ("addpath: %s: %s", dir.c_str (), msg.c_str ()); |
|
1428 } |
|
1429 } |
|
1430 } |
|
1431 else |
|
1432 error ("addpath: expecting all args to be character strings"); |
|
1433 } |
|
1434 } |
|
1435 else |
|
1436 print_usage (); |
|
1437 |
|
1438 return retval; |
|
1439 } |
|
1440 |
|
1441 DEFCMD (rmpath, args, nargout, |
|
1442 "-*- texinfo -*-\n\ |
|
1443 @deftypefn {Function File} {} rmpath (@var{dir1}, @dots{})\n\ |
|
1444 Remove @var{dir1}, @dots{} from the current function search path.\n\ |
|
1445 \n\ |
|
1446 @seealso{path, addpath, genpath, pathdef, savepath, pathsep}\n\ |
|
1447 @end deftypefn") |
|
1448 { |
|
1449 // Originally by Etienne Grossmann. Heavily modified and translated |
|
1450 // to C++ by jwe. |
|
1451 |
|
1452 octave_value retval; |
|
1453 |
|
1454 if (nargout > 0) |
|
1455 retval = load_path::path (); |
|
1456 |
|
1457 int nargin = args.length (); |
|
1458 |
|
1459 if (nargin > 0) |
|
1460 { |
|
1461 std::list<std::string> xpath = load_path::dir_list (); |
|
1462 |
|
1463 for (int i = 0; i < nargin; i++) |
|
1464 { |
|
1465 std::string arg = args(i).string_value (); |
|
1466 |
|
1467 if (! error_state) |
|
1468 { |
|
1469 std::list<std::string> dir_elts = split_path (arg); |
|
1470 |
|
1471 for (std::list<std::string>::const_iterator p = dir_elts.begin (); |
|
1472 p != dir_elts.end (); |
|
1473 p++) |
|
1474 { |
|
1475 std::string dir = *p; |
|
1476 |
|
1477 //dir = regexprep (dir_elts{j}, "//+", "/"); |
|
1478 //dir = regexprep (dir, "/$", ""); |
|
1479 |
|
1480 if (! load_path::remove (dir)) |
|
1481 warning ("rmpath: %s: not found", dir.c_str ()); |
|
1482 } |
|
1483 } |
|
1484 else |
|
1485 error ("addpath: expecting all args to be character strings"); |
|
1486 } |
|
1487 } |
|
1488 else |
|
1489 print_usage (); |
|
1490 |
|
1491 return retval; |
|
1492 } |
|
1493 |
|
1494 /* |
|
1495 ;;; Local Variables: *** |
|
1496 ;;; mode: C++ *** |
|
1497 ;;; End: *** |
|
1498 */ |