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