comparison src/help.cc @ 742:9004af8c7a33

[project @ 1994-09-30 14:50:32 by jwe]
author jwe
date Fri, 30 Sep 1994 14:53:08 +0000
parents 93c63deed7aa
children b6b78f85743a
comparison
equal deleted inserted replaced
741:2d2f3c07cedd 742:9004af8c7a33
340 if (symbols && count > 0) 340 if (symbols && count > 0)
341 list_in_columns (output_buf, symbols); 341 list_in_columns (output_buf, symbols);
342 delete [] symbols; 342 delete [] symbols;
343 } 343 }
344 344
345 static char *
346 print_symbol_type (ostrstream& output_buf, symbol_record *sym_rec,
347 char *name, int print)
348 {
349 char *retval = 0;
350
351 if (sym_rec->is_user_function ())
352 {
353 tree_fvc *defn = sym_rec->def ();
354 char *fn = defn->fcn_file_name ();
355 if (fn)
356 {
357 char *ff = fcn_file_in_path (fn);
358 ff = ff ? ff : fn;
359
360 if (print)
361 output_buf << name
362 << " is the function defined from:\n"
363 << ff << "\n";
364 else
365 retval = ff;
366 }
367 else
368 {
369 if (print)
370 output_buf << name << " is a user-defined function\n";
371 else
372 retval = "user-defined function";
373 }
374 }
375 else if (sym_rec->is_text_function ())
376 {
377 if (print)
378 output_buf << name << " is a builtin text-function\n";
379 else
380 retval = "builtin text-function";
381 }
382 else if (sym_rec->is_builtin_function ())
383 {
384 if (print)
385 output_buf << name << " is a builtin function\n";
386 else
387 retval = "builtin function";
388 }
389 else if (sym_rec->is_user_variable ())
390 {
391 if (print)
392 output_buf << name << " is a user-defined variable\n";
393 else
394 retval = "user-defined variable";
395 }
396 else if (sym_rec->is_builtin_variable ())
397 {
398 if (print)
399 output_buf << name << " is a builtin variable\n";
400 else
401 retval = "builtin variable";
402 }
403 else
404 {
405 if (print)
406 output_buf << "which: `" << name
407 << "' has unknown type\n";
408 else
409 retval = "unknown type";
410 }
411
412 return retval;
413 }
414
345 static void 415 static void
346 display_symtab_names (ostrstream& output_buf, char **names, 416 display_symtab_names (ostrstream& output_buf, char **names,
347 int count, const char *desc) 417 int count, const char *desc)
348 { 418 {
349 output_buf << "\n*** " << desc << ":\n\n"; 419 output_buf << "\n*** " << desc << ":\n\n";
592 if (sym_rec) 662 if (sym_rec)
593 { 663 {
594 char *h = sym_rec->help (); 664 char *h = sym_rec->help ();
595 if (h && *h) 665 if (h && *h)
596 { 666 {
597 output_buf << "\n*** " << *argv << ":\n\n" 667 print_symbol_type (output_buf, sym_rec, *argv, 1);
598 << h << "\n"; 668 output_buf << "\n" << h << "\n";
599 continue; 669 continue;
600 } 670 }
601 } 671 }
602 672
603 output_buf << "\nhelp: sorry, `" << *argv 673 output_buf << "\nhelp: sorry, `" << *argv
740 810
741 symbol_record *sym_rec = lookup_by_name (*argv); 811 symbol_record *sym_rec = lookup_by_name (*argv);
742 812
743 if (sym_rec) 813 if (sym_rec)
744 { 814 {
745 if (sym_rec->is_user_function ()) 815 int print = (nargout == 0);
746 { 816 char *tmp = print_symbol_type (output_buf, sym_rec,
747 tree_fvc *defn = sym_rec->def (); 817 *argv, print);
748 char *fn = defn->fcn_file_name (); 818 if (! print)
749 if (fn) 819 retval(i) = tmp;
750 {
751 char *ff = fcn_file_in_path (fn);
752 ff = ff ? ff : fn;
753
754 if (nargout == 0)
755 output_buf << *argv
756 << " is the function defined from:\n"
757 << ff << "\n";
758 else
759 retval(i) = ff;
760 }
761 else
762 {
763 if (nargout == 0)
764 output_buf << *argv << " is a user-defined function\n";
765 else
766 retval(i) = "user-defined function";
767 }
768 }
769 else if (sym_rec->is_text_function ())
770 {
771 if (nargout == 0)
772 output_buf << *argv << " is a builtin text-function\n";
773 else
774 retval(i) = "builtin text-function";
775 }
776 else if (sym_rec->is_builtin_function ())
777 {
778 if (nargout == 0)
779 output_buf << *argv << " is a builtin function\n";
780 else
781 retval(i) = "builtin function";
782 }
783 else if (sym_rec->is_user_variable ())
784 {
785 if (nargout == 0)
786 output_buf << *argv << " is a user-defined variable\n";
787 else
788 retval(i) = "user-defined variable";
789 }
790 else if (sym_rec->is_builtin_variable ())
791 {
792 if (nargout == 0)
793 output_buf << *argv << " is a builtin variable\n";
794 else
795 retval(i) = "builtin variable";
796 }
797 else
798 {
799 if (nargout == 0)
800 output_buf << "which: `" << *argv
801 << "' has unknown type\n";
802 else
803 retval(i) = "unknown type";
804 }
805 } 820 }
806 else 821 else
807 { 822 {
808 if (nargout == 0) 823 if (nargout == 0)
809 output_buf << "which: `" << *argv << "' is undefined\n"; 824 output_buf << "which: `" << *argv << "' is undefined\n";