1
|
1 // variables.cc -*- C++ -*- |
|
2 /* |
|
3 |
1009
|
4 Copyright (C) 1992, 1993, 1994, 1995 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 |
1315
|
20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
1
|
21 |
|
22 */ |
|
23 |
240
|
24 #ifdef HAVE_CONFIG_H |
1192
|
25 #include <config.h> |
1
|
26 #endif |
|
27 |
1343
|
28 #include <cfloat> |
|
29 #include <cstring> |
605
|
30 |
1350
|
31 #include <strstream.h> |
|
32 |
|
33 #ifdef HAVE_UNISTD_H |
1
|
34 #include <sys/types.h> |
|
35 #include <unistd.h> |
|
36 #endif |
|
37 |
605
|
38 #include "defaults.h" |
1352
|
39 #include "defun.h" |
|
40 #include "dirfns.h" |
704
|
41 #include "dynamic-ld.h" |
1352
|
42 #include "error.h" |
|
43 #include "help.h" |
|
44 #include "input.h" |
|
45 #include "lex.h" |
|
46 #include "oct-obj.h" |
581
|
47 #include "octave-hist.h" |
529
|
48 #include "octave.h" |
605
|
49 #include "pager.h" |
1352
|
50 #include "parse.h" |
|
51 #include "statdefs.h" |
|
52 #include "symtab.h" |
|
53 #include "sysdep.h" |
|
54 #include "tree-base.h" |
|
55 #include "tree-const.h" |
|
56 #include "tree-expr.h" |
|
57 #include "unwind-prot.h" |
|
58 #include "user-prefs.h" |
1
|
59 #include "utils.h" |
1352
|
60 #include "variables.h" |
|
61 #include "version.h" |
529
|
62 |
|
63 extern "C" |
|
64 { |
581
|
65 #include <readline/readline.h> |
529
|
66 |
|
67 #include "fnmatch.h" |
|
68 } |
1
|
69 |
|
70 // Symbol table for symbols at the top level. |
581
|
71 symbol_table *top_level_sym_tab = 0; |
1
|
72 |
|
73 // Symbol table for the current scope. |
581
|
74 symbol_table *curr_sym_tab = 0; |
1
|
75 |
|
76 // Symbol table for global symbols. |
581
|
77 symbol_table *global_sym_tab = 0; |
1
|
78 |
593
|
79 // Initialization. |
|
80 |
|
81 // Create the initial symbol tables and set the current scope at the |
|
82 // top level. |
|
83 |
195
|
84 void |
|
85 initialize_symbol_tables (void) |
|
86 { |
581
|
87 if (! global_sym_tab) |
|
88 global_sym_tab = new symbol_table (); |
195
|
89 |
581
|
90 if (! top_level_sym_tab) |
|
91 top_level_sym_tab = new symbol_table (); |
195
|
92 |
|
93 curr_sym_tab = top_level_sym_tab; |
|
94 } |
|
95 |
593
|
96 // Attributes of variables and functions. |
|
97 |
|
98 // Is this variable a builtin? |
|
99 |
|
100 int |
|
101 is_builtin_variable (const char *name) |
|
102 { |
|
103 symbol_record *sr = global_sym_tab->lookup (name, 0, 0); |
|
104 return (sr && sr->is_builtin_variable ()); |
|
105 } |
|
106 |
|
107 // Is this a text-style function? |
|
108 |
|
109 int |
|
110 is_text_function_name (const char *s) |
|
111 { |
|
112 symbol_record *sr = global_sym_tab->lookup (s); |
|
113 return (sr && sr->is_text_function ()); |
|
114 } |
|
115 |
|
116 // Is this function globally in this scope? |
|
117 |
605
|
118 int |
593
|
119 is_globally_visible (const char *name) |
|
120 { |
|
121 symbol_record *sr = curr_sym_tab->lookup (name, 0, 0); |
|
122 return (sr && sr->is_linked_to_global ()); |
|
123 } |
|
124 |
|
125 // Is this tree_constant a valid function? |
|
126 |
|
127 tree_fvc * |
|
128 is_valid_function (const tree_constant& arg, char *warn_for, int warn) |
|
129 { |
|
130 tree_fvc *ans = 0; |
|
131 |
636
|
132 char *fcn_name = arg.string_value (); |
|
133 |
|
134 if (error_state) |
593
|
135 { |
|
136 if (warn) |
|
137 error ("%s: expecting function name as argument", warn_for); |
|
138 return ans; |
|
139 } |
|
140 |
|
141 symbol_record *sr = 0; |
|
142 if (fcn_name) |
|
143 sr = lookup_by_name (fcn_name); |
|
144 |
|
145 if (sr) |
|
146 ans = sr->def (); |
|
147 |
|
148 if (! sr || ! ans || ! sr->is_function ()) |
|
149 { |
|
150 if (warn) |
|
151 error ("%s: the symbol `%s' is not valid as a function", |
|
152 warn_for, fcn_name); |
|
153 ans = 0; |
|
154 } |
|
155 |
|
156 return ans; |
|
157 } |
|
158 |
|
159 // Does this function take the right number of arguments? |
|
160 |
|
161 int |
|
162 takes_correct_nargs (tree_fvc *fcn, int expected_nargin, char *warn_for, |
|
163 int warn) |
|
164 { |
712
|
165 int nargin = fcn->max_expected_args (); |
|
166 int e_nargin = expected_nargin; |
593
|
167 if (nargin != e_nargin) |
|
168 { |
|
169 if (warn) |
722
|
170 error ("%s: expecting function to take %d argument%s", |
593
|
171 warn_for, e_nargin, (e_nargin == 1 ? "" : "s")); |
|
172 return 0; |
|
173 } |
|
174 return 1; |
|
175 } |
|
176 |
712
|
177 DEFUN ("is_global", Fis_global, Sis_global, 1, 1, |
593
|
178 "is_global (X): return 1 if the string X names a global variable\n\ |
|
179 otherwise, return 0.") |
|
180 { |
|
181 Octave_object retval = 0.0; |
|
182 |
712
|
183 int nargin = args.length (); |
|
184 |
|
185 if (nargin != 1) |
593
|
186 { |
|
187 print_usage ("is_global"); |
|
188 return retval; |
|
189 } |
|
190 |
722
|
191 char *name = args(0).string_value (); |
593
|
192 |
636
|
193 if (error_state) |
|
194 { |
|
195 error ("is_global: expecting string argument"); |
|
196 return retval; |
|
197 } |
|
198 |
593
|
199 symbol_record *sr = curr_sym_tab->lookup (name, 0, 0); |
|
200 |
|
201 retval = (double) (sr && sr->is_linked_to_global ()); |
|
202 |
|
203 return retval; |
|
204 } |
|
205 |
712
|
206 DEFUN ("exist", Fexist, Sexist, 1, 1, |
593
|
207 "exist (NAME): check if variable or file exists\n\ |
|
208 \n\ |
|
209 return 0 if NAME is undefined, 1 if it is a variable, or 2 if it is\n\ |
|
210 a function.") |
|
211 { |
|
212 Octave_object retval; |
|
213 |
712
|
214 int nargin = args.length (); |
|
215 |
|
216 if (nargin != 1) |
593
|
217 { |
|
218 print_usage ("exist"); |
|
219 return retval; |
|
220 } |
|
221 |
1277
|
222 char *name = strsave (args(0).string_value ()); |
593
|
223 |
636
|
224 if (error_state) |
|
225 { |
|
226 error ("exist: expecting string argument"); |
1277
|
227 delete [] name; |
636
|
228 return retval; |
|
229 } |
|
230 |
1277
|
231 char *struct_elts = strchr (name, '.'); |
|
232 if (struct_elts) |
|
233 { |
|
234 *struct_elts = '\0'; |
|
235 struct_elts++; |
|
236 } |
|
237 |
593
|
238 symbol_record *sr = curr_sym_tab->lookup (name, 0, 0); |
|
239 if (! sr) |
|
240 sr = global_sym_tab->lookup (name, 0, 0); |
|
241 |
|
242 retval = 0.0; |
|
243 |
|
244 if (sr && sr->is_variable () && sr->is_defined ()) |
1277
|
245 { |
|
246 retval = 1.0; |
|
247 tree_fvc *def = sr->def (); |
|
248 if (struct_elts) |
|
249 { |
|
250 retval = 0.0; |
|
251 if (def->is_constant ()) |
|
252 { |
|
253 tree_constant *tmp = (tree_constant *) def; |
|
254 tree_constant ult; |
|
255 ult = tmp->lookup_map_element (struct_elts, 0, 1); |
|
256 if (ult.is_defined ()) |
|
257 retval = 1.0; |
|
258 } |
|
259 } |
|
260 } |
593
|
261 else if (sr && sr->is_function ()) |
|
262 retval = 2.0; |
|
263 else |
|
264 { |
|
265 char *path = fcn_file_in_path (name); |
|
266 if (path) |
|
267 { |
|
268 delete [] path; |
|
269 retval = 2.0; |
|
270 } |
|
271 else |
|
272 { |
|
273 struct stat buf; |
|
274 if (stat (name, &buf) == 0 && S_ISREG (buf.st_mode)) |
|
275 retval = 2.0; |
|
276 } |
|
277 } |
|
278 |
1277
|
279 delete [] name; |
|
280 |
593
|
281 return retval; |
|
282 } |
|
283 |
|
284 // XXX FIXME XXX -- should these really be here? |
|
285 |
|
286 static char * |
|
287 octave_home (void) |
|
288 { |
|
289 char *oh = getenv ("OCTAVE_HOME"); |
666
|
290 |
|
291 return (oh ? oh : OCTAVE_PREFIX); |
|
292 } |
|
293 |
|
294 static char * |
|
295 subst_octave_home (char *s) |
|
296 { |
|
297 char *home = octave_home (); |
|
298 char *prefix = OCTAVE_PREFIX; |
|
299 |
|
300 char *retval; |
|
301 |
|
302 if (strcmp (home, prefix) == 0) |
|
303 retval = strsave (s); |
593
|
304 else |
666
|
305 { |
|
306 int len_home = strlen (home); |
|
307 int len_prefix = strlen (prefix); |
|
308 |
|
309 int count = 0; |
|
310 char *ptr = s; |
811
|
311 char *next = 0; |
|
312 while ((next = strstr (ptr, prefix))) |
666
|
313 { |
811
|
314 ptr = next + len_prefix; |
666
|
315 count++; |
|
316 } |
|
317 |
|
318 int grow_size = count * (len_home - len_prefix); |
|
319 |
811
|
320 int len_s = strlen (s); |
|
321 |
|
322 int len_retval = len_s + count * grow_size; |
666
|
323 |
|
324 retval = new char [len_retval+1]; |
|
325 |
|
326 char *p1 = s; |
|
327 char *p2 = p1; |
|
328 char *pdest = retval; |
|
329 |
1271
|
330 // Is this really a good way to do this? |
811
|
331 |
|
332 while (count >= 0) |
666
|
333 { |
|
334 p2 = strstr (p1, prefix); |
|
335 |
|
336 if (! p2) |
770
|
337 { |
811
|
338 memcpy (pdest, p1, strlen (p1)+1); |
|
339 break; |
770
|
340 } |
811
|
341 else if (p1 == p2) |
666
|
342 { |
|
343 memcpy (pdest, home, len_home); |
|
344 pdest += len_home; |
|
345 p1 += len_prefix; |
811
|
346 count--; |
666
|
347 } |
|
348 else |
|
349 { |
|
350 int len = (int) (p2 - p1); |
|
351 memcpy (pdest, p1, len); |
|
352 pdest += len; |
|
353 p1 += len; |
|
354 } |
|
355 |
|
356 } |
|
357 } |
|
358 |
|
359 return retval; |
593
|
360 } |
|
361 |
|
362 static char * |
|
363 octave_info_dir (void) |
|
364 { |
666
|
365 static char *retval = subst_octave_home (OCTAVE_INFODIR); |
|
366 return retval; |
|
367 } |
|
368 |
686
|
369 char * |
666
|
370 octave_arch_lib_dir (void) |
|
371 { |
|
372 static char *retval = subst_octave_home (OCTAVE_ARCHLIBDIR); |
|
373 return retval; |
593
|
374 } |
|
375 |
798
|
376 char * |
|
377 octave_bin_dir (void) |
|
378 { |
|
379 static char *retval = subst_octave_home (OCTAVE_BINDIR); |
|
380 return retval; |
|
381 } |
|
382 |
593
|
383 static char * |
|
384 default_pager (void) |
|
385 { |
|
386 static char *pager_binary = 0; |
|
387 delete [] pager_binary; |
|
388 char *pgr = getenv ("PAGER"); |
|
389 if (pgr) |
|
390 pager_binary = strsave (pgr); |
|
391 else |
|
392 #ifdef DEFAULT_PAGER |
|
393 pager_binary = strsave (DEFAULT_PAGER); |
|
394 #else |
|
395 pager_binary = strsave (""); |
|
396 #endif |
|
397 |
|
398 return pager_binary; |
|
399 } |
|
400 |
1121
|
401 // Always returns a new string. |
|
402 |
|
403 char * |
|
404 maybe_add_default_load_path (const char *p) |
|
405 { |
|
406 static char *std_path = subst_octave_home (OCTAVE_FCNFILEPATH); |
|
407 |
|
408 char *pathstring = strsave (p); |
|
409 |
|
410 if (pathstring[0] == SEPCHAR) |
|
411 { |
|
412 char *tmp = pathstring; |
|
413 pathstring = strconcat (std_path, pathstring); |
|
414 delete [] tmp; |
|
415 } |
|
416 |
|
417 int tmp_len = strlen (pathstring); |
|
418 if (pathstring[tmp_len-1] == SEPCHAR) |
|
419 { |
|
420 char *tmp = pathstring; |
|
421 pathstring = strconcat (pathstring, std_path); |
|
422 delete [] tmp; |
|
423 } |
|
424 |
|
425 return pathstring; |
|
426 } |
|
427 |
593
|
428 char * |
|
429 octave_lib_dir (void) |
|
430 { |
666
|
431 static char *retval = subst_octave_home (OCTAVE_LIBDIR); |
|
432 return retval; |
593
|
433 } |
|
434 |
|
435 // Handle OCTAVE_PATH from the environment like TeX handles TEXINPUTS. |
|
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 |
|
438 // `:', do both (which is useless, but the luser asked for it...). |
|
439 // |
|
440 // This function may eventually be called more than once, so be |
|
441 // careful not to create memory leaks. |
|
442 |
|
443 char * |
|
444 default_path (void) |
|
445 { |
1121
|
446 static char *std_path = subst_octave_home (OCTAVE_FCNFILEPATH); |
|
447 |
|
448 static char *oct_path = getenv ("OCTAVE_PATH"); |
|
449 |
593
|
450 static char *pathstring = 0; |
|
451 delete [] pathstring; |
|
452 |
1121
|
453 return oct_path ? strsave (oct_path) : strsave (std_path); |
593
|
454 } |
|
455 |
|
456 char * |
|
457 default_info_file (void) |
|
458 { |
|
459 static char *info_file_string = 0; |
|
460 delete [] info_file_string; |
|
461 char *oct_info_file = getenv ("OCTAVE_INFO_FILE"); |
|
462 if (oct_info_file) |
|
463 info_file_string = strsave (oct_info_file); |
|
464 else |
|
465 { |
|
466 char *infodir = octave_info_dir (); |
|
467 info_file_string = strconcat (infodir, "/octave.info"); |
|
468 } |
|
469 return info_file_string; |
|
470 } |
|
471 |
|
472 char * |
|
473 default_editor (void) |
|
474 { |
|
475 static char *editor_string = 0; |
|
476 delete [] editor_string; |
|
477 char *env_editor = getenv ("EDITOR"); |
|
478 if (env_editor && *env_editor) |
|
479 editor_string = strsave (env_editor); |
|
480 else |
|
481 editor_string = strsave ("vi"); |
|
482 return editor_string; |
|
483 } |
|
484 |
|
485 char * |
|
486 get_site_defaults (void) |
|
487 { |
731
|
488 static char *startupdir = subst_octave_home (OCTAVE_STARTUPFILEDIR); |
|
489 static char *sd = strconcat (startupdir, "/octaverc"); |
593
|
490 return sd; |
|
491 } |
|
492 |
|
493 // Functions for looking up variables and functions. |
|
494 |
581
|
495 // Is there a corresponding function file that is newer than the |
|
496 // symbol definition? |
|
497 |
593
|
498 static int |
1
|
499 symbol_out_of_date (symbol_record *sr) |
|
500 { |
195
|
501 int ignore = user_pref.ignore_function_time_stamp; |
|
502 |
|
503 if (ignore == 2) |
|
504 return 0; |
|
505 |
529
|
506 if (sr) |
1
|
507 { |
490
|
508 tree_fvc *ans = sr->def (); |
529
|
509 if (ans) |
1
|
510 { |
339
|
511 char *ff = ans->fcn_file_name (); |
529
|
512 if (ff && ! (ignore && ans->is_system_fcn_file ())) |
1
|
513 { |
|
514 time_t tp = ans->time_parsed (); |
339
|
515 char *fname = fcn_file_in_path (ff); |
195
|
516 int status = is_newer (fname, tp); |
|
517 delete [] fname; |
|
518 if (status > 0) |
|
519 return 1; |
1
|
520 } |
|
521 } |
|
522 } |
195
|
523 return 0; |
1
|
524 } |
|
525 |
991
|
526 static int |
|
527 looks_like_octave_copyright (char *s) |
|
528 { |
|
529 if (s && strncmp (s, " Copyright (C) ", 15) == 0) |
|
530 { |
|
531 s = strchr (s, '\n'); |
|
532 if (s) |
|
533 { |
|
534 s++; |
|
535 s = strchr (s, '\n'); |
|
536 if (s) |
|
537 { |
|
538 s++; |
|
539 if (strncmp (s, " This file is part of Octave.", 29) == 0) |
|
540 return 1; |
|
541 } |
|
542 } |
|
543 } |
|
544 return 0; |
|
545 } |
|
546 |
|
547 static char * |
581
|
548 gobble_leading_white_space (FILE *ffile) |
|
549 { |
991
|
550 ostrstream buf; |
|
551 |
|
552 int first_comments_seen = 0; |
|
553 int have_help_text = 0; |
581
|
554 int in_comment = 0; |
|
555 int c; |
|
556 while ((c = getc (ffile)) != EOF) |
|
557 { |
984
|
558 current_input_column++; |
581
|
559 if (in_comment) |
|
560 { |
991
|
561 if (! have_help_text) |
|
562 { |
|
563 first_comments_seen = 1; |
|
564 buf << (char) c; |
|
565 } |
|
566 |
581
|
567 if (c == '\n') |
984
|
568 { |
|
569 input_line_number++; |
|
570 current_input_column = 0; |
|
571 in_comment = 0; |
|
572 } |
581
|
573 } |
|
574 else |
|
575 { |
984
|
576 switch (c) |
581
|
577 { |
984
|
578 case ' ': |
|
579 case '\t': |
991
|
580 if (first_comments_seen) |
|
581 have_help_text = 1; |
984
|
582 break; |
|
583 |
|
584 case '\n': |
993
|
585 if (first_comments_seen) |
|
586 have_help_text = 1; |
984
|
587 input_line_number++; |
|
588 current_input_column = 0; |
|
589 continue; |
|
590 |
|
591 case '%': |
|
592 case '#': |
|
593 in_comment = 1; |
|
594 break; |
|
595 |
|
596 default: |
|
597 current_input_column--; |
581
|
598 ungetc (c, ffile); |
991
|
599 goto done; |
581
|
600 } |
|
601 } |
|
602 } |
991
|
603 |
|
604 done: |
|
605 |
|
606 buf << ends; |
|
607 char *help_txt = buf.str (); |
|
608 |
|
609 if (! help_txt || ! *help_txt || looks_like_octave_copyright (help_txt)) |
|
610 { |
|
611 delete help_txt; |
|
612 help_txt = 0; |
|
613 } |
|
614 |
|
615 return help_txt; |
581
|
616 } |
|
617 |
|
618 static int |
|
619 is_function_file (FILE *ffile) |
|
620 { |
|
621 int status = 0; |
|
622 |
|
623 long pos = ftell (ffile); |
|
624 |
|
625 char buf [10]; |
|
626 fgets (buf, 10, ffile); |
|
627 int len = strlen (buf); |
|
628 if (len > 8 && strncmp (buf, "function", 8) == 0 |
|
629 && ! (isalnum (buf[8]) || buf[8] == '_')) |
|
630 status = 1; |
|
631 |
|
632 fseek (ffile, pos, SEEK_SET); |
|
633 |
|
634 return status; |
|
635 } |
|
636 |
|
637 static int |
|
638 parse_fcn_file (int exec_script, char *ff) |
|
639 { |
|
640 begin_unwind_frame ("parse_fcn_file"); |
|
641 |
|
642 int script_file_executed = 0; |
|
643 |
|
644 assert (ff); |
|
645 |
1358
|
646 // Open function file and parse. |
581
|
647 |
|
648 int old_reading_fcn_file_state = reading_fcn_file; |
|
649 |
|
650 unwind_protect_ptr (rl_instream); |
|
651 unwind_protect_ptr (ff_instream); |
|
652 |
|
653 unwind_protect_int (using_readline); |
|
654 unwind_protect_int (input_line_number); |
|
655 unwind_protect_int (current_input_column); |
|
656 unwind_protect_int (reading_fcn_file); |
|
657 |
|
658 using_readline = 0; |
|
659 reading_fcn_file = 1; |
|
660 input_line_number = 0; |
|
661 current_input_column = 1; |
|
662 |
|
663 FILE *ffile = get_input_from_file (ff, 0); |
|
664 |
|
665 if (ffile) |
|
666 { |
1271
|
667 // Check to see if this file defines a function or is just a |
|
668 // list of commands. |
581
|
669 |
991
|
670 char *tmp_help_txt = gobble_leading_white_space (ffile); |
|
671 |
581
|
672 if (is_function_file (ffile)) |
|
673 { |
|
674 unwind_protect_int (echo_input); |
|
675 unwind_protect_int (saving_history); |
|
676 unwind_protect_int (reading_fcn_file); |
|
677 |
|
678 echo_input = 0; |
|
679 saving_history = 0; |
|
680 reading_fcn_file = 1; |
|
681 |
|
682 YY_BUFFER_STATE old_buf = current_buffer (); |
|
683 YY_BUFFER_STATE new_buf = create_buffer (ffile); |
|
684 |
|
685 add_unwind_protect (restore_input_buffer, (void *) old_buf); |
|
686 add_unwind_protect (delete_input_buffer, (void *) new_buf); |
|
687 |
|
688 switch_to_buffer (new_buf); |
|
689 |
|
690 unwind_protect_ptr (curr_sym_tab); |
|
691 |
|
692 reset_parser (); |
|
693 |
991
|
694 delete [] help_buf; |
|
695 help_buf = tmp_help_txt; |
|
696 |
581
|
697 int status = yyparse (); |
|
698 |
|
699 if (status != 0) |
|
700 { |
|
701 error ("parse error while reading function file %s", ff); |
|
702 global_sym_tab->clear (curr_fcn_file_name); |
|
703 } |
|
704 } |
|
705 else if (exec_script) |
|
706 { |
1271
|
707 // We don't need this now. |
|
708 |
|
709 delete [] tmp_help_txt; |
|
710 |
|
711 // The value of `reading_fcn_file' will be restored to the |
|
712 // proper value when we unwind from this frame. |
|
713 |
581
|
714 reading_fcn_file = old_reading_fcn_file_state; |
|
715 |
|
716 unwind_protect_int (reading_script_file); |
|
717 reading_script_file = 1; |
|
718 |
|
719 parse_and_execute (ffile, 1); |
|
720 |
|
721 script_file_executed = 1; |
|
722 } |
|
723 fclose (ffile); |
|
724 } |
|
725 |
|
726 run_unwind_frame ("parse_fcn_file"); |
|
727 |
|
728 return script_file_executed; |
|
729 } |
|
730 |
593
|
731 static int |
581
|
732 load_fcn_from_file (symbol_record *sym_rec, int exec_script) |
|
733 { |
|
734 int script_file_executed = 0; |
|
735 |
|
736 char *nm = sym_rec->name (); |
|
737 |
1271
|
738 // This is needed by yyparse. |
704
|
739 |
581
|
740 curr_fcn_file_name = nm; |
|
741 |
704
|
742 #ifdef WITH_DLD |
581
|
743 |
704
|
744 if (load_octave_oct_file (nm)) |
|
745 { |
|
746 force_link_to_function (nm); |
|
747 } |
|
748 else |
581
|
749 |
704
|
750 #endif |
581
|
751 |
|
752 { |
704
|
753 char *ff = fcn_file_in_path (nm); |
581
|
754 |
|
755 if (ff) |
|
756 { |
|
757 script_file_executed = parse_fcn_file (exec_script, ff); |
|
758 delete [] ff; |
|
759 } |
|
760 |
|
761 if (! (error_state || script_file_executed)) |
|
762 force_link_to_function (nm); |
|
763 } |
|
764 |
|
765 return script_file_executed; |
|
766 } |
|
767 |
|
768 int |
|
769 lookup (symbol_record *sym_rec, int exec_script) |
|
770 { |
1271
|
771 int script_executed = 0; |
581
|
772 |
|
773 if (! sym_rec->is_linked_to_global ()) |
|
774 { |
|
775 if (sym_rec->is_defined ()) |
|
776 { |
|
777 if (sym_rec->is_function () && symbol_out_of_date (sym_rec)) |
1271
|
778 script_executed = load_fcn_from_file (sym_rec, exec_script); |
581
|
779 } |
|
780 else if (! sym_rec->is_formal_parameter ()) |
|
781 { |
|
782 link_to_builtin_or_function (sym_rec); |
1271
|
783 |
581
|
784 if (! sym_rec->is_defined ()) |
1271
|
785 script_executed = load_fcn_from_file (sym_rec, exec_script); |
581
|
786 else if (sym_rec->is_function () && symbol_out_of_date (sym_rec)) |
1271
|
787 script_executed = load_fcn_from_file (sym_rec, exec_script); |
581
|
788 } |
|
789 } |
|
790 |
1271
|
791 return script_executed; |
581
|
792 } |
|
793 |
|
794 // Get the symbol record for the given name that is visible in the |
|
795 // current scope. Reread any function definitions that appear to be |
|
796 // out of date. If a function is available in a file but is not |
|
797 // currently loaded, this will load it and insert the name in the |
|
798 // current symbol table. |
|
799 |
|
800 symbol_record * |
|
801 lookup_by_name (const char *nm, int exec_script) |
|
802 { |
|
803 symbol_record *sym_rec = curr_sym_tab->lookup (nm, 1, 0); |
|
804 |
|
805 lookup (sym_rec, exec_script); |
|
806 |
|
807 return sym_rec; |
|
808 } |
|
809 |
991
|
810 char * |
993
|
811 get_help_from_file (const char *path) |
991
|
812 { |
|
813 if (path && *path) |
|
814 { |
|
815 FILE *fptr = fopen (path, "r"); |
|
816 if (fptr) |
|
817 { |
|
818 char *help_txt = gobble_leading_white_space (fptr); |
|
819 fclose (fptr); |
|
820 return help_txt; |
|
821 } |
|
822 } |
|
823 return 0; |
|
824 } |
|
825 |
593
|
826 // Variable values. |
195
|
827 |
581
|
828 // Look for the given name in the global symbol table. If it refers |
|
829 // to a string, return a new copy. If not, return 0; |
|
830 |
1
|
831 char * |
195
|
832 builtin_string_variable (const char *name) |
1
|
833 { |
195
|
834 symbol_record *sr = global_sym_tab->lookup (name, 0, 0); |
|
835 |
1271
|
836 // It is a prorgramming error to look for builtins that aren't. |
195
|
837 |
529
|
838 assert (sr); |
195
|
839 |
529
|
840 char *retval = 0; |
1
|
841 |
490
|
842 tree_fvc *defn = sr->def (); |
195
|
843 |
529
|
844 if (defn) |
1
|
845 { |
|
846 tree_constant val = defn->eval (0); |
195
|
847 |
610
|
848 if (! error_state && val.is_string ()) |
1
|
849 { |
|
850 char *s = val.string_value (); |
636
|
851 |
529
|
852 if (s) |
1
|
853 retval = strsave (s); |
|
854 } |
|
855 } |
|
856 |
|
857 return retval; |
|
858 } |
|
859 |
581
|
860 // 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, |
|
862 // return -1. |
|
863 |
1
|
864 int |
195
|
865 builtin_real_scalar_variable (const char *name, double& d) |
1
|
866 { |
|
867 int status = -1; |
195
|
868 symbol_record *sr = global_sym_tab->lookup (name, 0, 0); |
|
869 |
1271
|
870 // It is a prorgramming error to look for builtins that aren't. |
195
|
871 |
529
|
872 assert (sr); |
1
|
873 |
490
|
874 tree_fvc *defn = sr->def (); |
195
|
875 |
529
|
876 if (defn) |
1
|
877 { |
|
878 tree_constant val = defn->eval (0); |
195
|
879 |
598
|
880 if (! error_state && val.is_scalar_type ()) |
1
|
881 { |
|
882 d = val.double_value (); |
|
883 status = 0; |
|
884 } |
|
885 } |
|
886 |
|
887 return status; |
|
888 } |
|
889 |
1093
|
890 // Look for the given name in the global symbol table. |
|
891 |
|
892 tree_constant |
|
893 builtin_any_variable (const char *name) |
|
894 { |
|
895 tree_constant retval; |
|
896 |
|
897 symbol_record *sr = global_sym_tab->lookup (name, 0, 0); |
|
898 |
1271
|
899 // It is a prorgramming error to look for builtins that aren't. |
1093
|
900 |
|
901 assert (sr); |
|
902 |
|
903 tree_fvc *defn = sr->def (); |
|
904 |
|
905 if (defn) |
|
906 retval = defn->eval (0); |
|
907 |
|
908 return retval; |
|
909 } |
|
910 |
593
|
911 // Global stuff and links to builtin variables and functions. |
|
912 |
581
|
913 // 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 |
|
915 // it doesn't already exist. |
|
916 |
195
|
917 void |
|
918 link_to_global_variable (symbol_record *sr) |
|
919 { |
|
920 if (sr->is_linked_to_global ()) |
|
921 return; |
|
922 |
|
923 symbol_record *gsr = global_sym_tab->lookup (sr->name (), 1, 0); |
|
924 |
|
925 if (sr->is_formal_parameter ()) |
|
926 { |
|
927 error ("can't make function parameter `%s' global", sr->name ()); |
|
928 return; |
|
929 } |
|
930 |
1271
|
931 // There must be a better way to do this. XXX FIXME XXX |
195
|
932 |
|
933 if (sr->is_variable ()) |
|
934 { |
1271
|
935 // Would be nice not to have this cast. XXX FIXME XXX |
|
936 |
195
|
937 tree_constant *tmp = (tree_constant *) sr->def (); |
529
|
938 if (tmp) |
|
939 tmp = new tree_constant (*tmp); |
|
940 else |
207
|
941 tmp = new tree_constant (); |
195
|
942 gsr->define (tmp); |
|
943 } |
|
944 else |
529
|
945 sr->clear (); |
195
|
946 |
1271
|
947 // If the global symbol is currently defined as a function, we need |
|
948 // to hide it with a variable. |
195
|
949 |
|
950 if (gsr->is_function ()) |
529
|
951 gsr->define ((tree_constant *) 0); |
195
|
952 |
|
953 sr->alias (gsr, 1); |
|
954 sr->mark_as_linked_to_global (); |
|
955 } |
|
956 |
581
|
957 // Make the definition of the symbol record sr be the same as the |
|
958 // definition of the builtin variable of the same name. |
|
959 |
195
|
960 void |
|
961 link_to_builtin_variable (symbol_record *sr) |
|
962 { |
|
963 symbol_record *tmp_sym = global_sym_tab->lookup (sr->name (), 0, 0); |
|
964 |
529
|
965 if (tmp_sym && tmp_sym->is_builtin_variable ()) |
|
966 sr->alias (tmp_sym); |
195
|
967 } |
|
968 |
581
|
969 // Make the definition of the symbol record sr be the same as the |
|
970 // definition of the builtin variable or function, or user function of |
|
971 // the same name, provided that the name has not been used as a formal |
|
972 // parameter. |
|
973 |
195
|
974 void |
|
975 link_to_builtin_or_function (symbol_record *sr) |
|
976 { |
|
977 symbol_record *tmp_sym = global_sym_tab->lookup (sr->name (), 0, 0); |
|
978 |
529
|
979 if (tmp_sym |
|
980 && (tmp_sym->is_builtin_variable () || tmp_sym->is_function ()) |
|
981 && ! tmp_sym->is_formal_parameter ()) |
|
982 sr->alias (tmp_sym); |
195
|
983 } |
|
984 |
581
|
985 // Force a link to a function in the current symbol table. This is |
|
986 // used just after defining a function to avoid different behavior |
|
987 // depending on whether or not the function has been evaluated after |
|
988 // being defined. |
|
989 // |
|
990 // Return without doing anything if there isn't a function with the |
|
991 // given name defined in the global symbol table. |
|
992 |
195
|
993 void |
|
994 force_link_to_function (const char *id_name) |
|
995 { |
|
996 symbol_record *gsr = global_sym_tab->lookup (id_name, 1, 0); |
|
997 if (gsr->is_function ()) |
|
998 { |
|
999 curr_sym_tab->clear (id_name); |
|
1000 symbol_record *csr = curr_sym_tab->lookup (id_name, 1, 0); |
|
1001 csr->alias (gsr); |
|
1002 } |
|
1003 } |
|
1004 |
605
|
1005 // Help stuff. Shouldn't this go in help.cc? |
593
|
1006 |
|
1007 // It's not likely that this does the right thing now. XXX FIXME XXX |
|
1008 |
|
1009 char ** |
|
1010 make_name_list (void) |
|
1011 { |
|
1012 int key_len = 0; |
|
1013 int glb_len = 0; |
|
1014 int top_len = 0; |
|
1015 int lcl_len = 0; |
|
1016 int ffl_len = 0; |
|
1017 |
|
1018 char **key = 0; |
|
1019 char **glb = 0; |
|
1020 char **top = 0; |
|
1021 char **lcl = 0; |
|
1022 char **ffl = 0; |
|
1023 |
1271
|
1024 // Each of these functions returns a new vector of pointers to new |
|
1025 // strings. |
593
|
1026 |
|
1027 key = names (keyword_help (), key_len); |
|
1028 glb = global_sym_tab->list (glb_len); |
|
1029 top = top_level_sym_tab->list (top_len); |
|
1030 if (top_level_sym_tab != curr_sym_tab) |
|
1031 lcl = curr_sym_tab->list (lcl_len); |
|
1032 ffl = get_fcn_file_names (ffl_len, 1); |
|
1033 |
|
1034 int total_len = key_len + glb_len + top_len + lcl_len + ffl_len; |
|
1035 |
|
1036 char **list = new char * [total_len+1]; |
|
1037 |
1271
|
1038 // 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 |
|
1040 // pointers, and not the strings they point to. |
593
|
1041 |
|
1042 int j = 0; |
|
1043 int i = 0; |
|
1044 for (i = 0; i < key_len; i++) |
|
1045 list[j++] = key[i]; |
|
1046 |
|
1047 for (i = 0; i < glb_len; i++) |
|
1048 list[j++] = glb[i]; |
|
1049 |
|
1050 for (i = 0; i < top_len; i++) |
|
1051 list[j++] = top[i]; |
|
1052 |
|
1053 for (i = 0; i < lcl_len; i++) |
|
1054 list[j++] = lcl[i]; |
|
1055 |
|
1056 for (i = 0; i < ffl_len; i++) |
|
1057 list[j++] = ffl[i]; |
|
1058 |
|
1059 list[j] = 0; |
|
1060 |
|
1061 delete [] key; |
|
1062 delete [] glb; |
|
1063 delete [] top; |
|
1064 delete [] lcl; |
|
1065 delete [] ffl; |
|
1066 |
|
1067 return list; |
|
1068 } |
|
1069 |
|
1070 // List variable names. |
|
1071 |
|
1072 static void |
|
1073 print_symbol_info_line (ostrstream& output_buf, const symbol_record_info& s) |
|
1074 { |
|
1075 output_buf << (s.is_read_only () ? " -" : " w"); |
|
1076 output_buf << (s.is_eternal () ? "- " : "d "); |
|
1077 #if 0 |
|
1078 output_buf << (s.hides_fcn () ? "f" : (s.hides_builtin () ? "F" : "-")); |
|
1079 #endif |
|
1080 output_buf.form (" %-16s", s.type_as_string ()); |
|
1081 if (s.is_function ()) |
|
1082 output_buf << " - -"; |
|
1083 else |
|
1084 { |
|
1085 output_buf.form ("%7d", s.rows ()); |
|
1086 output_buf.form ("%7d", s.columns ()); |
|
1087 } |
|
1088 output_buf << " " << s.name () << "\n"; |
|
1089 } |
|
1090 |
|
1091 static void |
|
1092 print_long_listing (ostrstream& output_buf, symbol_record_info *s) |
|
1093 { |
|
1094 if (! s) |
|
1095 return; |
|
1096 |
|
1097 symbol_record_info *ptr = s; |
|
1098 while (ptr->is_defined ()) |
|
1099 { |
|
1100 print_symbol_info_line (output_buf, *ptr); |
|
1101 ptr++; |
|
1102 } |
|
1103 } |
|
1104 |
|
1105 static int |
867
|
1106 maybe_list (const char *header, char **argv, int argc, |
|
1107 ostrstream& output_buf, int show_verbose, symbol_table |
|
1108 *sym_tab, unsigned type, unsigned scope) |
593
|
1109 { |
|
1110 int count; |
|
1111 int status = 0; |
|
1112 if (show_verbose) |
|
1113 { |
|
1114 symbol_record_info *symbols; |
867
|
1115 symbols = sym_tab->long_list (count, argv, argc, 1, type, scope); |
593
|
1116 if (symbols && count > 0) |
|
1117 { |
|
1118 output_buf << "\n" << header << "\n\n" |
|
1119 << "prot type rows cols name\n" |
|
1120 << "==== ==== ==== ==== ====\n"; |
|
1121 |
|
1122 print_long_listing (output_buf, symbols); |
|
1123 status = 1; |
|
1124 } |
|
1125 delete [] symbols; |
|
1126 } |
|
1127 else |
|
1128 { |
867
|
1129 char **symbols = sym_tab->list (count, argv, argc, 1, type, scope); |
593
|
1130 if (symbols && count > 0) |
|
1131 { |
|
1132 output_buf << "\n" << header << "\n\n"; |
|
1133 list_in_columns (output_buf, symbols); |
|
1134 status = 1; |
|
1135 } |
|
1136 delete [] symbols; |
|
1137 } |
|
1138 return status; |
|
1139 } |
|
1140 |
|
1141 DEFUN_TEXT ("document", Fdocument, Sdocument, -1, 1, |
|
1142 "document symbol string ...\n\ |
|
1143 \n\ |
|
1144 Associate a cryptic message with a variable name.") |
|
1145 { |
|
1146 Octave_object retval; |
|
1147 |
|
1148 DEFINE_ARGV("document"); |
|
1149 |
|
1150 if (argc == 3) |
|
1151 { |
|
1152 char *name = argv[1]; |
|
1153 char *help = argv[2]; |
|
1154 |
|
1155 if (is_builtin_variable (name)) |
|
1156 error ("sorry, can't redefine help for builtin variables"); |
|
1157 else |
|
1158 { |
|
1159 symbol_record *sym_rec = curr_sym_tab->lookup (name, 0); |
|
1160 |
|
1161 if (sym_rec) |
|
1162 sym_rec->document (help); |
|
1163 else |
|
1164 error ("document: no such symbol `%s'", name); |
|
1165 } |
|
1166 } |
|
1167 else |
|
1168 print_usage ("document"); |
|
1169 |
|
1170 DELETE_ARGV; |
|
1171 |
|
1172 return retval; |
|
1173 } |
|
1174 |
584
|
1175 // XXX FIXME XXX -- this should take a list of regular expressions |
|
1176 // naming the variables to look for. |
|
1177 |
581
|
1178 static Octave_object |
|
1179 do_who (int argc, char **argv, int nargout) |
529
|
1180 { |
|
1181 Octave_object retval; |
|
1182 |
|
1183 int show_builtins = 0; |
|
1184 int show_functions = (curr_sym_tab == top_level_sym_tab); |
|
1185 int show_variables = 1; |
|
1186 int show_verbose = 0; |
|
1187 |
584
|
1188 char *my_name = argv[0]; |
|
1189 |
529
|
1190 if (argc > 1) |
|
1191 { |
|
1192 show_functions = 0; |
|
1193 show_variables = 0; |
|
1194 } |
|
1195 |
867
|
1196 while (--argc > 0) |
529
|
1197 { |
|
1198 argv++; |
867
|
1199 |
529
|
1200 if (strcmp (*argv, "-all") == 0 || strcmp (*argv, "-a") == 0) |
|
1201 { |
|
1202 show_builtins++; |
|
1203 show_functions++; |
|
1204 show_variables++; |
|
1205 } |
605
|
1206 else if (strcmp (*argv, "-builtins") == 0 || strcmp (*argv, "-b") == 0) |
529
|
1207 show_builtins++; |
605
|
1208 else if (strcmp (*argv, "-functions") == 0 || strcmp (*argv, "-f") == 0) |
529
|
1209 show_functions++; |
605
|
1210 else if (strcmp (*argv, "-long") == 0 || strcmp (*argv, "-l") == 0) |
|
1211 show_verbose++; |
|
1212 else if (strcmp (*argv, "-variables") == 0 || strcmp (*argv, "-v") == 0) |
529
|
1213 show_variables++; |
867
|
1214 else if (*argv[0] == '-') |
|
1215 warning ("%s: unrecognized option `%s'", my_name, *argv); |
529
|
1216 else |
867
|
1217 break; |
529
|
1218 } |
|
1219 |
1271
|
1220 // If the user specified -l and nothing else, show variables. If |
|
1221 // evaluating this at the top level, also show functions. |
529
|
1222 |
|
1223 if (show_verbose && ! (show_builtins || show_functions || show_variables)) |
|
1224 { |
|
1225 show_functions = (curr_sym_tab == top_level_sym_tab); |
|
1226 show_variables = 1; |
|
1227 } |
|
1228 |
|
1229 ostrstream output_buf; |
|
1230 int pad_after = 0; |
|
1231 |
|
1232 if (show_builtins) |
|
1233 { |
867
|
1234 pad_after += maybe_list ("*** built-in variables:", argv, argc, |
529
|
1235 output_buf, show_verbose, global_sym_tab, |
|
1236 symbol_def::BUILTIN_VARIABLE, |
|
1237 SYMTAB_ALL_SCOPES); |
|
1238 |
867
|
1239 pad_after += maybe_list ("*** built-in functions:", argv, argc, |
529
|
1240 output_buf, show_verbose, global_sym_tab, |
|
1241 symbol_def::BUILTIN_FUNCTION, |
|
1242 SYMTAB_ALL_SCOPES); |
|
1243 } |
|
1244 |
|
1245 if (show_functions) |
|
1246 { |
|
1247 pad_after += maybe_list ("*** currently compiled functions:", |
867
|
1248 argv, argc, output_buf, show_verbose, |
|
1249 global_sym_tab, symbol_def::USER_FUNCTION, |
529
|
1250 SYMTAB_ALL_SCOPES); |
|
1251 } |
|
1252 |
|
1253 if (show_variables) |
|
1254 { |
867
|
1255 pad_after += maybe_list ("*** local user variables:", argv, argc, |
529
|
1256 output_buf, show_verbose, curr_sym_tab, |
|
1257 symbol_def::USER_VARIABLE, |
|
1258 SYMTAB_LOCAL_SCOPE); |
|
1259 |
|
1260 pad_after += maybe_list ("*** globally visible user variables:", |
867
|
1261 argv, argc, output_buf, show_verbose, |
|
1262 curr_sym_tab, symbol_def::USER_VARIABLE, |
529
|
1263 SYMTAB_GLOBAL_SCOPE); |
|
1264 } |
|
1265 |
|
1266 if (pad_after) |
|
1267 output_buf << "\n"; |
|
1268 |
|
1269 output_buf << ends; |
|
1270 maybe_page_output (output_buf); |
|
1271 |
581
|
1272 return retval; |
|
1273 } |
|
1274 |
|
1275 DEFUN_TEXT ("who", Fwho, Swho, -1, 1, |
|
1276 "who [-all] [-builtins] [-functions] [-long] [-variables]\n\ |
|
1277 \n\ |
|
1278 List currently defined symbol(s). Options may be shortened to one\n\ |
|
1279 character, but may not be combined.") |
|
1280 { |
|
1281 Octave_object retval; |
|
1282 |
|
1283 DEFINE_ARGV("who"); |
|
1284 |
|
1285 retval = do_who (argc, argv, nargout); |
|
1286 |
529
|
1287 DELETE_ARGV; |
|
1288 |
|
1289 return retval; |
|
1290 } |
|
1291 |
581
|
1292 DEFUN_TEXT ("whos", Fwhos, Swhos, -1, 1, |
|
1293 "whos [-all] [-builtins] [-functions] [-long] [-variables]\n\ |
|
1294 \n\ |
|
1295 List currently defined symbol(s). Options may be shortened to one\n\ |
|
1296 character, but may not be combined.") |
|
1297 { |
|
1298 Octave_object retval; |
|
1299 |
712
|
1300 int nargin = args.length (); |
|
1301 |
742
|
1302 Octave_object tmp_args; |
|
1303 for (int i = nargin; i > 0; i--) |
|
1304 tmp_args(i) = args(i-1); |
|
1305 tmp_args(0) = "-long"; |
581
|
1306 |
742
|
1307 int argc = tmp_args.length () + 1; |
581
|
1308 char **argv = make_argv (tmp_args, "whos"); |
|
1309 |
|
1310 if (error_state) |
|
1311 return retval; |
|
1312 |
|
1313 retval = do_who (argc, argv, nargout); |
|
1314 |
|
1315 while (--argc >= 0) |
|
1316 delete [] argv[argc]; |
|
1317 delete [] argv; |
|
1318 |
|
1319 return retval; |
|
1320 } |
|
1321 |
593
|
1322 // Install variables and functions in the symbol tables. |
529
|
1323 |
593
|
1324 void |
|
1325 install_builtin_mapper (builtin_mapper_function *mf) |
529
|
1326 { |
593
|
1327 symbol_record *sym_rec = global_sym_tab->lookup (mf->name, 1); |
|
1328 sym_rec->unprotect (); |
|
1329 |
|
1330 Mapper_fcn mfcn; |
628
|
1331 mfcn.name = strsave (mf->name); |
593
|
1332 mfcn.can_return_complex_for_real_arg = mf->can_return_complex_for_real_arg; |
|
1333 mfcn.lower_limit = mf->lower_limit; |
|
1334 mfcn.upper_limit = mf->upper_limit; |
|
1335 mfcn.d_d_mapper = mf->d_d_mapper; |
|
1336 mfcn.d_c_mapper = mf->d_c_mapper; |
|
1337 mfcn.c_c_mapper = mf->c_c_mapper; |
|
1338 |
722
|
1339 tree_builtin *def = new tree_builtin (1, 1, mfcn, mf->name); |
593
|
1340 |
|
1341 sym_rec->define (def); |
|
1342 |
|
1343 sym_rec->document (mf->help_string); |
|
1344 sym_rec->make_eternal (); |
|
1345 sym_rec->protect (); |
|
1346 } |
|
1347 |
|
1348 void |
|
1349 install_builtin_function (builtin_function *f) |
|
1350 { |
|
1351 symbol_record *sym_rec = global_sym_tab->lookup (f->name, 1); |
|
1352 sym_rec->unprotect (); |
|
1353 |
|
1354 tree_builtin *def = new tree_builtin (f->nargin_max, f->nargout_max, |
|
1355 f->fcn, f->name); |
|
1356 |
|
1357 sym_rec->define (def, f->is_text_fcn); |
|
1358 |
|
1359 sym_rec->document (f->help_string); |
|
1360 sym_rec->make_eternal (); |
|
1361 sym_rec->protect (); |
|
1362 } |
|
1363 |
|
1364 void |
|
1365 install_builtin_variable (builtin_variable *v) |
|
1366 { |
|
1367 if (v->install_as_function) |
|
1368 install_builtin_variable_as_function (v->name, v->value, v->protect, |
|
1369 v->eternal, v->help_string); |
529
|
1370 else |
593
|
1371 bind_builtin_variable (v->name, v->value, v->protect, v->eternal, |
|
1372 v->sv_function, v->help_string); |
529
|
1373 } |
|
1374 |
593
|
1375 void |
|
1376 install_builtin_variable_as_function (const char *name, tree_constant *val, |
|
1377 int protect, int eternal, |
|
1378 const char *help) |
529
|
1379 { |
593
|
1380 symbol_record *sym_rec = global_sym_tab->lookup (name, 1); |
|
1381 sym_rec->unprotect (); |
|
1382 |
|
1383 const char *tmp_help = help; |
|
1384 if (! help) |
|
1385 tmp_help = sym_rec->help (); |
|
1386 |
|
1387 sym_rec->define_as_fcn (val); |
|
1388 |
|
1389 sym_rec->document (tmp_help); |
|
1390 |
|
1391 if (protect) |
|
1392 sym_rec->protect (); |
|
1393 |
|
1394 if (eternal) |
|
1395 sym_rec->make_eternal (); |
|
1396 } |
|
1397 |
|
1398 void |
|
1399 alias_builtin (const char *alias, const char *name) |
|
1400 { |
|
1401 symbol_record *sr_name = global_sym_tab->lookup (name, 0, 0); |
|
1402 if (! sr_name) |
|
1403 panic ("can't alias to undefined name!"); |
|
1404 |
|
1405 symbol_record *sr_alias = global_sym_tab->lookup (alias, 1, 0); |
|
1406 |
|
1407 if (sr_alias) |
|
1408 sr_alias->alias (sr_name); |
|
1409 else |
770
|
1410 panic ("can't find symbol record for builtin function `%s'", alias); |
529
|
1411 } |
|
1412 |
593
|
1413 // Defining variables. |
|
1414 |
1161
|
1415 #if 0 |
593
|
1416 void |
|
1417 bind_nargin_and_nargout (symbol_table *sym_tab, int nargin, int nargout) |
529
|
1418 { |
593
|
1419 tree_constant *tmp; |
|
1420 symbol_record *sr; |
|
1421 |
|
1422 sr = sym_tab->lookup ("nargin", 1, 0); |
|
1423 sr->unprotect (); |
712
|
1424 tmp = new tree_constant (nargin); |
593
|
1425 sr->define (tmp); |
|
1426 |
|
1427 sr = sym_tab->lookup ("nargout", 1, 0); |
|
1428 sr->unprotect (); |
|
1429 tmp = new tree_constant (nargout); |
|
1430 sr->define (tmp); |
|
1431 } |
1161
|
1432 #endif |
593
|
1433 |
1162
|
1434 void |
|
1435 bind_ans (const tree_constant& val, int print) |
|
1436 { |
|
1437 static symbol_record *sr = global_sym_tab->lookup ("ans", 1, 0); |
|
1438 |
1281
|
1439 tree_identifier *ans_id = new tree_identifier (sr); |
1162
|
1440 tree_constant *tmp = new tree_constant (val); |
|
1441 |
1281
|
1442 // XXX FIXME XXX -- making ans_id static, passing its address to |
|
1443 // tree_simple_assignment_expression along with a flag to not delete |
|
1444 // it seems to create a memory leak. Hmm. |
|
1445 |
|
1446 tree_simple_assignment_expression tmp_ass (ans_id, tmp, 0, 1); |
1162
|
1447 |
|
1448 tmp_ass.eval (print); |
|
1449 } |
|
1450 |
593
|
1451 // Give a global variable a definition. This will insert the symbol |
|
1452 // in the global table if necessary. |
|
1453 |
|
1454 // How is this different than install_builtin_variable? Are both |
|
1455 // functions needed? |
|
1456 |
|
1457 void |
|
1458 bind_builtin_variable (const char *varname, tree_constant *val, |
|
1459 int protect, int eternal, sv_Function sv_fcn, |
|
1460 const char *help) |
|
1461 { |
|
1462 symbol_record *sr = global_sym_tab->lookup (varname, 1, 0); |
|
1463 |
1271
|
1464 // It is a programming error for a builtin symbol to be missing. |
|
1465 // Besides, we just inserted it, so it must be there. |
593
|
1466 |
|
1467 assert (sr); |
|
1468 |
|
1469 sr->unprotect (); |
|
1470 |
1271
|
1471 // Must do this before define, since define will call the special |
|
1472 // variable function only if it knows about it, and it needs to, so |
|
1473 // that user prefs can be properly initialized. |
593
|
1474 |
|
1475 if (sv_fcn) |
|
1476 sr->set_sv_function (sv_fcn); |
|
1477 |
|
1478 sr->define_builtin_var (val); |
|
1479 |
|
1480 if (protect) |
|
1481 sr->protect (); |
|
1482 |
|
1483 if (eternal) |
|
1484 sr->make_eternal (); |
|
1485 |
|
1486 if (help) |
|
1487 sr->document (help); |
529
|
1488 } |
|
1489 |
593
|
1490 void |
|
1491 install_builtin_variables (void) |
529
|
1492 { |
1271
|
1493 // XXX FIXME XX -- these should probably be moved to where they |
|
1494 // logically belong instead of being all grouped here. |
593
|
1495 |
|
1496 DEFVAR ("EDITOR", SBV_EDITOR, editor, 0, 0, 1, sv_editor, |
|
1497 "name of the editor to be invoked by the edit_history command"); |
|
1498 |
|
1499 DEFVAR ("I", SBV_I, Complex (0.0, 1.0), 0, 1, 1, 0, |
|
1500 "sqrt (-1)"); |
|
1501 |
|
1502 DEFVAR ("Inf", SBV_Inf, octave_Inf, 0, 1, 1, 0, |
|
1503 "infinity"); |
|
1504 |
|
1505 DEFVAR ("INFO_FILE", SBV_INFO_FILE, info_file, 0, 0, 1, sv_info_file, |
|
1506 "name of the Octave info file"); |
|
1507 |
|
1508 DEFVAR ("J", SBV_J, Complex (0.0, 1.0), 0, 1, 1, 0, |
|
1509 "sqrt (-1)"); |
529
|
1510 |
593
|
1511 #if defined (HAVE_ISNAN) |
|
1512 DEFVAR ("NaN", SBV_NaN, octave_NaN, 0, 1, 1, 0, |
|
1513 "not a number"); |
|
1514 #endif |
|
1515 |
|
1516 DEFVAR ("LOADPATH", SBV_LOADPATH, load_path, 0, 0, 1, sv_loadpath, |
|
1517 "colon separated list of directories to search for scripts"); |
|
1518 |
686
|
1519 DEFVAR ("IMAGEPATH", SBV_IMAGEPATH, OCTAVE_IMAGEPATH, 0, 0, 1, |
|
1520 sv_imagepath, |
|
1521 "colon separated list of directories to search for image files"); |
|
1522 |
1219
|
1523 DEFVAR ("OCTAVE_VERSION", SBV_version, OCTAVE_VERSION, 0, 1, 1, 0, |
664
|
1524 "Octave version"); |
|
1525 |
593
|
1526 DEFVAR ("PAGER", SBV_PAGER, default_pager (), 0, 0, 1, sv_pager_binary, |
|
1527 "path to pager binary"); |
|
1528 |
|
1529 DEFVAR ("PS1", SBV_PS1, "\\s:\\#> ", 0, 0, 1, sv_ps1, |
|
1530 "primary prompt string"); |
|
1531 |
|
1532 DEFVAR ("PS2", SBV_PS2, "> ", 0, 0, 1, sv_ps2, |
|
1533 "secondary prompt string"); |
|
1534 |
1044
|
1535 DEFVAR ("PS4", SBV_PS4, "+ ", 0, 0, 1, sv_ps4, |
|
1536 "string printed before echoed input (enabled by --echo-input)"); |
|
1537 |
593
|
1538 DEFVAR ("PWD", SBV_PWD, get_working_directory ("initialize_globals"), |
|
1539 0, 1, 1, sv_pwd, |
|
1540 "current working directory"); |
|
1541 |
|
1542 DEFVAR ("SEEK_SET", SBV_SEEK_SET, 0.0, 0, 1, 1, 0, |
|
1543 "used with fseek to position file relative to the beginning"); |
529
|
1544 |
593
|
1545 DEFVAR ("SEEK_CUR", SBV_SEEK_CUR, 1.0, 0, 1, 1, 0, |
|
1546 "used with fseek to position file relative to the current position"); |
|
1547 |
|
1548 DEFVAR ("SEEK_END", SBV_SEEK_END, 2.0, 0, 1, 1, 0, |
|
1549 "used with fseek to position file relative to the end"); |
|
1550 |
|
1551 DEFVAR ("ans", SBV_ans, , 0, 0, 1, 0, |
|
1552 ""); |
|
1553 |
1343
|
1554 DEFVAR ("argv", SBV_argv, , 0, 1, 1, 0, |
|
1555 "the command line arguments this program was invoked with"); |
|
1556 |
661
|
1557 DEFVAR ("automatic_replot", SBV_automatic_replot, "false", |
|
1558 0, 0, 1, automatic_replot, |
|
1559 "if true, auto-insert a replot command when a plot changes"); |
|
1560 |
1093
|
1561 DEFVAR ("default_return_value", SBV_default_return_value, Matrix (), |
|
1562 0, 0, 1, 0, |
|
1563 "the default for value for unitialized variables returned from\n\ |
|
1564 functions. Only used if the variable initialize_return_values is\n\ |
|
1565 set to \"true\"."); |
593
|
1566 |
605
|
1567 DEFVAR ("default_save_format", SBV_default_save_format, "ascii", |
|
1568 0, 0, 1, sv_default_save_format, |
997
|
1569 "default format for files created with save, may be one of\n\ |
|
1570 \"binary\", \"text\", or \"mat-binary\""); |
605
|
1571 |
593
|
1572 DEFVAR ("do_fortran_indexing", SBV_do_fortran_indexing, "false", 0, 0, |
|
1573 1, do_fortran_indexing, |
|
1574 "allow single indices for matrices"); |
|
1575 |
|
1576 DEFVAR ("empty_list_elements_ok", SBV_empty_list_elements_ok, "warn", |
|
1577 0, 0, 1, empty_list_elements_ok, |
|
1578 "ignore the empty element in expressions like `a = [[], 1]'"); |
529
|
1579 |
593
|
1580 DEFVAR ("eps", SBV_eps, DBL_EPSILON, 0, 1, 1, 0, |
|
1581 "machine precision"); |
|
1582 |
|
1583 DEFVAR ("gnuplot_binary", SBV_gnuplot_binary, "gnuplot", 0, 0, 1, |
|
1584 sv_gnuplot_binary, |
|
1585 "path to gnuplot binary"); |
|
1586 |
|
1587 DEFVAR ("i", SBV_i, Complex (0.0, 1.0), 1, 1, 1, 0, |
|
1588 "sqrt (-1)"); |
529
|
1589 |
593
|
1590 DEFVAR ("ignore_function_time_stamp", SBV_ignore_function_time_stamp, |
|
1591 "system", 0, 0, 1, |
|
1592 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 DEFVAR ("implicit_str_to_num_ok", SBV_implicit_str_to_num_ok, "false", |
|
1597 0, 0, 1, implicit_str_to_num_ok, |
|
1598 "allow implicit string to number conversion"); |
|
1599 |
|
1600 DEFVAR ("inf", SBV_inf, octave_Inf, 0, 1, 1, 0, |
|
1601 "infinity"); |
|
1602 |
1093
|
1603 DEFVAR ("define_all_return_values", SBV_define_all_return_values, |
|
1604 "false", 0, 0, 1, define_all_return_values, |
|
1605 "control whether values returned from functions should have a\n\ |
|
1606 value even if one has not been explicitly assigned. See also\n\ |
|
1607 default_return_value"); |
|
1608 |
593
|
1609 DEFVAR ("j", SBV_j, Complex (0.0, 1.0), 1, 1, 1, 0, |
|
1610 "sqrt (-1)"); |
529
|
1611 |
593
|
1612 #if defined (HAVE_ISNAN) |
|
1613 DEFVAR ("nan", SBV_nan, octave_NaN, 0, 1, 1, 0, |
|
1614 "not a number"); |
|
1615 #endif |
|
1616 |
|
1617 DEFVAR ("ok_to_lose_imaginary_part", SBV_ok_to_lose_imaginary_part, |
|
1618 "warn", 0, 0, 1, ok_to_lose_imaginary_part, |
|
1619 "silently convert from complex to real by dropping imaginary part"); |
|
1620 |
|
1621 DEFVAR ("output_max_field_width", SBV_output_max_field_width, 10.0, 0, |
|
1622 0, 1, set_output_max_field_width, |
|
1623 "maximum width of an output field for numeric output"); |
|
1624 |
|
1625 DEFVAR ("output_precision", SBV_output_precision, 5.0, 0, 0, 1, |
|
1626 set_output_precision, |
|
1627 "number of significant figures to display for numeric output"); |
|
1628 |
|
1629 DEFVAR ("page_screen_output", SBV_page_screen_output, "true", 0, 0, 1, |
|
1630 page_screen_output, |
|
1631 "if possible, send output intended for the screen through the pager"); |
529
|
1632 |
593
|
1633 DEFVAR ("pi", SBV_pi, 4.0 * atan (1.0), 0, 1, 1, 0, |
|
1634 "ratio of the circumference of a circle to its diameter"); |
|
1635 |
|
1636 DEFVAR ("prefer_column_vectors", SBV_prefer_column_vectors, "true", 0, |
|
1637 0, 1, prefer_column_vectors, |
|
1638 "prefer column/row vectors"); |
|
1639 |
|
1640 DEFVAR ("prefer_zero_one_indexing", SBV_prefer_zero_one_indexing, |
|
1641 "false", 0, 0, 1, prefer_zero_one_indexing, |
|
1642 "when there is a conflict, prefer zero-one style indexing"); |
|
1643 |
|
1644 DEFVAR ("print_answer_id_name", SBV_print_answer_id_name, "true", 0, |
|
1645 0, 1, print_answer_id_name, |
|
1646 "set output style to print `var_name = ...'"); |
|
1647 |
|
1648 DEFVAR ("print_empty_dimensions", SBV_print_empty_dimensions, "true", |
|
1649 0, 0, 1, print_empty_dimensions, |
|
1650 "also print dimensions of empty matrices"); |
|
1651 |
1343
|
1652 DEFVAR ("program_invocation_name", SBV_program_invocation_name, |
|
1653 raw_prog_name, 0, 1, 1, 0, |
|
1654 "the full name of the current program or script, including the\n\ |
|
1655 directory specification"); |
|
1656 |
|
1657 DEFVAR ("program_name", SBV_program_name, prog_name, 0, 1, 1, 0, |
|
1658 "the name of the current program or script"); |
|
1659 |
593
|
1660 DEFVAR ("propagate_empty_matrices", SBV_propagate_empty_matrices, |
|
1661 "true", 0, 0, 1, propagate_empty_matrices, |
|
1662 "operations on empty matrices return an empty matrix, not an error"); |
529
|
1663 |
1045
|
1664 #if 0 |
|
1665 DEFVAR ("read_only_constants", SBV_read_only_constants, "true", 0, |
|
1666 0, 1, read_only_constants, |
|
1667 "allow built-in constants to be modified"); |
|
1668 #endif |
|
1669 |
868
|
1670 DEFVAR ("realmax", SBV_realmax, DBL_MAX, 1, 1, 1, 0, |
|
1671 "realmax (): return largest representable floating point number"); |
|
1672 |
|
1673 DEFVAR ("realmin", SBV_realmin, DBL_MIN, 1, 1, 1, 0, |
|
1674 "realmin (): return smallest representable floating point number"); |
|
1675 |
593
|
1676 DEFVAR ("resize_on_range_error", SBV_resize_on_range_error, "true", 0, |
|
1677 0, 1, resize_on_range_error, |
|
1678 "enlarge matrices on assignment"); |
|
1679 |
|
1680 DEFVAR ("return_last_computed_value", SBV_return_last_computed_value, |
|
1681 "false", 0, 0, 1, |
|
1682 return_last_computed_value, |
|
1683 "if a function does not return any values explicitly, return the\n\ |
|
1684 last computed value"); |
|
1685 |
|
1686 DEFVAR ("save_precision", SBV_save_precision, 17.0, 0, 0, 1, |
|
1687 set_save_precision, |
|
1688 "number of significant figures kept by the ASCII save command"); |
|
1689 |
|
1690 DEFVAR ("silent_functions", SBV_silent_functions, "false", 0, 0, 1, |
|
1691 silent_functions, |
|
1692 "suppress printing results in called functions"); |
|
1693 |
|
1694 DEFVAR ("split_long_rows", SBV_split_long_rows, "true", 0, 0, 1, |
|
1695 split_long_rows, |
|
1696 "split long matrix rows instead of wrapping"); |
529
|
1697 |
1198
|
1698 DEFVAR ("struct_levels_to_print", SBV_struct_levels_to_print, 2.0, |
|
1699 0, 0, 1, struct_levels_to_print, |
|
1700 "number of levels of structure elements to print"); |
|
1701 |
1139
|
1702 #ifdef USE_GNU_INFO |
1116
|
1703 DEFVAR ("suppress_verbose_help_message", |
|
1704 SBV_suppress_verbose_help_message, "false", 0, 0, 1, |
|
1705 suppress_verbose_help_message, |
|
1706 "suppress printing of message pointing to additional help in the\n\ |
|
1707 help and usage functions"); |
1139
|
1708 #endif |
1116
|
1709 |
593
|
1710 DEFVAR ("stdin", SBV_stdin, 0.0, 0, 1, 1, 0, |
|
1711 "file number of the standard input stream"); |
|
1712 |
|
1713 DEFVAR ("stdout", SBV_stdout, 1.0, 0, 1, 1, 0, |
|
1714 "file number of the standard output stream"); |
|
1715 |
|
1716 DEFVAR ("stderr", SBV_stderr, 2.0, 0, 1, 1, 0, |
|
1717 "file number of the standard error stream"); |
|
1718 |
|
1719 DEFVAR ("treat_neg_dim_as_zero", SBV_treat_neg_dim_as_zero, "false", |
|
1720 0, 0, 1, treat_neg_dim_as_zero, |
|
1721 "convert negative dimensions to zero"); |
|
1722 |
|
1723 DEFVAR ("warn_assign_as_truth_value", SBV_warn_assign_as_truth_value, |
|
1724 "true", 0, 0, 1, |
|
1725 warn_assign_as_truth_value, |
|
1726 "produce warning for assignments used as truth values"); |
|
1727 |
|
1728 DEFVAR ("warn_comma_in_global_decl", SBV_warn_comma_in_global_decl, |
|
1729 "true", 0, 0, 1, warn_comma_in_global_decl, |
|
1730 "produce warning for commas in global declarations"); |
|
1731 |
|
1732 DEFVAR ("warn_divide_by_zero", SBV_warn_divide_by_zero, "true", 0, 0, |
|
1733 1, warn_divide_by_zero, |
|
1734 "on IEEE machines, allow divide by zero errors to be suppressed"); |
1037
|
1735 |
|
1736 DEFVAR ("warn_function_name_clash", SBV_warn_function_name_clash, |
|
1737 "true", 0, 0, 1, warn_function_name_clash, |
|
1738 "produce warning if function name conflicts with file name"); |
1093
|
1739 |
|
1740 DEFVAR ("whitespace_in_literal_matrix", SBV_whitespace_in_literal_matrix, "", |
|
1741 0, 0, 1, whitespace_in_literal_matrix, |
|
1742 "control auto-insertion of commas and semicolons in literal matrices"); |
|
1743 |
529
|
1744 } |
|
1745 |
593
|
1746 // Deleting names from the symbol tables. |
|
1747 |
|
1748 DEFUN_TEXT ("clear", Fclear, Sclear, -1, 1, |
668
|
1749 "clear [-x] [name ...]\n\ |
|
1750 \n\ |
|
1751 Clear symbol(s) matching a list of globbing patterns.\n\ |
593
|
1752 \n\ |
668
|
1753 If no arguments are given, clear all user-defined variables and |
|
1754 functions.\n\ |
|
1755 \n\ |
|
1756 With -x, exclude the named variables") |
529
|
1757 { |
593
|
1758 Octave_object retval; |
|
1759 |
|
1760 DEFINE_ARGV("clear"); |
|
1761 |
668
|
1762 argc--; |
|
1763 argv++; |
|
1764 |
1271
|
1765 // Always clear the local table, but don't clear currently compiled |
|
1766 // functions unless we are at the top level. (Allowing that to |
|
1767 // happen inside functions would result in pretty odd behavior...) |
593
|
1768 |
|
1769 int clear_user_functions = (curr_sym_tab == top_level_sym_tab); |
|
1770 |
668
|
1771 if (argc == 0) |
593
|
1772 { |
|
1773 curr_sym_tab->clear (); |
|
1774 global_sym_tab->clear (clear_user_functions); |
|
1775 } |
529
|
1776 else |
|
1777 { |
668
|
1778 int exclusive = 0; |
|
1779 |
|
1780 if (argc > 0) |
|
1781 { |
|
1782 if (strcmp (*argv, "-x") == 0) |
|
1783 { |
|
1784 exclusive = 1; |
|
1785 argv++; |
|
1786 argc--; |
|
1787 } |
|
1788 } |
|
1789 |
|
1790 int lcount = 0; |
|
1791 int gcount = 0; |
|
1792 int fcount = 0; |
529
|
1793 |
668
|
1794 char **lvars = 0; |
|
1795 char **gvars = 0; |
|
1796 char **fcns = 0; |
|
1797 |
|
1798 if (argc > 0) |
593
|
1799 { |
893
|
1800 lvars = curr_sym_tab->list (lcount, 0, 0, 0, |
|
1801 symbol_def::USER_VARIABLE, |
668
|
1802 SYMTAB_LOCAL_SCOPE); |
|
1803 |
893
|
1804 gvars = curr_sym_tab->list (gcount, 0, 0, 0, |
|
1805 symbol_def::USER_VARIABLE, |
668
|
1806 SYMTAB_GLOBAL_SCOPE); |
|
1807 |
893
|
1808 fcns = global_sym_tab->list (fcount, 0, 0, 0, |
|
1809 symbol_def::USER_FUNCTION, |
864
|
1810 SYMTAB_ALL_SCOPES); |
668
|
1811 } |
|
1812 |
|
1813 while (argc > 0) |
|
1814 { |
|
1815 char *pat = *argv; |
|
1816 |
|
1817 if (pat) |
593
|
1818 { |
|
1819 int i; |
|
1820 for (i = 0; i < lcount; i++) |
|
1821 { |
668
|
1822 char *nm = lvars[i]; |
|
1823 int match = (fnmatch (pat, nm, __FNM_FLAGS) == 0); |
|
1824 if ((exclusive && ! match) || (! exclusive && match)) |
|
1825 curr_sym_tab->clear (nm); |
593
|
1826 } |
529
|
1827 |
593
|
1828 int count; |
|
1829 for (i = 0; i < gcount; i++) |
|
1830 { |
668
|
1831 char *nm = gvars[i]; |
|
1832 int match = (fnmatch (pat, nm, __FNM_FLAGS) == 0); |
|
1833 if ((exclusive && ! match) || (! exclusive && match)) |
593
|
1834 { |
668
|
1835 count = curr_sym_tab->clear (nm); |
593
|
1836 if (count > 0) |
668
|
1837 global_sym_tab->clear (nm, clear_user_functions); |
593
|
1838 } |
|
1839 } |
529
|
1840 |
593
|
1841 for (i = 0; i < fcount; i++) |
|
1842 { |
668
|
1843 char *nm = fcns[i]; |
|
1844 int match = (fnmatch (pat, nm, __FNM_FLAGS) == 0); |
|
1845 if ((exclusive && ! match) || (! exclusive && match)) |
593
|
1846 { |
668
|
1847 count = curr_sym_tab->clear (nm); |
864
|
1848 global_sym_tab->clear (nm, clear_user_functions); |
593
|
1849 } |
|
1850 } |
|
1851 } |
668
|
1852 |
|
1853 argc--; |
|
1854 argv++; |
593
|
1855 } |
529
|
1856 |
593
|
1857 delete [] lvars; |
|
1858 delete [] gvars; |
|
1859 delete [] fcns; |
|
1860 |
|
1861 } |
|
1862 |
|
1863 DELETE_ARGV; |
|
1864 |
|
1865 return retval; |
529
|
1866 } |
|
1867 |
1
|
1868 /* |
|
1869 ;;; Local Variables: *** |
|
1870 ;;; mode: C++ *** |
|
1871 ;;; page-delimiter: "^/\\*" *** |
|
1872 ;;; End: *** |
|
1873 */ |