Mercurial > hg > octave-lyh
comparison src/variables.cc @ 1418:3a86d9f74dc9
[project @ 1995-09-16 00:42:56 by jwe]
author | jwe |
---|---|
date | Sat, 16 Sep 1995 00:42:56 +0000 |
parents | 9517c453c9ab |
children | 0bdbc15a112b |
comparison
equal
deleted
inserted
replaced
1417:0bfe95ddc0af | 1418:3a86d9f74dc9 |
---|---|
165 int nargin = fcn->max_expected_args (); | 165 int nargin = fcn->max_expected_args (); |
166 int e_nargin = expected_nargin; | 166 int e_nargin = expected_nargin; |
167 if (nargin != e_nargin) | 167 if (nargin != e_nargin) |
168 { | 168 { |
169 if (warn) | 169 if (warn) |
170 error ("%s: expecting function to take %d argument%s", | 170 error ("%s: expecting function to take %d argument%s", |
171 warn_for, e_nargin, (e_nargin == 1 ? "" : "s")); | 171 warn_for, e_nargin, (e_nargin == 1 ? "" : "s")); |
172 return 0; | 172 return 0; |
173 } | 173 } |
174 return 1; | 174 return 1; |
175 } | 175 } |
205 | 205 |
206 DEFUN ("exist", Fexist, Sexist, 1, 1, | 206 DEFUN ("exist", Fexist, Sexist, 1, 1, |
207 "exist (NAME): check if variable or file exists\n\ | 207 "exist (NAME): check if variable or file exists\n\ |
208 \n\ | 208 \n\ |
209 return 0 if NAME is undefined, 1 if it is a variable, or 2 if it is\n\ | 209 return 0 if NAME is undefined, 1 if it is a variable, or 2 if it is\n\ |
210 a function.") | 210 a function.") |
211 { | 211 { |
212 Octave_object retval; | 212 Octave_object retval; |
213 | 213 |
214 int nargin = args.length (); | 214 int nargin = args.length (); |
215 | 215 |
330 // Is this really a good way to do this? | 330 // Is this really a good way to do this? |
331 | 331 |
332 while (count >= 0) | 332 while (count >= 0) |
333 { | 333 { |
334 p2 = strstr (p1, prefix); | 334 p2 = strstr (p1, prefix); |
335 | 335 |
336 if (! p2) | 336 if (! p2) |
337 { | 337 { |
338 memcpy (pdest, p1, strlen (p1)+1); | 338 memcpy (pdest, p1, strlen (p1)+1); |
339 break; | 339 break; |
340 } | 340 } |
436 // If the path starts with `:', prepend the standard path. If it ends | 436 // If the path starts with `:', prepend the standard path. If it ends |
437 // with `:' append the standard path. If it begins and ends with | 437 // with `:' append the standard path. If it begins and ends with |
438 // `:', do both (which is useless, but the luser asked for it...). | 438 // `:', do both (which is useless, but the luser asked for it...). |
439 // | 439 // |
440 // This function may eventually be called more than once, so be | 440 // This function may eventually be called more than once, so be |
441 // careful not to create memory leaks. | 441 // careful not to create memory leaks. |
442 | 442 |
443 char * | 443 char * |
444 default_path (void) | 444 default_path (void) |
445 { | 445 { |
446 static char *std_path = subst_octave_home (OCTAVE_FCNFILEPATH); | 446 static char *std_path = subst_octave_home (OCTAVE_FCNFILEPATH); |
542 } | 542 } |
543 } | 543 } |
544 return 0; | 544 return 0; |
545 } | 545 } |
546 | 546 |
547 // Eat whitespace and comments from FFILE, returning the first block | |
548 // of comments. If SKIP_COPYRIGHT, keep reading until the first block | |
549 // of comments that doesn't look like a copyright notice. | |
550 | |
547 static char * | 551 static char * |
548 gobble_leading_white_space (FILE *ffile) | 552 gobble_leading_white_space (FILE *ffile, int skip_copyright) |
549 { | 553 { |
550 ostrstream buf; | 554 ostrstream buf; |
551 | 555 |
552 int first_comments_seen = 0; | 556 int first_comments_seen = 0; |
553 int have_help_text = 0; | 557 int have_help_text = 0; |
567 if (c == '\n') | 571 if (c == '\n') |
568 { | 572 { |
569 input_line_number++; | 573 input_line_number++; |
570 current_input_column = 0; | 574 current_input_column = 0; |
571 in_comment = 0; | 575 in_comment = 0; |
576 if ((c = getc (ffile)) != EOF) | |
577 { | |
578 current_input_column--; | |
579 ungetc (c, ffile); | |
580 if (c == '\n') | |
581 break; | |
582 } | |
583 else | |
584 break; | |
572 } | 585 } |
573 } | 586 } |
574 else | 587 else |
575 { | 588 { |
576 switch (c) | 589 switch (c) |
604 done: | 617 done: |
605 | 618 |
606 buf << ends; | 619 buf << ends; |
607 char *help_txt = buf.str (); | 620 char *help_txt = buf.str (); |
608 | 621 |
609 if (! help_txt || ! *help_txt || looks_like_octave_copyright (help_txt)) | 622 if (skip_copyright && help_txt && looks_like_octave_copyright (help_txt)) |
610 { | 623 { |
611 delete help_txt; | 624 delete [] help_txt; |
625 help_txt = gobble_leading_white_space (ffile, skip_copyright); | |
626 } | |
627 | |
628 if (help_txt && ! *help_txt) | |
629 { | |
630 delete [] help_txt; | |
612 help_txt = 0; | 631 help_txt = 0; |
613 } | 632 } |
614 | 633 |
615 return help_txt; | 634 return help_txt; |
616 } | 635 } |
665 if (ffile) | 684 if (ffile) |
666 { | 685 { |
667 // Check to see if this file defines a function or is just a | 686 // Check to see if this file defines a function or is just a |
668 // list of commands. | 687 // list of commands. |
669 | 688 |
670 char *tmp_help_txt = gobble_leading_white_space (ffile); | 689 char *tmp_help_txt = gobble_leading_white_space (ffile, 0); |
671 | 690 |
672 if (is_function_file (ffile)) | 691 if (is_function_file (ffile)) |
673 { | 692 { |
674 unwind_protect_int (echo_input); | 693 unwind_protect_int (echo_input); |
675 unwind_protect_int (saving_history); | 694 unwind_protect_int (saving_history); |
813 if (path && *path) | 832 if (path && *path) |
814 { | 833 { |
815 FILE *fptr = fopen (path, "r"); | 834 FILE *fptr = fopen (path, "r"); |
816 if (fptr) | 835 if (fptr) |
817 { | 836 { |
818 char *help_txt = gobble_leading_white_space (fptr); | 837 char *help_txt = gobble_leading_white_space (fptr, 1); |
819 fclose (fptr); | 838 fclose (fptr); |
820 return help_txt; | 839 return help_txt; |
821 } | 840 } |
822 } | 841 } |
823 return 0; | 842 return 0; |
857 return retval; | 876 return retval; |
858 } | 877 } |
859 | 878 |
860 // Look for the given name in the global symbol table. If it refers | 879 // Look for the given name in the global symbol table. If it refers |
861 // to a real scalar, place the value in d and return 0. Otherwise, | 880 // to a real scalar, place the value in d and return 0. Otherwise, |
862 // return -1. | 881 // return -1. |
863 | 882 |
864 int | 883 int |
865 builtin_real_scalar_variable (const char *name, double& d) | 884 builtin_real_scalar_variable (const char *name, double& d) |
866 { | 885 { |
867 int status = -1; | 886 int status = -1; |
910 | 929 |
911 // Global stuff and links to builtin variables and functions. | 930 // Global stuff and links to builtin variables and functions. |
912 | 931 |
913 // Make the definition of the symbol record sr be the same as the | 932 // Make the definition of the symbol record sr be the same as the |
914 // definition of the global variable of the same name, creating it if | 933 // definition of the global variable of the same name, creating it if |
915 // it doesn't already exist. | 934 // it doesn't already exist. |
916 | 935 |
917 void | 936 void |
918 link_to_global_variable (symbol_record *sr) | 937 link_to_global_variable (symbol_record *sr) |
919 { | 938 { |
920 if (sr->is_linked_to_global ()) | 939 if (sr->is_linked_to_global ()) |
1032 ffl = get_fcn_file_names (ffl_len, 1); | 1051 ffl = get_fcn_file_names (ffl_len, 1); |
1033 | 1052 |
1034 int total_len = key_len + glb_len + top_len + lcl_len + ffl_len; | 1053 int total_len = key_len + glb_len + top_len + lcl_len + ffl_len; |
1035 | 1054 |
1036 char **list = new char * [total_len+1]; | 1055 char **list = new char * [total_len+1]; |
1037 | 1056 |
1038 // Put all the symbols in one big list. Only copy pointers, not the | 1057 // Put all the symbols in one big list. Only copy pointers, not the |
1039 // strings they point to, then only delete the original array of | 1058 // strings they point to, then only delete the original array of |
1040 // pointers, and not the strings they point to. | 1059 // pointers, and not the strings they point to. |
1041 | 1060 |
1042 int j = 0; | 1061 int j = 0; |
1199 | 1218 |
1200 if (strcmp (*argv, "-all") == 0 || strcmp (*argv, "-a") == 0) | 1219 if (strcmp (*argv, "-all") == 0 || strcmp (*argv, "-a") == 0) |
1201 { | 1220 { |
1202 show_builtins++; | 1221 show_builtins++; |
1203 show_functions++; | 1222 show_functions++; |
1204 show_variables++; | 1223 show_variables++; |
1205 } | 1224 } |
1206 else if (strcmp (*argv, "-builtins") == 0 || strcmp (*argv, "-b") == 0) | 1225 else if (strcmp (*argv, "-builtins") == 0 || strcmp (*argv, "-b") == 0) |
1207 show_builtins++; | 1226 show_builtins++; |
1208 else if (strcmp (*argv, "-functions") == 0 || strcmp (*argv, "-f") == 0) | 1227 else if (strcmp (*argv, "-functions") == 0 || strcmp (*argv, "-f") == 0) |
1209 show_functions++; | 1228 show_functions++; |
1253 if (show_variables) | 1272 if (show_variables) |
1254 { | 1273 { |
1255 pad_after += maybe_list ("*** local user variables:", argv, argc, | 1274 pad_after += maybe_list ("*** local user variables:", argv, argc, |
1256 output_buf, show_verbose, curr_sym_tab, | 1275 output_buf, show_verbose, curr_sym_tab, |
1257 symbol_def::USER_VARIABLE, | 1276 symbol_def::USER_VARIABLE, |
1258 SYMTAB_LOCAL_SCOPE); | 1277 SYMTAB_LOCAL_SCOPE); |
1259 | 1278 |
1260 pad_after += maybe_list ("*** globally visible user variables:", | 1279 pad_after += maybe_list ("*** globally visible user variables:", |
1261 argv, argc, output_buf, show_verbose, | 1280 argv, argc, output_buf, show_verbose, |
1262 curr_sym_tab, symbol_def::USER_VARIABLE, | 1281 curr_sym_tab, symbol_def::USER_VARIABLE, |
1263 SYMTAB_GLOBAL_SCOPE); | 1282 SYMTAB_GLOBAL_SCOPE); |
1482 | 1501 |
1483 if (eternal) | 1502 if (eternal) |
1484 sr->make_eternal (); | 1503 sr->make_eternal (); |
1485 | 1504 |
1486 if (help) | 1505 if (help) |
1487 sr->document (help); | 1506 sr->document (help); |
1488 } | 1507 } |
1489 | 1508 |
1490 void | 1509 void |
1491 bind_builtin_variable (const char *varname, const tree_constant& val, | 1510 bind_builtin_variable (const char *varname, const tree_constant& val, |
1492 int protect, int eternal, sv_Function sv_fcn, | 1511 int protect, int eternal, sv_Function sv_fcn, |
1500 install_builtin_variables (void) | 1519 install_builtin_variables (void) |
1501 { | 1520 { |
1502 // XXX FIXME XX -- these should probably be moved to where they | 1521 // XXX FIXME XX -- these should probably be moved to where they |
1503 // logically belong instead of being all grouped here. | 1522 // logically belong instead of being all grouped here. |
1504 | 1523 |
1505 DEFVAR ("EDITOR", SBV_EDITOR, editor, 0, 0, 1, sv_editor, | 1524 DEFVAR ("EDITOR", SBV_EDITOR, editor, 0, sv_editor, |
1506 "name of the editor to be invoked by the edit_history command"); | 1525 "name of the editor to be invoked by the edit_history command"); |
1507 | 1526 |
1508 DEFVAR ("I", SBV_I, Complex (0.0, 1.0), 0, 1, 1, 0, | 1527 DEFCONST ("I", SBV_I, Complex (0.0, 1.0), 0, 0, |
1509 "sqrt (-1)"); | 1528 "sqrt (-1)"); |
1510 | 1529 |
1511 DEFVAR ("Inf", SBV_Inf, octave_Inf, 0, 1, 1, 0, | 1530 DEFCONST ("Inf", SBV_Inf, octave_Inf, 0, 0, |
1512 "infinity"); | 1531 "infinity"); |
1513 | 1532 |
1514 DEFVAR ("INFO_FILE", SBV_INFO_FILE, info_file, 0, 0, 1, sv_info_file, | 1533 DEFVAR ("INFO_FILE", SBV_INFO_FILE, info_file, 0, sv_info_file, |
1515 "name of the Octave info file"); | 1534 "name of the Octave info file"); |
1516 | 1535 |
1517 DEFVAR ("J", SBV_J, Complex (0.0, 1.0), 0, 1, 1, 0, | 1536 DEFCONST ("J", SBV_J, Complex (0.0, 1.0), 0, 0, |
1518 "sqrt (-1)"); | 1537 "sqrt (-1)"); |
1519 | 1538 |
1520 DEFVAR ("NaN", SBV_NaN, octave_NaN, 0, 1, 1, 0, | 1539 DEFCONST ("NaN", SBV_NaN, octave_NaN, 0, 0, |
1521 "not a number"); | 1540 "not a number"); |
1522 | 1541 |
1523 DEFVAR ("LOADPATH", SBV_LOADPATH, load_path, 0, 0, 1, sv_loadpath, | 1542 DEFVAR ("LOADPATH", SBV_LOADPATH, load_path, 0, sv_loadpath, |
1524 "colon separated list of directories to search for scripts"); | 1543 "colon separated list of directories to search for scripts"); |
1525 | 1544 |
1526 DEFVAR ("IMAGEPATH", SBV_IMAGEPATH, OCTAVE_IMAGEPATH, 0, 0, 1, | 1545 DEFVAR ("IMAGEPATH", SBV_IMAGEPATH, OCTAVE_IMAGEPATH, 0, |
1527 sv_imagepath, | 1546 sv_imagepath, |
1528 "colon separated list of directories to search for image files"); | 1547 "colon separated list of directories to search for image files"); |
1529 | 1548 |
1530 DEFVAR ("OCTAVE_VERSION", SBV_version, OCTAVE_VERSION, 0, 1, 1, 0, | 1549 DEFCONST ("OCTAVE_VERSION", SBV_version, OCTAVE_VERSION, 0, 0, |
1531 "Octave version"); | 1550 "Octave version"); |
1532 | 1551 |
1533 DEFVAR ("PAGER", SBV_PAGER, default_pager (), 0, 0, 1, sv_pager_binary, | 1552 DEFVAR ("PAGER", SBV_PAGER, default_pager (), 0, sv_pager_binary, |
1534 "path to pager binary"); | 1553 "path to pager binary"); |
1535 | 1554 |
1536 DEFVAR ("PS1", SBV_PS1, "\\s:\\#> ", 0, 0, 1, sv_ps1, | 1555 DEFVAR ("PS1", SBV_PS1, "\\s:\\#> ", 0, sv_ps1, |
1537 "primary prompt string"); | 1556 "primary prompt string"); |
1538 | 1557 |
1539 DEFVAR ("PS2", SBV_PS2, "> ", 0, 0, 1, sv_ps2, | 1558 DEFVAR ("PS2", SBV_PS2, "> ", 0, sv_ps2, |
1540 "secondary prompt string"); | 1559 "secondary prompt string"); |
1541 | 1560 |
1542 DEFVAR ("PS4", SBV_PS4, "+ ", 0, 0, 1, sv_ps4, | 1561 DEFVAR ("PS4", SBV_PS4, "+ ", 0, sv_ps4, |
1543 "string printed before echoed input (enabled by --echo-input)"); | 1562 "string printed before echoed input (enabled by --echo-input)"); |
1544 | 1563 |
1545 DEFVAR ("PWD", SBV_PWD, get_working_directory ("initialize_globals"), | 1564 DEFCONST ("PWD", SBV_PWD, |
1546 0, 1, 1, sv_pwd, | 1565 get_working_directory ("initialize_globals"), 0, sv_pwd, |
1547 "current working directory"); | 1566 "current working directory"); |
1548 | 1567 |
1549 DEFVAR ("SEEK_SET", SBV_SEEK_SET, 0.0, 0, 1, 1, 0, | 1568 DEFCONST ("SEEK_SET", SBV_SEEK_SET, 0.0, 0, 0, |
1550 "used with fseek to position file relative to the beginning"); | 1569 "used with fseek to position file relative to the beginning"); |
1551 | 1570 |
1552 DEFVAR ("SEEK_CUR", SBV_SEEK_CUR, 1.0, 0, 1, 1, 0, | 1571 DEFCONST ("SEEK_CUR", SBV_SEEK_CUR, 1.0, 0, 0, |
1553 "used with fseek to position file relative to the current position"); | 1572 "used with fseek to position file relative to the current position"); |
1554 | 1573 |
1555 DEFVAR ("SEEK_END", SBV_SEEK_END, 2.0, 0, 1, 1, 0, | 1574 DEFCONST ("SEEK_END", SBV_SEEK_END, 2.0, 0, 0, |
1556 "used with fseek to position file relative to the end"); | 1575 "used with fseek to position file relative to the end"); |
1557 | 1576 |
1558 DEFVAR ("ans", SBV_ans, , 0, 0, 1, 0, | 1577 DEFVAR ("ans", SBV_ans, , 0, 0, |
1559 ""); | 1578 ""); |
1560 | 1579 |
1561 DEFVAR ("argv", SBV_argv, , 0, 1, 1, 0, | 1580 DEFCONST ("argv", SBV_argv, , 0, 0, |
1562 "the command line arguments this program was invoked with"); | 1581 "the command line arguments this program was invoked with"); |
1563 | 1582 |
1564 DEFVAR ("automatic_replot", SBV_automatic_replot, "false", | 1583 DEFVAR ("automatic_replot", SBV_automatic_replot, "false", |
1565 0, 0, 1, automatic_replot, | 1584 0, automatic_replot, |
1566 "if true, auto-insert a replot command when a plot changes"); | 1585 "if true, auto-insert a replot command when a plot changes"); |
1567 | 1586 |
1568 DEFVAR ("default_return_value", SBV_default_return_value, Matrix (), | 1587 DEFVAR ("default_return_value", SBV_default_return_value, Matrix (), |
1569 0, 0, 1, 0, | 1588 0, 0, |
1570 "the default for value for unitialized variables returned from\n\ | 1589 "the default for value for unitialized variables returned from\n\ |
1571 functions. Only used if the variable initialize_return_values is\n\ | 1590 functions. Only used if the variable initialize_return_values is\n\ |
1572 set to \"true\"."); | 1591 set to \"true\"."); |
1573 | 1592 |
1574 DEFVAR ("default_save_format", SBV_default_save_format, "ascii", | 1593 DEFVAR ("default_save_format", SBV_default_save_format, "ascii", |
1575 0, 0, 1, sv_default_save_format, | 1594 0, sv_default_save_format, |
1576 "default format for files created with save, may be one of\n\ | 1595 "default format for files created with save, may be one of\n\ |
1577 \"binary\", \"text\", or \"mat-binary\""); | 1596 \"binary\", \"text\", or \"mat-binary\""); |
1578 | 1597 |
1579 DEFVAR ("define_all_return_values", SBV_define_all_return_values, | 1598 DEFVAR ("define_all_return_values", SBV_define_all_return_values, |
1580 "false", 0, 0, 1, define_all_return_values, | 1599 "false", 0, define_all_return_values, |
1581 "control whether values returned from functions should have a\n\ | 1600 "control whether values returned from functions should have a\n\ |
1582 value even if one has not been explicitly assigned. See also\n\ | 1601 value even if one has not been explicitly assigned. See also\n\ |
1583 default_return_value"); | 1602 default_return_value"); |
1584 | 1603 |
1585 DEFVAR ("do_fortran_indexing", SBV_do_fortran_indexing, "false", 0, 0, | 1604 DEFVAR ("do_fortran_indexing", SBV_do_fortran_indexing, "false", 0, |
1586 1, do_fortran_indexing, | 1605 do_fortran_indexing, |
1587 "allow single indices for matrices"); | 1606 "allow single indices for matrices"); |
1588 | 1607 |
1589 DEFVAR ("empty_list_elements_ok", SBV_empty_list_elements_ok, "warn", | 1608 DEFVAR ("empty_list_elements_ok", SBV_empty_list_elements_ok, |
1590 0, 0, 1, empty_list_elements_ok, | 1609 "warn", 0, empty_list_elements_ok, |
1591 "ignore the empty element in expressions like `a = [[], 1]'"); | 1610 "ignore the empty element in expressions like `a = [[], 1]'"); |
1592 | 1611 |
1593 DEFVAR ("eps", SBV_eps, DBL_EPSILON, 0, 1, 1, 0, | 1612 DEFCONST ("eps", SBV_eps, DBL_EPSILON, 0, 0, |
1594 "machine precision"); | 1613 "machine precision"); |
1595 | 1614 |
1596 DEFVAR ("gnuplot_binary", SBV_gnuplot_binary, "gnuplot", 0, 0, 1, | 1615 DEFVAR ("gnuplot_binary", SBV_gnuplot_binary, "gnuplot", 0, |
1597 sv_gnuplot_binary, | 1616 sv_gnuplot_binary, |
1598 "path to gnuplot binary"); | 1617 "path to gnuplot binary"); |
1599 | 1618 |
1600 DEFVAR ("i", SBV_i, Complex (0.0, 1.0), 1, 1, 1, 0, | 1619 DEFCONST ("i", SBV_i, Complex (0.0, 1.0), 1, 0, |
1601 "sqrt (-1)"); | 1620 "sqrt (-1)"); |
1602 | 1621 |
1603 DEFVAR ("ignore_function_time_stamp", SBV_ignore_function_time_stamp, | 1622 DEFVAR ("ignore_function_time_stamp", |
1604 "system", 0, 0, 1, | 1623 SBV_ignore_function_time_stamp, "system", 0, |
1605 ignore_function_time_stamp, | 1624 ignore_function_time_stamp, |
1606 "don't check to see if function files have changed since they were\n\ | 1625 "don't check to see if function files have changed since they were\n\ |
1607 last compiled. Possible values are \"system\" and \"all\""); | 1626 last compiled. Possible values are \"system\" and \"all\""); |
1608 | 1627 |
1609 DEFVAR ("implicit_str_to_num_ok", SBV_implicit_str_to_num_ok, "false", | 1628 DEFVAR ("implicit_str_to_num_ok", SBV_implicit_str_to_num_ok, |
1610 0, 0, 1, implicit_str_to_num_ok, | 1629 "false", 0, implicit_str_to_num_ok, |
1611 "allow implicit string to number conversion"); | 1630 "allow implicit string to number conversion"); |
1612 | 1631 |
1613 DEFVAR ("inf", SBV_inf, octave_Inf, 0, 1, 1, 0, | 1632 DEFCONST ("inf", SBV_inf, octave_Inf, 0, 0, |
1614 "infinity"); | 1633 "infinity"); |
1615 | 1634 |
1616 DEFVAR ("j", SBV_j, Complex (0.0, 1.0), 1, 1, 1, 0, | 1635 DEFCONST ("j", SBV_j, Complex (0.0, 1.0), 1, 0, |
1617 "sqrt (-1)"); | 1636 "sqrt (-1)"); |
1618 | 1637 |
1619 DEFVAR ("nan", SBV_nan, octave_NaN, 0, 1, 1, 0, | 1638 DEFCONST ("nan", SBV_nan, octave_NaN, 0, 0, |
1620 "not a number"); | 1639 "not a number"); |
1621 | 1640 |
1622 DEFVAR ("ok_to_lose_imaginary_part", SBV_ok_to_lose_imaginary_part, | 1641 DEFVAR ("ok_to_lose_imaginary_part", SBV_ok_to_lose_imaginary_part, |
1623 "warn", 0, 0, 1, ok_to_lose_imaginary_part, | 1642 "warn", 0, ok_to_lose_imaginary_part, |
1624 "silently convert from complex to real by dropping imaginary part"); | 1643 "silently convert from complex to real by dropping imaginary part"); |
1625 | 1644 |
1626 DEFVAR ("output_max_field_width", SBV_output_max_field_width, 10.0, 0, | 1645 DEFVAR ("output_max_field_width", SBV_output_max_field_width, 10.0, |
1627 0, 1, set_output_max_field_width, | 1646 0, set_output_max_field_width, |
1628 "maximum width of an output field for numeric output"); | 1647 "maximum width of an output field for numeric output"); |
1629 | 1648 |
1630 DEFVAR ("output_precision", SBV_output_precision, 5.0, 0, 0, 1, | 1649 DEFVAR ("output_precision", SBV_output_precision, 5.0, 0, |
1631 set_output_precision, | 1650 set_output_precision, |
1632 "number of significant figures to display for numeric output"); | 1651 "number of significant figures to display for numeric output"); |
1633 | 1652 |
1634 DEFVAR ("page_screen_output", SBV_page_screen_output, "true", 0, 0, 1, | 1653 DEFVAR ("page_screen_output", SBV_page_screen_output, "true", 0, |
1635 page_screen_output, | 1654 page_screen_output, |
1636 "if possible, send output intended for the screen through the pager"); | 1655 "if possible, send output intended for the screen through the pager"); |
1637 | 1656 |
1638 DEFVAR ("pi", SBV_pi, 4.0 * atan (1.0), 0, 1, 1, 0, | 1657 DEFCONST ("pi", SBV_pi, 4.0 * atan (1.0), 0, 0, |
1639 "ratio of the circumference of a circle to its diameter"); | 1658 "ratio of the circumference of a circle to its diameter"); |
1640 | 1659 |
1641 DEFVAR ("prefer_column_vectors", SBV_prefer_column_vectors, "true", 0, | 1660 DEFVAR ("prefer_column_vectors", SBV_prefer_column_vectors, "true", |
1642 0, 1, prefer_column_vectors, | 1661 0, prefer_column_vectors, |
1643 "prefer column/row vectors"); | 1662 "prefer column/row vectors"); |
1644 | 1663 |
1645 DEFVAR ("prefer_zero_one_indexing", SBV_prefer_zero_one_indexing, | 1664 DEFVAR ("prefer_zero_one_indexing", SBV_prefer_zero_one_indexing, |
1646 "false", 0, 0, 1, prefer_zero_one_indexing, | 1665 "false", 0, prefer_zero_one_indexing, |
1647 "when there is a conflict, prefer zero-one style indexing"); | 1666 "when there is a conflict, prefer zero-one style indexing"); |
1648 | 1667 |
1649 DEFVAR ("print_answer_id_name", SBV_print_answer_id_name, "true", 0, | 1668 DEFVAR ("print_answer_id_name", SBV_print_answer_id_name, "true", 0, |
1650 0, 1, print_answer_id_name, | 1669 print_answer_id_name, |
1651 "set output style to print `var_name = ...'"); | 1670 "set output style to print `var_name = ...'"); |
1652 | 1671 |
1653 DEFVAR ("print_empty_dimensions", SBV_print_empty_dimensions, "true", | 1672 DEFVAR ("print_empty_dimensions", SBV_print_empty_dimensions, |
1654 0, 0, 1, print_empty_dimensions, | 1673 "true", 0, print_empty_dimensions, |
1655 "also print dimensions of empty matrices"); | 1674 "also print dimensions of empty matrices"); |
1656 | 1675 |
1657 DEFVAR ("program_invocation_name", SBV_program_invocation_name, | 1676 DEFCONST ("program_invocation_name", SBV_program_invocation_name, |
1658 raw_prog_name, 0, 1, 1, 0, | 1677 raw_prog_name, 0, 0, |
1659 "the full name of the current program or script, including the\n\ | 1678 "the full name of the current program or script, including the\n\ |
1660 directory specification"); | 1679 directory specification"); |
1661 | 1680 |
1662 DEFVAR ("program_name", SBV_program_name, prog_name, 0, 1, 1, 0, | 1681 DEFCONST ("program_name", SBV_program_name, prog_name, 0, 0, |
1663 "the name of the current program or script"); | 1682 "the name of the current program or script"); |
1664 | 1683 |
1665 DEFVAR ("propagate_empty_matrices", SBV_propagate_empty_matrices, | 1684 DEFVAR ("propagate_empty_matrices", SBV_propagate_empty_matrices, |
1666 "true", 0, 0, 1, propagate_empty_matrices, | 1685 "true", 0, propagate_empty_matrices, |
1667 "operations on empty matrices return an empty matrix, not an error"); | 1686 "operations on empty matrices return an empty matrix, not an error"); |
1668 | 1687 |
1669 #if 0 | 1688 #if 0 |
1670 DEFVAR ("read_only_constants", SBV_read_only_constants, "true", 0, | 1689 DEFVAR ("read_only_constants", SBV_read_only_constants, "true", 0, |
1671 0, 1, read_only_constants, | 1690 read_only_constants, |
1672 "allow built-in constants to be modified"); | 1691 "allow built-in constants to be modified"); |
1673 #endif | 1692 #endif |
1674 | 1693 |
1675 DEFVAR ("realmax", SBV_realmax, DBL_MAX, 1, 1, 1, 0, | 1694 DEFCONST ("realmax", SBV_realmax, DBL_MAX, 0, 0, |
1676 "realmax (): return largest representable floating point number"); | 1695 "realmax (): return largest representable floating point number"); |
1677 | 1696 |
1678 DEFVAR ("realmin", SBV_realmin, DBL_MIN, 1, 1, 1, 0, | 1697 DEFCONST ("realmin", SBV_realmin, DBL_MIN, 0, 0, |
1679 "realmin (): return smallest representable floating point number"); | 1698 "realmin (): return smallest representable floating point number"); |
1680 | 1699 |
1681 DEFVAR ("resize_on_range_error", SBV_resize_on_range_error, "true", 0, | 1700 DEFVAR ("resize_on_range_error", SBV_resize_on_range_error, "true", |
1682 0, 1, resize_on_range_error, | 1701 0, resize_on_range_error, |
1683 "enlarge matrices on assignment"); | 1702 "enlarge matrices on assignment"); |
1684 | 1703 |
1685 DEFVAR ("return_last_computed_value", SBV_return_last_computed_value, | 1704 DEFVAR ("return_last_computed_value", |
1686 "false", 0, 0, 1, | 1705 SBV_return_last_computed_value, "false", 0, |
1687 return_last_computed_value, | 1706 return_last_computed_value, |
1688 "if a function does not return any values explicitly, return the\n\ | 1707 "if a function does not return any values explicitly, return the\n\ |
1689 last computed value"); | 1708 last computed value"); |
1690 | 1709 |
1691 DEFVAR ("save_precision", SBV_save_precision, 17.0, 0, 0, 1, | 1710 DEFVAR ("save_precision", SBV_save_precision, 17.0, 0, |
1692 set_save_precision, | 1711 set_save_precision, |
1693 "number of significant figures kept by the ASCII save command"); | 1712 "number of significant figures kept by the ASCII save command"); |
1694 | 1713 |
1695 DEFVAR ("silent_functions", SBV_silent_functions, "false", 0, 0, 1, | 1714 DEFVAR ("silent_functions", SBV_silent_functions, "false", 0, |
1696 silent_functions, | 1715 silent_functions, |
1697 "suppress printing results in called functions"); | 1716 "suppress printing results in called functions"); |
1698 | 1717 |
1699 DEFVAR ("split_long_rows", SBV_split_long_rows, "true", 0, 0, 1, | 1718 DEFVAR ("split_long_rows", SBV_split_long_rows, "true", 0, |
1700 split_long_rows, | 1719 split_long_rows, |
1701 "split long matrix rows instead of wrapping"); | 1720 "split long matrix rows instead of wrapping"); |
1702 | 1721 |
1703 DEFVAR ("struct_levels_to_print", SBV_struct_levels_to_print, 2.0, | 1722 DEFVAR ("struct_levels_to_print", SBV_struct_levels_to_print, 2.0, |
1704 0, 0, 1, struct_levels_to_print, | 1723 0, struct_levels_to_print, |
1705 "number of levels of structure elements to print"); | 1724 "number of levels of structure elements to print"); |
1706 | 1725 |
1707 #ifdef USE_GNU_INFO | 1726 #ifdef USE_GNU_INFO |
1708 DEFVAR ("suppress_verbose_help_message", | 1727 DEFVAR ("suppress_verbose_help_message", |
1709 SBV_suppress_verbose_help_message, "false", 0, 0, 1, | 1728 SBV_suppress_verbose_help_message, "false", 0, |
1710 suppress_verbose_help_message, | 1729 suppress_verbose_help_message, |
1711 "suppress printing of message pointing to additional help in the\n\ | 1730 "suppress printing of message pointing to additional help in the\n\ |
1712 help and usage functions"); | 1731 help and usage functions"); |
1713 #endif | 1732 #endif |
1714 | 1733 |
1715 DEFVAR ("stdin", SBV_stdin, 0.0, 0, 1, 1, 0, | 1734 DEFCONST ("stdin", SBV_stdin, 0.0, 0, 0, |
1716 "file number of the standard input stream"); | 1735 "file number of the standard input stream"); |
1717 | 1736 |
1718 DEFVAR ("stdout", SBV_stdout, 1.0, 0, 1, 1, 0, | 1737 DEFCONST ("stdout", SBV_stdout, 1.0, 0, 0, |
1719 "file number of the standard output stream"); | 1738 "file number of the standard output stream"); |
1720 | 1739 |
1721 DEFVAR ("stderr", SBV_stderr, 2.0, 0, 1, 1, 0, | 1740 DEFCONST ("stderr", SBV_stderr, 2.0, 0, 0, |
1722 "file number of the standard error stream"); | 1741 "file number of the standard error stream"); |
1723 | 1742 |
1724 DEFVAR ("treat_neg_dim_as_zero", SBV_treat_neg_dim_as_zero, "false", | 1743 DEFVAR ("treat_neg_dim_as_zero", SBV_treat_neg_dim_as_zero, "false", |
1725 0, 0, 1, treat_neg_dim_as_zero, | 1744 0, treat_neg_dim_as_zero, |
1726 "convert negative dimensions to zero"); | 1745 "convert negative dimensions to zero"); |
1727 | 1746 |
1728 DEFVAR ("warn_assign_as_truth_value", SBV_warn_assign_as_truth_value, | 1747 DEFVAR ("warn_assign_as_truth_value", |
1729 "true", 0, 0, 1, | 1748 SBV_warn_assign_as_truth_value, "true", 0, |
1730 warn_assign_as_truth_value, | 1749 warn_assign_as_truth_value, |
1731 "produce warning for assignments used as truth values"); | 1750 "produce warning for assignments used as truth values"); |
1732 | 1751 |
1733 DEFVAR ("warn_comma_in_global_decl", SBV_warn_comma_in_global_decl, | 1752 DEFVAR ("warn_comma_in_global_decl", SBV_warn_comma_in_global_decl, |
1734 "true", 0, 0, 1, warn_comma_in_global_decl, | 1753 "true", 0, warn_comma_in_global_decl, |
1735 "produce warning for commas in global declarations"); | 1754 "produce warning for commas in global declarations"); |
1736 | 1755 |
1737 DEFVAR ("warn_divide_by_zero", SBV_warn_divide_by_zero, "true", 0, 0, | 1756 DEFVAR ("warn_divide_by_zero", SBV_warn_divide_by_zero, "true", 0, |
1738 1, warn_divide_by_zero, | 1757 warn_divide_by_zero, |
1739 "on IEEE machines, allow divide by zero errors to be suppressed"); | 1758 "on IEEE machines, allow divide by zero errors to be suppressed"); |
1740 | 1759 |
1741 DEFVAR ("warn_function_name_clash", SBV_warn_function_name_clash, | 1760 DEFVAR ("warn_function_name_clash", SBV_warn_function_name_clash, |
1742 "true", 0, 0, 1, warn_function_name_clash, | 1761 "true", 0, warn_function_name_clash, |
1743 "produce warning if function name conflicts with file name"); | 1762 "produce warning if function name conflicts with file name"); |
1744 | 1763 |
1745 DEFVAR ("whitespace_in_literal_matrix", SBV_whitespace_in_literal_matrix, "", | 1764 DEFVAR ("whitespace_in_literal_matrix", |
1746 0, 0, 1, whitespace_in_literal_matrix, | 1765 SBV_whitespace_in_literal_matrix, "", 0, |
1766 whitespace_in_literal_matrix, | |
1747 "control auto-insertion of commas and semicolons in literal matrices"); | 1767 "control auto-insertion of commas and semicolons in literal matrices"); |
1748 | |
1749 } | 1768 } |
1750 | 1769 |
1751 // Deleting names from the symbol tables. | 1770 // Deleting names from the symbol tables. |
1752 | 1771 |
1753 DEFUN_TEXT ("clear", Fclear, Sclear, -1, 1, | 1772 DEFUN_TEXT ("clear", Fclear, Sclear, -1, 1, |
1801 char **fcns = 0; | 1820 char **fcns = 0; |
1802 | 1821 |
1803 if (argc > 0) | 1822 if (argc > 0) |
1804 { | 1823 { |
1805 lvars = curr_sym_tab->list (lcount, 0, 0, 0, | 1824 lvars = curr_sym_tab->list (lcount, 0, 0, 0, |
1806 symbol_def::USER_VARIABLE, | 1825 SYMTAB_VARIABLES, |
1807 SYMTAB_LOCAL_SCOPE); | 1826 SYMTAB_LOCAL_SCOPE); |
1808 | 1827 |
1809 gvars = curr_sym_tab->list (gcount, 0, 0, 0, | 1828 gvars = curr_sym_tab->list (gcount, 0, 0, 0, |
1810 symbol_def::USER_VARIABLE, | 1829 SYMTAB_VARIABLES, |
1811 SYMTAB_GLOBAL_SCOPE); | 1830 SYMTAB_GLOBAL_SCOPE); |
1812 | 1831 |
1813 fcns = global_sym_tab->list (fcount, 0, 0, 0, | 1832 fcns = global_sym_tab->list (fcount, 0, 0, 0, |
1814 symbol_def::USER_FUNCTION, | 1833 symbol_def::USER_FUNCTION, |
1815 SYMTAB_ALL_SCOPES); | 1834 SYMTAB_ALL_SCOPES); |