Mercurial > hg > octave-lyh
comparison src/variables.cc @ 3016:f512c16826d1
[project @ 1997-06-03 03:16:13 by jwe]
author | jwe |
---|---|
date | Tue, 03 Jun 1997 03:21:08 +0000 |
parents | 66a1cede95e7 |
children | f491f232cb09 |
comparison
equal
deleted
inserted
replaced
3015:2e114e914b77 | 3016:f512c16826d1 |
---|---|
84 // 4 ==> echo commands read from command line | 84 // 4 ==> echo commands read from command line |
85 // | 85 // |
86 // more than one state can be active at once. | 86 // more than one state can be active at once. |
87 int Vecho_executing_commands; | 87 int Vecho_executing_commands; |
88 | 88 |
89 // Where history is saved. | |
90 static string Vhistory_file; | |
91 | |
92 // The number of lines to keep in the history file. | |
93 static int Vhistory_size; | |
94 | |
95 // Should Octave always check to see if function files have changed | 89 // Should Octave always check to see if function files have changed |
96 // since they were last compiled? | 90 // since they were last compiled? |
97 static int Vignore_function_time_stamp; | 91 static int Vignore_function_time_stamp; |
98 | |
99 // TRUE if we are saving history. | |
100 static int Vsaving_history; | |
101 | 92 |
102 // Symbol table for symbols at the top level. | 93 // Symbol table for symbols at the top level. |
103 symbol_table *top_level_sym_tab = 0; | 94 symbol_table *top_level_sym_tab = 0; |
104 | 95 |
105 // Symbol table for the current scope. | 96 // Symbol table for the current scope. |
1131 symbol_record *csr = curr_sym_tab->lookup (id_name, true); | 1122 symbol_record *csr = curr_sym_tab->lookup (id_name, true); |
1132 csr->alias (gsr); | 1123 csr->alias (gsr); |
1133 } | 1124 } |
1134 } | 1125 } |
1135 | 1126 |
1136 // Help stuff. Shouldn't this go in help.cc? | |
1137 | |
1138 // It's not likely that this does the right thing now. XXX FIXME XXX | |
1139 | |
1140 string_vector | |
1141 make_name_list (void) | |
1142 { | |
1143 int key_len = 0; | |
1144 int glb_len = 0; | |
1145 int top_len = 0; | |
1146 int lcl_len = 0; | |
1147 | |
1148 string_vector key; | |
1149 string_vector glb; | |
1150 string_vector top; | |
1151 string_vector lcl; | |
1152 string_vector ffl; | |
1153 | |
1154 // Each of these functions returns a new vector of pointers to new | |
1155 // strings. | |
1156 | |
1157 key = names (keyword_help (), key_len); | |
1158 | |
1159 glb = global_sym_tab->name_list (glb_len); | |
1160 | |
1161 top = top_level_sym_tab->name_list (top_len); | |
1162 | |
1163 if (top_level_sym_tab != curr_sym_tab) | |
1164 lcl = curr_sym_tab->name_list (lcl_len); | |
1165 | |
1166 ffl = octave_fcn_file_name_cache::list_no_suffix (); | |
1167 int ffl_len = ffl.length (); | |
1168 | |
1169 int total_len = key_len + glb_len + top_len + lcl_len + ffl_len; | |
1170 | |
1171 string_vector list (total_len); | |
1172 | |
1173 // Put all the symbols in one big list. Only copy pointers, not the | |
1174 // strings they point to, then only delete the original array of | |
1175 // pointers, and not the strings they point to. | |
1176 | |
1177 int j = 0; | |
1178 int i = 0; | |
1179 for (i = 0; i < key_len; i++) | |
1180 list[j++] = key[i]; | |
1181 | |
1182 for (i = 0; i < glb_len; i++) | |
1183 list[j++] = glb[i]; | |
1184 | |
1185 for (i = 0; i < top_len; i++) | |
1186 list[j++] = top[i]; | |
1187 | |
1188 for (i = 0; i < lcl_len; i++) | |
1189 list[j++] = lcl[i]; | |
1190 | |
1191 for (i = 0; i < ffl_len; i++) | |
1192 list[j++] = ffl[i]; | |
1193 | |
1194 return list; | |
1195 } | |
1196 | |
1197 // List variable names. | |
1198 | |
1199 DEFUN (document, args, , | 1127 DEFUN (document, args, , |
1200 "document (NAME, STRING)\n\ | 1128 "document (NAME, STRING)\n\ |
1201 \n\ | 1129 \n\ |
1202 Associate a cryptic message with a variable name.") | 1130 Associate a cryptic message with a variable name.") |
1203 { | 1131 { |
1461 sr->make_eternal (); | 1389 sr->make_eternal (); |
1462 | 1390 |
1463 sr->document (help); | 1391 sr->document (help); |
1464 } | 1392 } |
1465 | 1393 |
1466 // XXX FIXME XXX -- some of these should do their own checking to be | |
1467 // able to provide more meaningful warning or error messages. | |
1468 | |
1469 static int | |
1470 echo_executing_commands (void) | |
1471 { | |
1472 Vecho_executing_commands = check_preference ("echo_executing_commands"); | |
1473 | |
1474 return 0; | |
1475 } | |
1476 | |
1477 static int | |
1478 history_size (void) | |
1479 { | |
1480 double val; | |
1481 if (builtin_real_scalar_variable ("history_size", val) | |
1482 && ! xisnan (val)) | |
1483 { | |
1484 int ival = NINT (val); | |
1485 if (ival >= 0 && ival == val) | |
1486 { | |
1487 Vhistory_size = ival; | |
1488 command_history::set_size (ival); | |
1489 return 0; | |
1490 } | |
1491 } | |
1492 gripe_invalid_value_specified ("history_size"); | |
1493 return -1; | |
1494 } | |
1495 | |
1496 static int | |
1497 history_file (void) | |
1498 { | |
1499 int status = 0; | |
1500 | |
1501 string s = builtin_string_variable ("history_file"); | |
1502 | |
1503 if (s.empty ()) | |
1504 { | |
1505 gripe_invalid_value_specified ("history_file"); | |
1506 status = -1; | |
1507 } | |
1508 else | |
1509 { | |
1510 Vhistory_file = s; | |
1511 command_history::set_file (file_ops::tilde_expand (s)); | |
1512 } | |
1513 | |
1514 return status; | |
1515 } | |
1516 | |
1517 static int | |
1518 ignore_function_time_stamp (void) | |
1519 { | |
1520 int pref = 0; | |
1521 | |
1522 string val = builtin_string_variable ("ignore_function_time_stamp"); | |
1523 | |
1524 if (! val.empty ()) | |
1525 { | |
1526 if (val.compare ("all", 0, 3) == 0) | |
1527 pref = 2; | |
1528 if (val.compare ("system", 0, 6) == 0) | |
1529 pref = 1; | |
1530 } | |
1531 | |
1532 Vignore_function_time_stamp = pref; | |
1533 | |
1534 return 0; | |
1535 } | |
1536 | |
1537 static int | |
1538 saving_history (void) | |
1539 { | |
1540 Vsaving_history = check_preference ("saving_history"); | |
1541 | |
1542 command_history::ignore_entries (! Vsaving_history); | |
1543 | |
1544 return 0; | |
1545 } | |
1546 | |
1547 // XXX FIXME XXX -- there still may be better places for some of these | |
1548 // to be defined. | |
1549 | |
1550 void | |
1551 symbols_of_variables (void) | |
1552 { | |
1553 DEFVAR (ans, , 0, 0, | |
1554 ""); | |
1555 | |
1556 DEFCONST (argv, , 0, 0, | |
1557 "the command line arguments this program was invoked with"); | |
1558 | |
1559 DEFVAR (echo_executing_commands, static_cast<double> (ECHO_OFF), 0, | |
1560 echo_executing_commands, | |
1561 "echo commands as they are executed"); | |
1562 | |
1563 DEFCONST (error_text, "", 0, 0, | |
1564 "the text of error messages that would have been printed in the\n\ | |
1565 body of the most recent unwind_protect statement or the TRY part of\n\ | |
1566 the most recent eval() command. Outside of unwind_protect and\n\ | |
1567 eval(), or if no error has ocurred within them, the value of\n\ | |
1568 __error_text__ is guaranteed to be the empty string."); | |
1569 | |
1570 DEFVAR (history_file, default_history_file (), 0, history_file, | |
1571 "name of command history file"); | |
1572 | |
1573 double tmp_hist_size = default_history_size (); | |
1574 | |
1575 DEFVAR (history_size, tmp_hist_size, 0, history_size, | |
1576 "number of commands to save in the history list"); | |
1577 | |
1578 DEFVAR (ignore_function_time_stamp, "system", 0, ignore_function_time_stamp, | |
1579 "don't check to see if function files have changed since they were\n\ | |
1580 last compiled. Possible values are \"system\" and \"all\""); | |
1581 | |
1582 DEFCONST (program_invocation_name, | |
1583 octave_env::get_program_invocation_name (), 0, 0, | |
1584 "the full name of the current program or script, including the\n\ | |
1585 directory specification"); | |
1586 | |
1587 DEFCONST (program_name, octave_env::get_program_name (), 0, 0, | |
1588 "the name of the current program or script"); | |
1589 | |
1590 DEFVAR (saving_history, 1.0, 0, saving_history, | |
1591 "save command history"); | |
1592 } | |
1593 | |
1594 // Deleting names from the symbol tables. | 1394 // Deleting names from the symbol tables. |
1595 | 1395 |
1596 DEFUN_TEXT (clear, args, , | 1396 DEFUN_TEXT (clear, args, , |
1597 "clear [-x] [name ...]\n\ | 1397 "clear [-x] [name ...]\n\ |
1598 \n\ | 1398 \n\ |
1733 print_usage ("__dump_symtab_info__"); | 1533 print_usage ("__dump_symtab_info__"); |
1734 | 1534 |
1735 return retval; | 1535 return retval; |
1736 } | 1536 } |
1737 | 1537 |
1538 // XXX FIXME XXX -- some of these should do their own checking to be | |
1539 // able to provide more meaningful warning or error messages. | |
1540 | |
1541 static int | |
1542 echo_executing_commands (void) | |
1543 { | |
1544 Vecho_executing_commands = check_preference ("echo_executing_commands"); | |
1545 | |
1546 return 0; | |
1547 } | |
1548 | |
1549 static int | |
1550 ignore_function_time_stamp (void) | |
1551 { | |
1552 int pref = 0; | |
1553 | |
1554 string val = builtin_string_variable ("ignore_function_time_stamp"); | |
1555 | |
1556 if (! val.empty ()) | |
1557 { | |
1558 if (val.compare ("all", 0, 3) == 0) | |
1559 pref = 2; | |
1560 if (val.compare ("system", 0, 6) == 0) | |
1561 pref = 1; | |
1562 } | |
1563 | |
1564 Vignore_function_time_stamp = pref; | |
1565 | |
1566 return 0; | |
1567 } | |
1568 | |
1569 // XXX FIXME XXX -- there still may be better places for some of these | |
1570 // to be defined. | |
1571 | |
1572 void | |
1573 symbols_of_variables (void) | |
1574 { | |
1575 DEFVAR (ans, , 0, 0, | |
1576 ""); | |
1577 | |
1578 DEFCONST (argv, , 0, 0, | |
1579 "the command line arguments this program was invoked with"); | |
1580 | |
1581 DEFVAR (echo_executing_commands, static_cast<double> (ECHO_OFF), 0, | |
1582 echo_executing_commands, | |
1583 "echo commands as they are executed"); | |
1584 | |
1585 DEFCONST (error_text, "", 0, 0, | |
1586 "the text of error messages that would have been printed in the\n\ | |
1587 body of the most recent unwind_protect statement or the TRY part of\n\ | |
1588 the most recent eval() command. Outside of unwind_protect and\n\ | |
1589 eval(), or if no error has ocurred within them, the value of\n\ | |
1590 __error_text__ is guaranteed to be the empty string."); | |
1591 | |
1592 DEFVAR (ignore_function_time_stamp, "system", 0, ignore_function_time_stamp, | |
1593 "don't check to see if function files have changed since they were\n\ | |
1594 last compiled. Possible values are \"system\" and \"all\""); | |
1595 | |
1596 DEFCONST (program_invocation_name, | |
1597 octave_env::get_program_invocation_name (), 0, 0, | |
1598 "the full name of the current program or script, including the\n\ | |
1599 directory specification"); | |
1600 | |
1601 DEFCONST (program_name, octave_env::get_program_name (), 0, 0, | |
1602 "the name of the current program or script"); | |
1603 } | |
1604 | |
1738 /* | 1605 /* |
1739 ;;; Local Variables: *** | 1606 ;;; Local Variables: *** |
1740 ;;; mode: C++ *** | 1607 ;;; mode: C++ *** |
1741 ;;; End: *** | 1608 ;;; End: *** |
1742 */ | 1609 */ |