1
|
1 // help.cc -*- C++ -*- |
|
2 /* |
|
3 |
389
|
4 Copyright (C) 1992, 1993, 1994 John W. Eaton |
1
|
5 |
|
6 This file is part of Octave. |
|
7 |
|
8 Octave is free software; you can redistribute it and/or modify it |
|
9 under the terms of the GNU General Public License as published by the |
|
10 Free Software Foundation; either version 2, or (at your option) any |
|
11 later version. |
|
12 |
|
13 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
16 for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
|
19 along with Octave; see the file COPYING. If not, write to the Free |
|
20 Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
21 |
|
22 */ |
|
23 |
240
|
24 #ifdef HAVE_CONFIG_H |
|
25 #include "config.h" |
1
|
26 #endif |
|
27 |
529
|
28 #include <signal.h> |
|
29 #include <stdlib.h> |
1
|
30 #include <iostream.h> |
529
|
31 #include <strstream.h> |
240
|
32 |
581
|
33 #include "tree-expr.h" |
|
34 #include "tree-const.h" |
529
|
35 #include "sighandlers.h" |
|
36 #include "user-prefs.h" |
|
37 #include "tree-expr.h" |
|
38 #include "variables.h" |
|
39 #include "oct-obj.h" |
|
40 #include "symtab.h" |
|
41 #include "octave.h" |
|
42 #include "dirfns.h" |
|
43 #include "pager.h" |
|
44 #include "error.h" |
242
|
45 #include "utils.h" |
1
|
46 #include "help.h" |
529
|
47 #include "defun.h" |
|
48 |
|
49 extern "C" |
|
50 { |
|
51 #include "info/info.h" |
|
52 #include "info/dribble.h" |
|
53 #include "info/terminal.h" |
|
54 |
|
55 extern int initialize_info_session (); |
|
56 extern int index_entry_exists (); |
|
57 extern int do_info_index_search (); |
|
58 extern void finish_info_session (); |
|
59 extern char *replace_in_documentation (); |
|
60 |
|
61 // XXX FIXME XXX |
|
62 #undef __FUNCTION_DEF |
|
63 #include <readline/tilde.h> |
|
64 } |
1
|
65 |
|
66 static help_list operators[] = |
|
67 { |
|
68 { "!", |
|
69 "Logical not operator. See also `~'.\n", }, |
|
70 |
|
71 { "!=", |
|
72 "Logical not equals operator. See also `~' and `<>'.\n", }, |
|
73 |
|
74 { "\"", |
|
75 "String delimiter.\n", }, |
|
76 |
|
77 { "#", |
|
78 "Begin comment character. See also `%'.\n", }, |
|
79 |
|
80 { "%", |
|
81 "Begin comment charcter. See also `#'.\n", }, |
|
82 |
|
83 { "&", |
|
84 "Logical and operator. See also `&&'.\n", }, |
|
85 |
|
86 { "&&", |
|
87 "Logical and operator. See also `&'.\n", }, |
|
88 |
|
89 { "'", |
|
90 "Matrix transpose operator. For complex matrices, computes the\n\ |
|
91 complex conjugate (Hermitian) transpose. See also `.''\n\ |
|
92 \n\ |
|
93 The single quote character may also be used to delimit strings, but\n\ |
|
94 it is better to use the double quote character, since that is never\n\ |
|
95 ambiguous\n", }, |
|
96 |
|
97 { "(", |
|
98 "Array index or function argument delimiter.\n", }, |
|
99 |
|
100 { ")", |
|
101 "Array index or function argument delimiter.\n", }, |
|
102 |
|
103 { "*", |
|
104 "Multiplication operator. See also `.*'\n", }, |
|
105 |
|
106 { "**", |
|
107 "Power operator. See also `^', `.**', and `.^'\n", }, |
|
108 |
|
109 { "+", |
|
110 "Addition operator.\n", }, |
|
111 |
|
112 { "++", |
|
113 "Increment operator. As in C, may be applied as a prefix or postfix operator.\n", }, |
|
114 |
|
115 { ",", |
|
116 "Array index, function argument, or command separator.\n", }, |
|
117 |
|
118 { "-", |
|
119 "Subtraction or unary negation operator.\n", }, |
|
120 |
|
121 { "--", |
|
122 "Decrement operator. As in C, may be applied as a prefix or postfix operator.\n", }, |
|
123 |
|
124 { ".'", |
|
125 "Matrix transpose operator. For complex matrices, computes the\n\ |
|
126 transpose, *not* the complex conjugate transpose. See also `''.\n", }, |
|
127 |
|
128 { ".*", |
|
129 "Element by element multiplication operator. See also `*'.\n", }, |
|
130 |
|
131 { ".**", |
|
132 "Element by element power operator. See also `**', `^', and `.^'.\n", }, |
|
133 |
|
134 { "./", |
|
135 "Element by element division operator. See also `/' and `\\'.\n", }, |
|
136 |
|
137 { ".^", |
389
|
138 "Element by element power operator. See also `**', `^', and `.^'.\n", }, |
1
|
139 |
|
140 { "/", |
|
141 "Right division. See also `\\' and `./'.\n", }, |
|
142 |
|
143 { ":", |
|
144 "Select entire rows or columns of matrices.\n", }, |
|
145 |
|
146 { ";", |
|
147 "Array row or command separator. See also `,'.\n", }, |
|
148 |
|
149 { "<", |
|
150 "Less than operator.\n", }, |
|
151 |
|
152 { "<=", |
|
153 "Less than or equals operator.\n", }, |
|
154 |
|
155 { "<>", |
|
156 "Logical not equals operator. See also `!=' and `~='.\n", }, |
|
157 |
|
158 { "=", |
|
159 "Assignment operator.\n", }, |
|
160 |
|
161 { "==", |
|
162 "Equality test operator.\n", }, |
|
163 |
|
164 { ">", |
|
165 "Greater than operator.\n", }, |
|
166 |
|
167 { ">=", |
|
168 "Greater than or equals operator.\n", }, |
|
169 |
|
170 { "[", |
|
171 "Return list delimiter. See also `]'.\n", }, |
|
172 |
|
173 { "\\", |
|
174 "Left division operator. See also `/' and `./'.\n", }, |
|
175 |
|
176 { "]", |
|
177 "Return list delimiter. See also `['.\n", }, |
|
178 |
|
179 { "^", |
|
180 "Power operator. See also `**', `.^', and `.**.'\n", }, |
|
181 |
|
182 { "|", |
|
183 "Logical or operator. See also `||'.\n", }, |
|
184 |
|
185 { "||", |
|
186 "Logical or operator. See also `|'.\n", }, |
|
187 |
|
188 { "~", |
|
189 "Logical not operator. See also `!' and `~'.\n", }, |
|
190 |
|
191 { "~=", |
|
192 "Logical not equals operator. See also `<>' and `!='.\n", }, |
|
193 |
529
|
194 { 0, 0, }, |
1
|
195 }; |
|
196 |
|
197 static help_list keywords[] = |
|
198 { |
|
199 { "break", |
|
200 "Exit the innermost enclosing while or for loop.\n", }, |
|
201 |
|
202 { "continue", |
|
203 "Jump to the end of the innermost enclosing while or for loop.\n", }, |
|
204 |
|
205 { "else", |
|
206 "Alternate action for an if block.\n", }, |
|
207 |
|
208 { "elseif", |
|
209 "Alternate conditional test for an if block.\n", }, |
|
210 |
|
211 { "end", |
|
212 "Mark the end of any for, if, while, or function block.\n", }, |
|
213 |
|
214 { "endfor", |
|
215 "Mark the end of a for loop.\n", }, |
|
216 |
|
217 { "endfunction", |
|
218 "Mark the end of a function.\n", }, |
|
219 |
|
220 { "endif", |
|
221 "Mark the end of an if block.\n", }, |
|
222 |
|
223 { "endwhile", |
|
224 "Mark the end of a while loop.\n", }, |
|
225 |
|
226 { "for", |
|
227 "Begin a for loop.\n", }, |
|
228 |
|
229 { "function", |
|
230 "Begin a function body.\n", }, |
|
231 |
|
232 { "global", |
|
233 "Declare variables to have global scope.\n", }, |
|
234 |
|
235 { "gplot", |
|
236 "Produce 2-D plots using gnuplot-like command syntax.\n", }, |
|
237 |
|
238 { "gsplot", |
|
239 "Produce 3-D plots using gnuplot-like command syntax.\n", }, |
|
240 |
|
241 { "if", |
|
242 "Begin an if block.\n", }, |
|
243 |
|
244 { "return", |
|
245 "Return from a function.\n", }, |
|
246 |
|
247 { "while", |
|
248 "Begin a while loop.\n", }, |
|
249 |
529
|
250 { 0, 0, }, |
1
|
251 }; |
|
252 |
581
|
253 // Return a copy of the operator or keyword names. |
|
254 |
1
|
255 char ** |
|
256 names (help_list *lst, int& count) |
|
257 { |
|
258 count = 0; |
|
259 help_list *ptr = lst; |
529
|
260 while (ptr->name) |
1
|
261 { |
|
262 count++; |
|
263 ptr++; |
|
264 } |
|
265 |
|
266 if (count == 0) |
529
|
267 return 0; |
1
|
268 |
|
269 char **name_list = new char * [count+1]; |
|
270 |
|
271 ptr = lst; |
|
272 int i = 0; |
529
|
273 while (ptr->name) |
1
|
274 { |
242
|
275 name_list[i++] = strsave (ptr->name); |
1
|
276 ptr++; |
|
277 } |
|
278 |
529
|
279 name_list[i] = 0; |
1
|
280 return name_list; |
|
281 } |
|
282 |
|
283 help_list * |
|
284 operator_help (void) |
|
285 { |
|
286 return operators; |
|
287 } |
|
288 |
|
289 help_list * |
|
290 keyword_help (void) |
|
291 { |
|
292 return keywords; |
|
293 } |
|
294 |
542
|
295 void |
|
296 additional_help_message (ostrstream& output_buf) |
|
297 { |
|
298 output_buf |
|
299 << "\n" |
|
300 << "Additional help for builtin functions, operators, and variables\n" |
|
301 << "is available in the on-line version of the manual.\n" |
|
302 << "\n" |
|
303 << "Use the command `help -i <topic>' to search the manual index.\n"; |
|
304 } |
|
305 |
|
306 void |
|
307 print_usage (const char *string, int just_usage) |
|
308 { |
|
309 ostrstream output_buf; |
|
310 |
|
311 symbol_record *sym_rec = global_sym_tab->lookup (string, 0, 0); |
|
312 if (sym_rec) |
|
313 { |
|
314 char *h = sym_rec->help (); |
|
315 if (h && *h) |
|
316 { |
|
317 output_buf << "\n*** " << string << ":\n\n" |
|
318 << h << "\n"; |
|
319 |
|
320 if (! just_usage) |
|
321 additional_help_message (output_buf); |
|
322 output_buf << ends; |
|
323 maybe_page_output (output_buf); |
|
324 } |
|
325 } |
|
326 } |
|
327 |
529
|
328 static void |
542
|
329 display_names_from_help_list (ostrstream& output_buf, help_list *list, |
|
330 const char *desc) |
529
|
331 { |
|
332 int count = 0; |
|
333 char **symbols = names (list, count); |
|
334 output_buf << "\n*** " << desc << ":\n\n"; |
|
335 if (symbols && count > 0) |
|
336 list_in_columns (output_buf, symbols); |
|
337 delete [] symbols; |
|
338 } |
|
339 |
|
340 static void |
542
|
341 display_symtab_names (ostrstream& output_buf, char **names, |
|
342 int count, const char *desc) |
|
343 { |
|
344 output_buf << "\n*** " << desc << ":\n\n"; |
|
345 if (names && count > 0) |
|
346 list_in_columns (output_buf, names); |
|
347 } |
|
348 |
|
349 static void |
529
|
350 simple_help (void) |
|
351 { |
|
352 ostrstream output_buf; |
|
353 |
542
|
354 display_names_from_help_list (output_buf, operator_help (), |
|
355 "operators"); |
529
|
356 |
542
|
357 display_names_from_help_list (output_buf, keyword_help (), |
|
358 "reserved words"); |
529
|
359 |
542
|
360 #ifdef LIST_SYMBOLS |
|
361 #undef LIST_SYMBOLS |
|
362 #endif |
|
363 #define LIST_SYMBOLS(type, msg) \ |
|
364 do \ |
|
365 { \ |
|
366 int count; \ |
|
367 char **names = global_sym_tab->list (count, 1, type); \ |
|
368 display_symtab_names (output_buf, names, count, msg); \ |
|
369 char **ptr = names; \ |
|
370 while (*ptr) \ |
|
371 delete [] *ptr++; \ |
|
372 delete [] names; \ |
|
373 } \ |
|
374 while (0) |
529
|
375 |
542
|
376 // XXX FIXME XXX -- is this distinction needed? |
|
377 LIST_SYMBOLS (symbol_def::TEXT_FUNCTION, |
|
378 "text functions (these names are also reserved)"); |
529
|
379 |
542
|
380 LIST_SYMBOLS (symbol_def::MAPPER_FUNCTION, "mapper functions"); |
|
381 |
|
382 LIST_SYMBOLS (symbol_def::BUILTIN_FUNCTION, "general functions"); |
|
383 |
|
384 LIST_SYMBOLS (symbol_def::BUILTIN_VARIABLE, "builtin variables"); |
|
385 |
529
|
386 // Also need to list variables and currently compiled functions from |
|
387 // the symbol table, if there are any. |
|
388 |
|
389 // Also need to search octave_path for script files. |
|
390 |
|
391 char **path = pathstring_to_vector (user_pref.loadpath); |
|
392 |
|
393 char **ptr = path; |
|
394 if (ptr) |
|
395 { |
|
396 while (*ptr) |
|
397 { |
|
398 int count; |
|
399 char **names = get_fcn_file_names (count, *ptr, 0); |
|
400 output_buf << "\n*** function files in " |
|
401 << make_absolute (*ptr, the_current_working_directory) |
|
402 << ":\n\n"; |
|
403 if (names && count > 0) |
|
404 list_in_columns (output_buf, names); |
|
405 delete [] names; |
|
406 ptr++; |
|
407 } |
|
408 } |
|
409 |
|
410 additional_help_message (output_buf); |
|
411 output_buf << ends; |
|
412 maybe_page_output (output_buf); |
|
413 } |
|
414 |
|
415 static int |
|
416 try_info (const char *string, int force = 0) |
|
417 { |
|
418 int status = 0; |
|
419 |
|
420 char *directory_name = strsave (user_pref.info_file); |
|
421 char *temp = filename_non_directory (directory_name); |
|
422 |
|
423 if (temp != directory_name) |
|
424 { |
|
425 *temp = 0; |
|
426 info_add_path (directory_name, INFOPATH_PREPEND); |
|
427 } |
|
428 |
|
429 delete [] directory_name; |
|
430 |
|
431 NODE *initial_node = info_get_node (user_pref.info_file, 0); |
|
432 |
|
433 if (! initial_node) |
|
434 { |
|
435 warning ("can't find info file!\n"); |
|
436 status = -1; |
|
437 } |
|
438 else |
|
439 { |
|
440 status = initialize_info_session (initial_node, 0); |
|
441 |
|
442 if (status == 0 && (force || index_entry_exists (windows, string))) |
|
443 { |
|
444 terminal_clear_screen (); |
|
445 |
|
446 terminal_prep_terminal (); |
|
447 |
|
448 display_update_display (windows); |
|
449 |
|
450 info_last_executed_command = 0; |
|
451 |
|
452 if (! force) |
|
453 do_info_index_search (windows, 0, string); |
|
454 |
|
455 char *format = replace_in_documentation |
|
456 ("Type \"\\[quit]\" to quit, \"\\[get-help-window]\" for help."); |
|
457 |
|
458 window_message_in_echo_area (format); |
|
459 |
|
460 info_read_and_dispatch (); |
|
461 |
|
462 terminal_goto_xy (0, screenheight - 1); |
|
463 |
|
464 terminal_clear_to_eol (); |
|
465 |
|
466 terminal_unprep_terminal (); |
|
467 |
|
468 status = 1; |
|
469 } |
|
470 |
|
471 finish_info_session (initial_node, 0); |
|
472 } |
|
473 |
|
474 return status; |
|
475 } |
|
476 |
542
|
477 int |
|
478 help_from_list (ostrstream& output_buf, const help_list *list, |
|
479 const char *string, int usage) |
|
480 { |
|
481 char *name; |
|
482 while ((name = list->name) != 0) |
|
483 { |
|
484 if (strcmp (name, string) == 0) |
|
485 { |
|
486 if (usage) |
|
487 output_buf << "\nusage: "; |
|
488 else |
|
489 { |
|
490 output_buf << "\n*** " << string << ":\n\n"; |
|
491 } |
|
492 |
|
493 output_buf << list->help << "\n"; |
|
494 |
|
495 return 1; |
|
496 } |
|
497 list++; |
|
498 } |
|
499 return 0; |
|
500 } |
|
501 |
529
|
502 DEFUN_TEXT ("help", Fhelp, Shelp, -1, 1, |
|
503 "help [-i] [topic ...]\n\ |
|
504 \n\ |
|
505 print cryptic yet witty messages") |
|
506 { |
|
507 Octave_object retval; |
|
508 |
|
509 DEFINE_ARGV("help"); |
|
510 |
|
511 if (argc == 1) |
|
512 { |
|
513 simple_help (); |
|
514 } |
|
515 else |
|
516 { |
|
517 if (argv[1] && strcmp (argv[1], "-i") == 0) |
|
518 { |
|
519 argc--; |
|
520 argv++; |
|
521 |
|
522 if (argc == 1) |
|
523 { |
|
524 volatile sig_handler *old_sigint_handler; |
|
525 old_sigint_handler = signal (SIGINT, SIG_IGN); |
|
526 |
|
527 try_info (0, 1); |
|
528 |
|
529 signal (SIGINT, old_sigint_handler); |
|
530 } |
|
531 else |
|
532 { |
|
533 while (--argc > 0) |
|
534 { |
|
535 argv++; |
|
536 |
|
537 if (! *argv || ! **argv) |
|
538 continue; |
|
539 |
|
540 volatile sig_handler *old_sigint_handler; |
|
541 old_sigint_handler = signal (SIGINT, SIG_IGN); |
|
542 |
|
543 if (! try_info (*argv)) |
|
544 { |
|
545 message ("help", |
|
546 "sorry, `%s' is not indexed in the manual", |
|
547 *argv); |
|
548 sleep (2); |
|
549 } |
|
550 |
|
551 signal (SIGINT, old_sigint_handler); |
|
552 } |
|
553 } |
|
554 } |
|
555 else |
|
556 { |
|
557 ostrstream output_buf; |
|
558 |
|
559 help_list *op_help_list = operator_help (); |
|
560 help_list *kw_help_list = keyword_help (); |
|
561 |
|
562 while (--argc > 0) |
|
563 { |
|
564 argv++; |
|
565 |
|
566 if (! *argv || ! **argv) |
|
567 continue; |
|
568 |
|
569 if (help_from_list (output_buf, op_help_list, *argv, 0)) |
|
570 continue; |
|
571 |
|
572 if (help_from_list (output_buf, kw_help_list, *argv, 0)) |
|
573 continue; |
|
574 |
581
|
575 symbol_record *sym_rec = lookup_by_name (*argv); |
|
576 |
529
|
577 if (sym_rec) |
|
578 { |
|
579 char *h = sym_rec->help (); |
|
580 if (h && *h) |
|
581 { |
|
582 output_buf << "\n*** " << *argv << ":\n\n" |
|
583 << h << "\n"; |
|
584 continue; |
|
585 } |
|
586 } |
|
587 |
|
588 output_buf << "\nhelp: sorry, `" << *argv |
581
|
589 << "' is not documented\n"; |
529
|
590 } |
|
591 |
|
592 additional_help_message (output_buf); |
|
593 output_buf << ends; |
|
594 maybe_page_output (output_buf); |
|
595 } |
|
596 } |
|
597 |
|
598 DELETE_ARGV; |
|
599 |
|
600 return retval; |
|
601 } |
|
602 |
581
|
603 DEFUN_TEXT ("type", Ftype, Stype, -1, 1, |
|
604 "type NAME ...]\n\ |
|
605 \n\ |
|
606 display the definition of each NAME that refers to a function") |
|
607 { |
|
608 Octave_object retval; |
|
609 |
|
610 DEFINE_ARGV("type"); |
|
611 |
|
612 if (argc > 1) |
|
613 { |
|
614 // XXX FIXME XXX -- we should really use getopt () |
|
615 int quiet = 0; |
|
616 if (argv[1] && strcmp (argv[1], "-q") == 0) |
|
617 { |
|
618 quiet = 1; |
|
619 argc--; |
|
620 argv++; |
|
621 } |
|
622 |
|
623 ostrstream output_buf; |
|
624 |
|
625 while (--argc > 0) |
|
626 { |
|
627 argv++; |
|
628 |
|
629 if (! *argv || ! **argv) |
|
630 continue; |
|
631 |
|
632 symbol_record *sym_rec = lookup_by_name (*argv); |
|
633 |
|
634 if (sym_rec) |
|
635 { |
|
636 if (sym_rec->is_user_function ()) |
|
637 { |
|
638 tree_fvc *defn = sym_rec->def (); |
|
639 |
|
640 if (nargout == 0 && ! quiet) |
|
641 output_buf << *argv << " is a user-defined function\n"; |
|
642 |
|
643 defn->print_code (output_buf); |
|
644 } |
|
645 |
|
646 // XXX FIXME XXX -- this code should be shared with Fwhich |
|
647 |
|
648 else if (sym_rec->is_text_function ()) |
|
649 output_buf << *argv << " is a builtin text-function\n"; |
|
650 else if (sym_rec->is_builtin_function ()) |
|
651 output_buf << *argv << " is a builtin function\n"; |
|
652 else if (sym_rec->is_user_variable ()) |
|
653 output_buf << *argv << " is a user-defined variable\n"; |
|
654 else if (sym_rec->is_builtin_variable ()) |
|
655 output_buf << *argv << " is a builtin variable\n"; |
|
656 else |
|
657 output_buf << "type: `" << *argv << "' has unknown type!\n"; |
|
658 } |
|
659 else |
|
660 output_buf << "type: `" << *argv << "' undefined\n"; |
|
661 } |
|
662 |
|
663 output_buf << ends; |
|
664 |
|
665 if (nargout == 0) |
|
666 maybe_page_output (output_buf); |
|
667 else |
|
668 { |
|
669 char *s = output_buf.str (); |
|
670 retval = s; |
|
671 delete s; |
|
672 } |
|
673 } |
|
674 else |
|
675 print_usage ("type"); |
|
676 |
|
677 DELETE_ARGV; |
|
678 |
|
679 return retval; |
|
680 } |
|
681 |
|
682 DEFUN_TEXT ("which", Fwhich, Swhich, -1, 1, |
|
683 "which NAME ...]\n\ |
|
684 \n\ |
|
685 display the type of each NAME. If NAME is defined from an function\n\ |
|
686 file, print the full name of the file.") |
|
687 { |
|
688 Octave_object retval; |
|
689 |
|
690 DEFINE_ARGV("which"); |
|
691 |
|
692 if (argc > 1) |
|
693 { |
|
694 if (nargout > 0) |
|
695 retval.resize (argc-1, Matrix ()); |
|
696 |
|
697 ostrstream output_buf; |
|
698 |
|
699 for (int i = 0; i < argc-1; i++) |
|
700 { |
|
701 argv++; |
|
702 |
|
703 if (! *argv || ! **argv) |
|
704 continue; |
|
705 |
|
706 symbol_record *sym_rec = lookup_by_name (*argv); |
|
707 |
|
708 if (sym_rec) |
|
709 { |
|
710 if (sym_rec->is_user_function ()) |
|
711 { |
|
712 tree_fvc *defn = sym_rec->def (); |
|
713 char *fn = defn->fcn_file_name (); |
|
714 if (fn) |
|
715 { |
|
716 char *ff = fcn_file_in_path (fn); |
|
717 ff = ff ? ff : fn; |
|
718 |
|
719 if (nargout == 0) |
|
720 output_buf << *argv |
|
721 << " is the function defined from:\n" |
|
722 << ff << "\n"; |
|
723 else |
|
724 retval(i) = ff; |
|
725 } |
|
726 else |
|
727 { |
|
728 if (nargout == 0) |
|
729 output_buf << *argv << " is a user-defined function\n"; |
|
730 else |
|
731 retval(i) = "user-defined function"; |
|
732 } |
|
733 } |
|
734 else if (sym_rec->is_text_function ()) |
|
735 { |
|
736 if (nargout == 0) |
|
737 output_buf << *argv << " is a builtin text-function\n"; |
|
738 else |
|
739 retval(i) = "builtin text-function"; |
|
740 } |
|
741 else if (sym_rec->is_builtin_function ()) |
|
742 { |
|
743 if (nargout == 0) |
|
744 output_buf << *argv << " is a builtin function\n"; |
|
745 else |
|
746 retval(i) = "builtin function"; |
|
747 } |
|
748 else if (sym_rec->is_user_variable ()) |
|
749 { |
|
750 if (nargout == 0) |
|
751 output_buf << *argv << " is a user-defined variable\n"; |
|
752 else |
|
753 retval(i) = "user-defined variable"; |
|
754 } |
|
755 else if (sym_rec->is_builtin_variable ()) |
|
756 { |
|
757 if (nargout == 0) |
|
758 output_buf << *argv << " is a builtin variable\n"; |
|
759 else |
|
760 retval(i) = "builtin variable"; |
|
761 } |
|
762 else |
|
763 { |
|
764 if (nargout == 0) |
|
765 output_buf << "which: `" << *argv |
|
766 << "' has unknown type\n"; |
|
767 else |
|
768 retval(i) = "unknown type"; |
|
769 } |
|
770 } |
|
771 else |
|
772 { |
|
773 if (nargout == 0) |
|
774 output_buf << "which: `" << *argv << "' is undefined\n"; |
|
775 else |
|
776 retval(i) = "undefined"; |
|
777 } |
|
778 } |
|
779 output_buf << ends; |
|
780 maybe_page_output (output_buf); |
|
781 } |
|
782 else |
|
783 print_usage ("which"); |
|
784 |
|
785 DELETE_ARGV; |
|
786 |
|
787 return retval; |
|
788 } |
|
789 |
1
|
790 /* |
|
791 ;;; Local Variables: *** |
|
792 ;;; mode: C++ *** |
|
793 ;;; page-delimiter: "^/\\*" *** |
|
794 ;;; End: *** |
|
795 */ |