GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
variables.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1993-2021 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if defined (HAVE_CONFIG_H)
27 # include "config.h"
28 #endif
29 
30 #include <cstdio>
31 #include <cstring>
32 
33 #include <iomanip>
34 #include <list>
35 #include <set>
36 #include <string>
37 
38 #include "file-stat.h"
39 #include "oct-env.h"
40 #include "file-ops.h"
41 #include "glob-match.h"
42 #include "lo-regexp.h"
43 #include "str-vec.h"
44 
45 #include "Cell.h"
46 #include "defun.h"
47 #include "error.h"
48 #include "errwarn.h"
49 #include "event-manager.h"
50 #include "help.h"
51 #include "input.h"
52 #include "interpreter-private.h"
53 #include "interpreter.h"
54 #include "lex.h"
55 #include "load-path.h"
57 #include "oct-map.h"
58 #include "ovl.h"
59 #include "ov.h"
60 #include "ov-class.h"
61 #include "ov-usr-fcn.h"
62 #include "pager.h"
63 #include "parse.h"
64 #include "pt-eval.h"
65 #include "syminfo.h"
66 #include "symtab.h"
67 #include "sysdep.h"
68 #include "unwind-prot.h"
69 #include "utils.h"
70 #include "variables.h"
71 
72 // Attributes of variables and functions.
73 
74 // Is this octave_value a valid function?
75 
77 is_valid_function (const std::string& fcn_name,
78  const std::string& warn_for, bool warn)
79 {
80  octave_function *ans = nullptr;
81 
82  if (! fcn_name.empty ())
83  {
84  octave::symbol_table& symtab
85  = octave::__get_symbol_table__ ("is_valid_function");
86 
87  octave_value val = symtab.find_function (fcn_name);
88 
89  if (val.is_defined ())
90  ans = val.function_value (true);
91  }
92 
93  // FIXME: Should this be "err" and "error_for", rather than warn?
94  if (! ans && warn)
95  error ("%s: the symbol '%s' is not valid as a function",
96  warn_for.c_str (), fcn_name.c_str ());
97 
98  return ans;
99 }
100 
103  const std::string& warn_for, bool warn)
104 {
105  octave_function *ans = nullptr;
106 
107  std::string fcn_name;
108 
109  if (arg.is_string ())
110  {
111  fcn_name = arg.string_value ();
112 
113  ans = is_valid_function (fcn_name, warn_for, warn);
114  }
115  else if (warn)
116  // FIXME: Should this be "err" and "error_for", rather than warn?
117  error ("%s: argument must be a string containing function name",
118  warn_for.c_str ());
119 
120  return ans;
121 }
122 
124 extract_function (const octave_value& arg, const std::string& warn_for,
125  const std::string& fname, const std::string& header,
126  const std::string& trailer)
127 {
128  octave_function *retval = is_valid_function (arg, warn_for, 0);
129 
130  if (! retval)
131  {
132  std::string s = arg.xstring_value ("%s: argument must be a string",
133  warn_for.c_str ());
134 
135  std::string cmd = header;
136  cmd.append (s);
137  cmd.append (trailer);
138 
139  int parse_status;
140 
141  octave::interpreter& interp
142  = octave::__get_interpreter__ ("extract_function");
143 
144  interp.eval_string (cmd, true, parse_status, 0);
145 
146  if (parse_status != 0)
147  error ("%s: '%s' is not valid as a function",
148  warn_for.c_str (), fname.c_str ());
149 
150  retval = is_valid_function (fname, warn_for, 0);
151 
152  if (! retval)
153  error ("%s: '%s' is not valid as a function",
154  warn_for.c_str (), fname.c_str ());
155 
156  warning ("%s: passing function body as a string is obsolete; please use anonymous functions",
157  warn_for.c_str ());
158  }
159 
160  return retval;
161 }
162 
163 DEFMETHOD (isglobal, interp, args, ,
164  doc: /* -*- texinfo -*-
165 @deftypefn {} {} isglobal (@var{name})
166 Return true if @var{name} is a globally visible variable.
167 
168 For example:
169 
170 @example
171 @group
172 global x
173 isglobal ("x")
174  @result{} 1
175 @end group
176 @end example
177 @seealso{isvarname, exist}
178 @end deftypefn */)
179 {
180  if (args.length () != 1)
181  print_usage ();
182 
183  std::string name = args(0).xstring_value ("isglobal: NAME must be a string");
184 
185  return ovl (interp.isglobal (name));
186 }
187 
188 /*
189 %!test
190 %! global x;
191 %! assert (isglobal ("x"), true);
192 %! clear -global x; # cleanup after test
193 
194 %!error isglobal ()
195 %!error isglobal ("a", "b")
196 %!error isglobal (1)
197 */
198 
199 static int
200 symbol_exist (octave::interpreter& interp, const std::string& name,
201  const std::string& type = "any")
202 {
203  if (octave::iskeyword (name))
204  return 0;
205 
206  bool search_any = type == "any";
207  bool search_var = type == "var";
208  bool search_dir = type == "dir";
209  bool search_file = type == "file";
210  bool search_builtin = type == "builtin";
211  bool search_class = type == "class";
212 
213  if (! (search_any || search_var || search_dir || search_file
214  || search_builtin || search_class))
215  error (R"(exist: unrecognized type argument "%s")", type.c_str ());
216 
217  octave::symbol_table& symtab = interp.get_symbol_table ();
218 
219  if (search_any || search_var)
220  {
221  octave_value val = interp.varval (name);
222 
223  if (val.is_constant () || val.isobject ()
224  || val.is_function_handle ()
225  || val.is_anonymous_function ()
226  || val.is_inline_function ())
227  return 1;
228 
229  if (search_var)
230  return 0;
231  }
232 
233  // We shouldn't need to look in the global symbol table, since any name
234  // that is visible in the current scope will be in the local symbol table.
235 
236  if (search_any || search_file || search_dir)
237  {
238  bool have_fcn_ext = false;
239 
240  std::string xname = name;
241  std::string ext;
242 
243  size_t pos = name.rfind ('.');
244 
245  if (pos != std::string::npos)
246  {
247  ext = name.substr (pos+1);
248 
249  if (ext == "m" || ext == "oct" || ext == "mex")
250  {
251  xname = name.substr (0, pos);
252  have_fcn_ext = true;
253  }
254  }
255 
256  std::string file_name;
257 
258  if (search_any || search_file)
259  {
260  octave::load_path& lp = interp.get_load_path ();
261 
262  // Class constructor.
263  file_name = lp.find_method (xname, xname);
264 
265  if (have_fcn_ext && ! file_name.empty ())
266  {
267  pos = file_name.rfind ('.');
268 
269  if (pos != std::string::npos)
270  {
271  std::string fext = file_name.substr (pos+1);
272 
273  if (ext != fext)
274  file_name = "";
275  }
276  }
277 
278  if (search_any && file_name.empty ())
279  {
280  // Command line function which Matlab does not support
281  octave_value val = symtab.find_cmdline_function (xname);
282 
283  if (val.is_defined ())
284  return 103;
285  }
286 
287  // Autoloads can only have simple names without extensions.
288 
289  if (! have_fcn_ext && file_name.empty ())
290  {
291  octave::tree_evaluator& tw = interp.get_evaluator ();
292 
293  file_name = tw.lookup_autoload (name);
294  }
295 
296  // Use original name here.
297 
298  if (file_name.empty ())
299  file_name = lp.find_fcn (name);
300  }
301 
302  size_t len = file_name.length ();
303 
304  if (len > 0)
305  {
306  if (search_any || search_file)
307  {
308  if (len > 4 && (file_name.substr (len-4) == ".oct"
309  || file_name.substr (len-4) == ".mex"))
310  return 3;
311  else
312  return 2;
313  }
314  }
315 
316  file_name = octave::file_in_path (name, "");
317 
318  if (file_name.empty ())
319  file_name = name;
320 
321  // "stat" doesn't work on UNC shares and drive letters.
322  if ((search_any || search_file) && octave::drive_or_unc_share (file_name))
323  return 7;
324 
325  octave::sys::file_stat fs (file_name);
326 
327  if (fs)
328  {
329  if (search_any || search_file)
330  {
331  if (fs.is_dir ())
332  return 7;
333 
334  len = file_name.length ();
335 
336  if (len > 4 && (file_name.substr (len-4) == ".oct"
337  || file_name.substr (len-4) == ".mex"))
338  return 3;
339  else
340  return 2;
341  }
342  else if (search_dir && fs.is_dir ())
343  return 7;
344  }
345 
346  if (search_file || search_dir)
347  return 0;
348  }
349 
350  if ((search_any || search_builtin)
351  && symtab.is_built_in_function_name (name))
352  return 5;
353 
354  return 0;
355 }
356 
357 int
358 symbol_exist (const std::string& name, const std::string& type)
359 {
360  octave::interpreter& interp = octave::__get_interpreter__ ("symbol_exist");
361 
362  return symbol_exist (interp, name, type);
363 }
364 
365 
366 #define GET_IDX(LEN) \
367  static_cast<int> (((LEN)-1) * static_cast<double> (rand ()) / RAND_MAX)
368 
369 std::string
370 unique_symbol_name (const std::string& basename)
371 {
372  static const std::string alpha
373  = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
374 
375  static size_t len = alpha.length ();
376 
377  std::string nm = basename + alpha[GET_IDX (len)];
378 
379  size_t pos = nm.length ();
380 
381  if (nm.substr (0, 2) == "__")
382  nm.append ("__");
383 
384  octave::interpreter& interp
385  = octave::__get_interpreter__ ("unique_symbol_name");
386 
387  while (symbol_exist (interp, nm, "any"))
388  nm.insert (pos++, 1, alpha[GET_IDX (len)]);
389 
390  return nm;
391 }
392 
393 DEFMETHOD (exist, interp, args, ,
394  doc: /* -*- texinfo -*-
395 @deftypefn {} {@var{c} =} exist (@var{name})
396 @deftypefnx {} {@var{c} =} exist (@var{name}, @var{type})
397 Check for the existence of @var{name} as a variable, function, file, directory,
398 or class.
399 
400 The return code @var{c} is one of
401 
402 @table @asis
403 @item 1
404 @var{name} is a variable.
405 
406 @item 2
407 @var{name} is an absolute filename, an ordinary file in Octave's @code{path},
408 or (after appending @samp{.m}) a function file in Octave's @code{path}.
409 
410 @item 3
411 @var{name} is a @samp{.oct} or @samp{.mex} file in Octave's @code{path}.
412 
413 @item 5
414 @var{name} is a built-in function.
415 
416 @item 7
417 @var{name} is a directory.
418 
419 @item 8
420 @var{name} is a class. (Note: not currently implemented)
421 
422 @item 103
423 @var{name} is a function not associated with a file (entered on the command
424 line).
425 
426 @item 0
427 @var{name} does not exist.
428 @end table
429 
430 If the optional argument @var{type} is supplied, check only for symbols of the
431 specified type. Valid types are
432 
433 @table @asis
434 @item @qcode{"var"}
435 Check only for variables.
436 
437 @item @qcode{"builtin"}
438 Check only for built-in functions.
439 
440 @item @qcode{"dir"}
441 Check only for directories.
442 
443 @item @qcode{"file"}
444 Check only for files and directories.
445 
446 @item @qcode{"class"}
447 Check only for classes. (Note: This option is accepted, but not currently
448 implemented)
449 @end table
450 
451 If no type is given, and there are multiple possible matches for name,
452 @code{exist} will return a code according to the following priority list:
453 variable, built-in function, oct-file, directory, file, class.
454 
455 @code{exist} returns 2 if a regular file called @var{name} is present in
456 Octave's search path. For information about other types of files not on the
457 search path use some combination of the functions @code{file_in_path} and
458 @code{stat} instead.
459 
460 Programming Note: If @var{name} is implemented by a buggy .oct/.mex file,
461 calling @var{exist} may cause Octave to crash. To maintain high performance,
462 Octave trusts .oct/.mex files instead of @nospell{sandboxing} them.
463 
464 @seealso{file_in_loadpath, file_in_path, dir_in_loadpath, stat}
465 @end deftypefn */)
466 {
467  int nargin = args.length ();
468 
469  if (nargin < 1 || nargin > 2)
470  print_usage ();
471 
472  std::string name = args(0).xstring_value ("exist: NAME must be a string");
473 
474  if (nargin == 2)
475  {
476  std::string type = args(1).xstring_value ("exist: TYPE must be a string");
477 
478  if (type == "class")
479  warning (R"(exist: "class" type argument is not implemented)");
480 
481  return ovl (symbol_exist (interp, name, type));
482  }
483  else
484  return ovl (symbol_exist (interp, name));
485 }
486 
487 /*
488 %!shared dirtmp, __var1
489 %! dirtmp = P_tmpdir ();
490 %! __var1 = 1;
491 
492 %!assert (exist ("__%Highly_unlikely_name%__"), 0)
493 %!assert (exist ("__var1"), 1)
494 %!assert (exist ("__var1", "var"), 1)
495 %!assert (exist ("__var1", "builtin"), 0)
496 %!assert (exist ("__var1", "dir"), 0)
497 %!assert (exist ("__var1", "file"), 0)
498 
499 %!test
500 %! if (isunix ())
501 %! assert (exist ("/bin/sh"), 2);
502 %! assert (exist ("/bin/sh", "file"), 2);
503 %! assert (exist ("/bin/sh", "dir"), 0);
504 %! assert (exist ("/dev/null"), 2);
505 %! assert (exist ("/dev/null", "file"), 2);
506 %! assert (exist ("/dev/null", "dir"), 0);
507 %! endif
508 
509 %!assert (exist ("print_usage"), 2)
510 %!assert (exist ("print_usage.m"), 2)
511 %!assert (exist ("print_usage", "file"), 2)
512 %!assert (exist ("print_usage", "dir"), 0)
513 
514 ## Don't search path for rooted relative filenames
515 %!assert (exist ("plot.m", "file"), 2)
516 %!assert (exist ("./plot.m", "file"), 0)
517 %!assert (exist ("./%nonexistentfile%", "file"), 0)
518 %!assert (exist ("%nonexistentfile%", "file"), 0)
519 
520 ## Don't search path for absolute filenames
521 %!test
522 %! tname = tempname ();
523 %! unwind_protect
524 %! ## open/close file to create it, equivalent of touch
525 %! fid = fopen (tname, "w");
526 %! fclose (fid);
527 %! [~, fname] = fileparts (tname);
528 %! assert (exist (fullfile (tempdir (), fname), "file"), 2);
529 %! unwind_protect_cleanup
530 %! unlink (tname);
531 %! end_unwind_protect
532 %! assert (exist (fullfile (pwd (), "%nonexistentfile%"), "file"), 0);
533 
534 %!assert (exist ("fftw"), 3);
535 %!assert (exist ("fftw.oct"), 3);
536 %!assert (exist ("fftw", "file"), 3);
537 %!assert (exist ("fftw", "builtin"), 0);
538 
539 %!assert (exist ("ftp"), 2);
540 %!assert (exist ("ftp.m"), 2);
541 %!assert (exist ("@ftp/ftp"), 2);
542 %!assert (exist ("@ftp/ftp.m"), 2);
543 
544 %!assert (exist ("inputParser"), 2);
545 %!assert (exist ("inputParser.m"), 2);
546 
547 %!assert (exist ("sin"), 5)
548 %!assert (exist ("sin", "builtin"), 5)
549 %!assert (exist ("sin", "file"), 0)
550 
551 %!assert (exist (dirtmp), 7)
552 %!assert (exist (dirtmp, "dir"), 7)
553 %!assert (exist (dirtmp, "file"), 7)
554 
555 %!error exist ()
556 %!error exist (1,2,3)
557 %!warning <"class" type argument is not implemented> exist ("a", "class");
558 %!error <TYPE must be a string> exist ("a", 1)
559 %!error <NAME must be a string> exist (1)
560 %!error <unrecognized type argument "foobar"> exist ("a", "foobar")
561 
562 */
563 
564 // Variable values.
565 
566 static bool
567 wants_local_change (const octave_value_list& args, int& nargin)
568 {
569  bool retval = false;
570 
571  if (nargin == 2)
572  {
573  if (! args(1).is_string () || args(1).string_value () != "local")
574  error_with_cfn (R"(second argument must be "local")");
575 
576  nargin = 1;
577  retval = true;
578  }
579 
580  return retval;
581 }
582 
583 static octave::unwind_protect *
585 {
587  = octave::__get_evaluator__ ("curr_fcn_unwind_protect_frame");
588 
589  return tw.curr_fcn_unwind_protect_frame ();
590 }
591 
592 template <typename T>
593 static bool
595 {
597 
598  if (frame)
599  {
600  frame->protect_var (var);
601  return true;
602  }
603  else
604  return false;
605 }
606 
608 set_internal_variable (bool& var, const octave_value_list& args,
609  int nargout, const char *nm)
610 {
612 
613  int nargin = args.length ();
614 
615  if (nargout > 0 || nargin == 0)
616  retval = var;
617 
618  if (wants_local_change (args, nargin))
619  {
620  if (! try_local_protect (var))
621  warning (R"("local" has no effect outside a function)");
622  }
623 
624  if (nargin > 1)
625  print_usage ();
626 
627  if (nargin == 1)
628  {
629  bool bval = args(0).xbool_value ("%s: argument must be a logical value", nm);
630 
631  var = bval;
632  }
633 
634  return retval;
635 }
636 
638 set_internal_variable (char& var, const octave_value_list& args,
639  int nargout, const char *nm)
640 {
642 
643  int nargin = args.length ();
644 
645  if (nargout > 0 || nargin == 0)
646  retval = var;
647 
648  if (wants_local_change (args, nargin))
649  {
650  if (! try_local_protect (var))
651  warning (R"("local" has no effect outside a function)");
652  }
653 
654  if (nargin > 1)
655  print_usage ();
656 
657  if (nargin == 1)
658  {
659  std::string sval = args(0).xstring_value ("%s: argument must be a single character", nm);
660 
661  switch (sval.length ())
662  {
663  case 1:
664  var = sval[0];
665  break;
666 
667  case 0:
668  var = '\0';
669  break;
670 
671  default:
672  error ("%s: argument must be a single character", nm);
673  break;
674  }
675  }
676 
677  return retval;
678 }
679 
682  int nargout, const char *nm,
683  int minval, int maxval)
684 {
686 
687  int nargin = args.length ();
688 
689  if (nargout > 0 || nargin == 0)
690  retval = var;
691 
692  if (wants_local_change (args, nargin))
693  {
694  if (! try_local_protect (var))
695  warning (R"("local" has no effect outside a function)");
696  }
697 
698  if (nargin > 1)
699  print_usage ();
700 
701  if (nargin == 1)
702  {
703  int ival = args(0).xint_value ("%s: argument must be an integer value", nm);
704 
705  if (ival < minval)
706  error ("%s: arg must be greater than %d", nm, minval);
707  if (ival > maxval)
708  error ("%s: arg must be less than or equal to %d", nm, maxval);
709 
710  var = ival;
711  }
712 
713  return retval;
714 }
715 
717 set_internal_variable (double& var, const octave_value_list& args,
718  int nargout, const char *nm,
719  double minval, double maxval)
720 {
722 
723  int nargin = args.length ();
724 
725  if (nargout > 0 || nargin == 0)
726  retval = var;
727 
728  if (wants_local_change (args, nargin))
729  {
730  if (! try_local_protect (var))
731  warning (R"("local" has no effect outside a function)");
732  }
733 
734  if (nargin > 1)
735  print_usage ();
736 
737  if (nargin == 1)
738  {
739  double dval = args(0).xscalar_value ("%s: argument must be a scalar value", nm);
740 
741  if (dval < minval)
742  error ("%s: argument must be greater than %g", nm, minval);
743  if (dval > maxval)
744  error ("%s: argument must be less than or equal to %g", nm, maxval);
745 
746  var = dval;
747  }
748 
749  return retval;
750 }
751 
753 set_internal_variable (std::string& var, const octave_value_list& args,
754  int nargout, const char *nm, bool empty_ok)
755 {
757 
758  int nargin = args.length ();
759 
760  if (nargout > 0 || nargin == 0)
761  retval = var;
762 
763  if (wants_local_change (args, nargin))
764  {
765  if (! try_local_protect (var))
766  warning (R"("local" has no effect outside a function)");
767  }
768 
769  if (nargin > 1)
770  print_usage ();
771 
772  if (nargin == 1)
773  {
774  std::string sval = args(0).xstring_value ("%s: first argument must be a string", nm);
775 
776  if (! empty_ok && sval.empty ())
777  error ("%s: value must not be empty", nm);
778 
779  var = sval;
780  }
781 
782  return retval;
783 }
784 
787  int nargout, const char *nm, const char **choices)
788 {
790  int nchoices = 0;
791  while (choices[nchoices] != nullptr)
792  nchoices++;
793 
794  int nargin = args.length ();
795 
796  assert (var < nchoices);
797 
798  if (nargout > 0 || nargin == 0)
799  retval = choices[var];
800 
801  if (wants_local_change (args, nargin))
802  {
803  if (! try_local_protect (var))
804  warning (R"("local" has no effect outside a function)");
805  }
806 
807  if (nargin > 1)
808  print_usage ();
809 
810  if (nargin == 1)
811  {
812  std::string sval = args(0).xstring_value ("%s: first argument must be a string", nm);
813 
814  int i = 0;
815  for (; i < nchoices; i++)
816  {
817  if (sval == choices[i])
818  {
819  var = i;
820  break;
821  }
822  }
823  if (i == nchoices)
824  error (R"(%s: value not allowed ("%s"))", nm, sval.c_str ());
825  }
826 
827  return retval;
828 }
829 
831 set_internal_variable (std::string& var, const octave_value_list& args,
832  int nargout, const char *nm, const char **choices)
833 {
835  int nchoices = 0;
836  while (choices[nchoices] != nullptr)
837  nchoices++;
838 
839  int nargin = args.length ();
840 
841  if (nargout > 0 || nargin == 0)
842  retval = var;
843 
844  if (wants_local_change (args, nargin))
845  {
846  if (! try_local_protect (var))
847  warning (R"("local" has no effect outside a function)");
848  }
849 
850  if (nargin > 1)
851  print_usage ();
852 
853  if (nargin == 1)
854  {
855  std::string sval = args(0).xstring_value ("%s: first argument must be a string", nm);
856 
857  int i = 0;
858  for (; i < nchoices; i++)
859  {
860  if (sval == choices[i])
861  {
862  var = sval;
863  break;
864  }
865  }
866  if (i == nchoices)
867  error (R"(%s: value not allowed ("%s"))", nm, sval.c_str ());
868  }
869 
870  return retval;
871 }
872 
873 // NOTE: Calling Fmlock directly (without an associated stack frame)
874 // will probably not do what you expect because it will lock the calling
875 // function. You should use interpreter::mlock directly if you want to
876 // lock a .oct function. For .mex, you would normally use mexLock.
877 //
878 // FIXME: with the current implementation, calling "builtin ('mlock')"
879 // will also not do what you expect. Is there any reasonable way to fix
880 // that?
881 
882 DEFMETHOD (mlock, interp, args, ,
883  doc: /* -*- texinfo -*-
884 @deftypefn {} {} mlock ()
885 Lock the current function into memory so that it can't be removed with
886 @code{clear}.
887 @seealso{munlock, mislocked, persistent, clear}
888 @end deftypefn */)
889 {
890  if (args.length () != 0)
891  print_usage ();
892 
893  interp.mlock (true);
894 
895  return ovl ();
896 }
897 
898 DEFMETHOD (munlock, interp, args, ,
899  doc: /* -*- texinfo -*-
900 @deftypefn {} {} munlock ()
901 @deftypefnx {} {} munlock (@var{fcn})
902 Unlock the named function @var{fcn} so that it may be removed from memory with
903 @code{clear}.
904 
905 If no function is named then unlock the current function.
906 @seealso{mlock, mislocked, persistent, clear}
907 @end deftypefn */)
908 {
909  int nargin = args.length ();
910 
911  if (nargin > 1)
912  print_usage ();
913 
914  if (nargin == 1)
915  {
916  std::string name
917  = args(0).xstring_value ("munlock: FCN must be a string");
918 
919  interp.munlock (name);
920  }
921  else
922  interp.munlock (true);
923 
924  return ovl ();
925 }
926 
927 DEFMETHOD (mislocked, interp, args, ,
928  doc: /* -*- texinfo -*-
929 @deftypefn {} {} mislocked ()
930 @deftypefnx {} {} mislocked (@var{fcn})
931 Return true if the named function @var{fcn} is locked in memory.
932 
933 If no function is named then return true if the current function is locked.
934 @seealso{mlock, munlock, persistent, clear}
935 @end deftypefn */)
936 {
937  int nargin = args.length ();
938 
939  if (nargin > 1)
940  print_usage ();
941 
942  if (nargin == 1)
943  {
944  std::string name
945  = args(0).xstring_value ("mislocked: FCN must be a string");
946 
947  return ovl (interp.mislocked (name));
948  }
949  else
950  return ovl (interp.mislocked (true));
951 }
952 
953 // Deleting names from the symbol tables.
954 
955 static inline bool
956 name_matches_any_pattern (const std::string& nm, const string_vector& argv,
957  int argc, int idx, bool have_regexp = false)
958 {
959  bool retval = false;
960 
961  for (int k = idx; k < argc; k++)
962  {
963  std::string patstr = argv[k];
964  if (! patstr.empty ())
965  {
966  if (have_regexp)
967  {
968  if (octave::regexp::is_match (patstr, nm))
969  {
970  retval = true;
971  break;
972  }
973  }
974  else
975  {
976  glob_match pattern (patstr);
977 
978  if (pattern.match (nm))
979  {
980  retval = true;
981  break;
982  }
983  }
984  }
985  }
986 
987  return retval;
988 }
989 
990 static inline void
991 maybe_warn_exclusive (bool exclusive)
992 {
993  if (exclusive)
994  warning ("clear: ignoring --exclusive option");
995 }
996 
997 static void
999  const string_vector& argv, int argc, int idx,
1000  bool exclusive = false)
1001 {
1002  if (idx == argc)
1003  interp.clear_functions ();
1004  else
1005  {
1006  if (exclusive)
1007  {
1008  std::list<std::string> fcns = interp.user_function_names ();
1009 
1010  for (const auto& name : fcns)
1011  {
1012  if (! name_matches_any_pattern (name, argv, argc, idx))
1013  interp.clear_function (name);
1014  }
1015  }
1016  else
1017  {
1018  while (idx < argc)
1019  interp.clear_function_pattern (argv[idx++]);
1020  }
1021  }
1022 }
1023 
1024 static void
1026  const string_vector& argv, int argc, int idx,
1027  bool exclusive = false)
1028 {
1029  if (idx == argc)
1030  {
1031  std::list<std::string> gvars = interp.global_variable_names ();
1032 
1033  for (const auto& name : gvars)
1034  {
1035  interp.clear_variable (name);
1036  interp.clear_global_variable (name);
1037  }
1038  }
1039  else
1040  {
1041  if (exclusive)
1042  {
1043  std::list<std::string> gvars = interp.global_variable_names ();
1044 
1045  for (const auto& name : gvars)
1046  {
1047  if (! name_matches_any_pattern (name, argv, argc, idx))
1048  {
1049  interp.clear_variable (name);
1050  interp.clear_global_variable (name);
1051  }
1052  }
1053  }
1054  else
1055  {
1056  while (idx < argc)
1057  {
1058  std::string pattern = argv[idx++];
1059 
1060  interp.clear_variable_pattern (pattern);
1061  interp.clear_global_variable_pattern (pattern);
1062  }
1063  }
1064  }
1065 }
1066 
1067 static void
1069  const string_vector& argv, int argc, int idx,
1070  bool exclusive = false, bool have_regexp = false)
1071 {
1072  if (idx == argc)
1073  interp.clear_variables ();
1074  else
1075  {
1076  if (exclusive)
1077  {
1078  std::list<std::string> lvars = interp.variable_names ();
1079 
1080  for (const auto& name : lvars)
1081  {
1082  if (! name_matches_any_pattern (name, argv, argc, idx,
1083  have_regexp))
1084  interp.clear_variable (name);
1085  }
1086  }
1087  else
1088  {
1089  if (have_regexp)
1090  while (idx < argc)
1091  interp.clear_variable_regexp (argv[idx++]);
1092  else
1093  while (idx < argc)
1094  interp.clear_variable_pattern (argv[idx++]);
1095  }
1096  }
1097 }
1098 
1099 static void
1101  const string_vector& argv, int argc, int idx,
1102  bool exclusive = false)
1103 {
1104  if (idx == argc)
1105  {
1106  interp.clear_variables ();
1107  }
1108  else
1109  {
1110  if (exclusive)
1111  {
1112  // FIXME: is this really what we want, or do we
1113  // somehow want to only clear the functions that are not
1114  // shadowed by local variables? It seems that would be a
1115  // bit harder to do.
1116 
1117  do_clear_variables (interp, argv, argc, idx, exclusive);
1118  do_clear_functions (interp, argv, argc, idx, exclusive);
1119  }
1120  else
1121  {
1122  while (idx < argc)
1123  interp.clear_symbol_pattern (argv[idx++]);
1124  }
1125  }
1126 }
1127 
1128 static void
1130  const string_vector& argv, int argc, int idx)
1131 {
1132  // This is supposed to be mostly Matlab compatible.
1133 
1134  for (; idx < argc; idx++)
1135  {
1136  if (argv[idx] == "all" && ! interp.is_local_variable ("all"))
1137  {
1138  interp.clear_all ();
1139  }
1140  else if (argv[idx] == "functions"
1141  && ! interp.is_local_variable ("functions"))
1142  {
1143  do_clear_functions (interp, argv, argc, ++idx);
1144  }
1145  else if (argv[idx] == "global"
1146  && ! interp.is_local_variable ("global"))
1147  {
1148  do_clear_globals (interp, argv, argc, ++idx);
1149  }
1150  else if (argv[idx] == "variables"
1151  && ! interp.is_local_variable ("variables"))
1152  {
1153  interp.clear_variables ();
1154  }
1155  else if (argv[idx] == "classes"
1156  && ! interp.is_local_variable ("classes"))
1157  {
1158  interp.clear_objects ();
1160  interp.clear_all ();
1161  }
1162  else
1163  {
1164  interp.clear_symbol_pattern (argv[idx]);
1165  }
1166  }
1167 }
1168 
1169 DEFMETHOD (clear, interp, args, ,
1170  doc: /* -*- texinfo -*-
1171 @deftypefn {} {} clear
1172 @deftypefnx {} {} clear @var{pattern} @dots{}
1173 @deftypefnx {} {} clear @var{options} @var{pattern} @dots{}
1174 Delete the names matching the given @var{pattern}s thereby freeing memory.
1175 
1176 The @var{pattern} may contain the following special characters:
1177 
1178 @table @code
1179 @item ?
1180 Match any single character.
1181 
1182 @item *
1183 Match zero or more characters.
1184 
1185 @item [ @var{list} ]
1186 Match the list of characters specified by @var{list}. If the first character
1187 is @code{!} or @code{^}, match all characters except those specified by
1188 @var{list}. For example, the pattern @code{[a-zA-Z]} will match all lowercase
1189 and uppercase alphabetic characters.
1190 @end table
1191 
1192 For example, the command
1193 
1194 @example
1195 clear foo b*r
1196 @end example
1197 
1198 @noindent
1199 clears the name @code{foo} and all names that begin with the letter @samp{b}
1200 and end with the letter @samp{r}.
1201 
1202 If @code{clear} is called without any arguments, all user-defined variables
1203 are cleared from the current workspace (i.e., local variables). Any global
1204 variables present will no longer be visible in the current workspace, but they
1205 will continue to exist in the global workspace. Functions are unaffected by
1206 this form of @code{clear}.
1207 
1208 The following options are available in both long and short form
1209 
1210 @table @code
1211 @item all, -all, -a
1212 Clear all local and global user-defined variables, and all functions from the
1213 symbol table.
1214 
1215 @item -exclusive, -x
1216 Clear variables that do @strong{not} match the following pattern.
1217 
1218 @item functions, -functions, -f
1219 Clear function names from the function symbol table. Persistent variables
1220 will be re-initialized to their default value unless the function has been
1221 locked in memory with @code{mlock}.
1222 
1223 @item global, -global, -g
1224 Clear global variable names.
1225 
1226 @item variables, -variables, -v
1227 Clear local variable names.
1228 
1229 @item classes, -classes, -c
1230 Clear the class structure table and all objects.
1231 
1232 @item -regexp, -r
1233 The @var{pattern} arguments are treated as regular expressions and any matches
1234 will be cleared.
1235 @end table
1236 
1237 With the exception of @option{-exclusive} and @option{-regexp}, all long
1238 options can be used without the dash as well. Note that, aside from
1239 @option{-exclusive}, only one other option may appear. All options must
1240 appear before any patterns.
1241 
1242 Programming Notes: The command @code{clear @var{name}} only clears the variable
1243 @var{name} when both a variable and a (shadowed) function named @var{name}
1244 are currently defined. For example, suppose you have defined a function
1245 @code{foo}, and then hidden it by performing the assignment @code{foo = 2}.
1246 Executing the command @code{clear foo} once will clear the variable
1247 definition and restore the definition of @code{foo} as a function.
1248 Executing @code{clear foo} a second time will clear the function definition.
1249 
1250 When a local variable name, which is linked to a global variable, is cleared
1251 only the local copy of the variable is removed. The global copy is untouched
1252 and can be restored with @code{global @var{global_varname}}. Conversely,
1253 @code{clear -g @var{global_varname}} will remove both the local and global
1254 variables.
1255 
1256 @seealso{clearvars, who, whos, exist, mlock}
1257 @end deftypefn */)
1258 {
1259  int argc = args.length () + 1;
1260 
1261  string_vector argv = args.make_argv ("clear");
1262 
1263  if (argc == 1)
1264  {
1265  do_clear_variables (interp, argv, argc, true);
1266 
1267  octave::event_manager& evmgr = interp.get_event_manager ();
1268 
1269  evmgr.clear_workspace ();
1270  }
1271  else
1272  {
1273  int idx = 0;
1274 
1275  bool clear_all = false;
1276  bool clear_functions = false;
1277  bool clear_globals = false;
1278  bool clear_variables = false;
1279  bool clear_objects = false;
1280  bool exclusive = false;
1281  bool have_regexp = false;
1282  bool have_dash_option = false;
1283 
1284  while (++idx < argc)
1285  {
1286  if (argv[idx] == "-all" || argv[idx] == "-a")
1287  {
1288  if (have_dash_option)
1289  print_usage ();
1290 
1291  have_dash_option = true;
1292  clear_all = true;
1293  }
1294  else if (argv[idx] == "-exclusive" || argv[idx] == "-x")
1295  {
1296  exclusive = true;
1297  }
1298  else if (argv[idx] == "-functions" || argv[idx] == "-f")
1299  {
1300  if (have_dash_option)
1301  print_usage ();
1302 
1303  have_dash_option = true;
1304  clear_functions = true;
1305  }
1306  else if (argv[idx] == "-global" || argv[idx] == "-g")
1307  {
1308  if (have_dash_option)
1309  print_usage ();
1310 
1311  have_dash_option = true;
1312  clear_globals = true;
1313  }
1314  else if (argv[idx] == "-variables" || argv[idx] == "-v")
1315  {
1316  if (have_dash_option)
1317  print_usage ();
1318 
1319  have_dash_option = true;
1320  clear_variables = true;
1321  }
1322  else if (argv[idx] == "-classes" || argv[idx] == "-c")
1323  {
1324  if (have_dash_option)
1325  print_usage ();
1326 
1327  have_dash_option = true;
1328  clear_objects = true;
1329  }
1330  else if (argv[idx] == "-regexp" || argv[idx] == "-r")
1331  {
1332  if (have_dash_option)
1333  print_usage ();
1334 
1335  have_dash_option = true;
1336  have_regexp = true;
1337  }
1338  else
1339  break;
1340  }
1341 
1342  if (idx <= argc)
1343  {
1344  if (! have_dash_option && ! exclusive)
1345  do_matlab_compatible_clear (interp, argv, argc, idx);
1346  else
1347  {
1348  if (clear_all)
1349  {
1350  maybe_warn_exclusive (exclusive);
1351 
1352  if (++idx < argc)
1353  warning ("clear: ignoring extra arguments after -all");
1354 
1355  interp.clear_all ();
1356  }
1357  else if (have_regexp)
1358  {
1359  do_clear_variables (interp, argv, argc, idx, exclusive, true);
1360  }
1361  else if (clear_functions)
1362  {
1363  do_clear_functions (interp, argv, argc, idx, exclusive);
1364  }
1365  else if (clear_globals)
1366  {
1367  do_clear_globals (interp, argv, argc, idx, exclusive);
1368  }
1369  else if (clear_variables)
1370  {
1371  do_clear_variables (interp, argv, argc, idx, exclusive);
1372  }
1373  else if (clear_objects)
1374  {
1375  interp.clear_objects ();
1377  interp.clear_all ();
1378  }
1379  else
1380  {
1381  do_clear_symbols (interp, argv, argc, idx, exclusive);
1382  }
1383  }
1384  }
1385  }
1386 
1387  return ovl ();
1388 }
1389 
1390 /*
1391 ## This test must be wrapped in its own function or the 'clear' command will
1392 ## break the %!test environment.
1393 %!function __test_clear_no_args__ ()
1394 %! global x
1395 %! x = 3;
1396 %! clear
1397 %! assert (! exist ("x", "var")); # x is not in the current workspace anymore
1398 %! global x # but still lives in the global workspace
1399 %! assert (exist ("x", "var"));
1400 %!endfunction
1401 
1402 %!test
1403 %! unwind_protect
1404 %! __test_clear_no_args__ ();
1405 %! unwind_protect_cleanup
1406 %! clear -g x
1407 %! end_unwind_protect
1408 
1409 ## Test that multiple options cannot be given
1410 %!error clear -f -g
1411 */
1412 
1413 static std::string Vmissing_function_hook = "__unimplemented__";
1414 
1415 DEFUN (missing_function_hook, args, nargout,
1416  doc: /* -*- texinfo -*-
1417 @deftypefn {} {@var{val} =} missing_function_hook ()
1418 @deftypefnx {} {@var{old_val} =} missing_function_hook (@var{new_val})
1419 @deftypefnx {} {} missing_function_hook (@var{new_val}, "local")
1420 Query or set the internal variable that specifies the function to call
1421 to provide extra information when an unknown identifier is referenced.
1422 
1423 When called from inside a function with the @qcode{"local"} option, the
1424 variable is changed locally for the function and any subroutines it calls.
1425 The original variable value is restored when exiting the function.
1426 @seealso{missing_component_hook}
1427 @end deftypefn */)
1428 {
1429  return SET_INTERNAL_VARIABLE (missing_function_hook);
1430 }
1431 
1432 std::string
1433 maybe_missing_function_hook (const std::string& name)
1434 {
1435  octave::interpreter& interp
1436  = octave::__get_interpreter__ ("maybe_missing_function_hook");
1437 
1438  // Don't do this if we're handling errors.
1439  if (Vmissing_function_hook.empty ())
1440  return "";
1441 
1442  octave::symbol_table& symtab = interp.get_symbol_table ();
1443 
1445 
1446  if (val.is_defined ())
1447  {
1448  // Ensure auto-restoration.
1449  octave::unwind_protect frame;
1451 
1452  // Clear the variable prior to calling the function.
1453  const std::string func_name = Vmissing_function_hook;
1454  Vmissing_function_hook.clear ();
1455 
1456  // Call.
1457  octave_value_list tmp = octave::feval (func_name, octave_value (name), 1);
1458 
1459  if (tmp.length () == 1 && tmp(0).is_string ())
1460  return tmp(0).string_value ();
1461  }
1462 
1463  return "";
1464 }
1465 
1466 DEFMETHOD (__varval__, interp, args, ,
1467  doc: /* -*- texinfo -*-
1468 @deftypefn {} {} __varval__ (@var{name})
1469 Return the value of the variable @var{name} directly from the symbol table.
1470 @end deftypefn */)
1471 {
1472  if (args.length () != 1)
1473  print_usage ();
1474 
1475  std::string name = args(0).xstring_value ("__varval__: first argument must be a variable name");
1476 
1477  std::string nm = args(0).string_value ();
1478 
1479  // FIXME: we need this kluge to implement inputname in a .m file.
1480 
1481  if (nm == ".argn.")
1482  {
1483  octave::tree_evaluator& tw = interp.get_evaluator ();
1484 
1486  }
1487 
1488  return interp.varval (nm);
1489 }
1490 
1491 static std::string Vmissing_component_hook;
1492 
1493 DEFUN (missing_component_hook, args, nargout,
1494  doc: /* -*- texinfo -*-
1495 @deftypefn {} {@var{val} =} missing_component_hook ()
1496 @deftypefnx {} {@var{old_val} =} missing_component_hook (@var{new_val})
1497 @deftypefnx {} {} missing_component_hook (@var{new_val}, "local")
1498 Query or set the internal variable that specifies the function to call when
1499 a component of Octave is missing.
1500 
1501 This can be useful for packagers that may split the Octave installation into
1502 multiple sub-packages, for example, to provide a hint to users for how to
1503 install the missing components.
1504 
1505 When called from inside a function with the @qcode{"local"} option, the
1506 variable is changed locally for the function and any subroutines it calls.
1507 The original variable value is restored when exiting the function.
1508 
1509 The hook function is expected to be of the form
1510 
1511 @example
1512 @var{fcn} (@var{component})
1513 @end example
1514 
1515 Octave will call @var{fcn} with the name of the function that requires the
1516 component and a string describing the missing component. The hook function
1517 should return an error message to be displayed.
1518 @seealso{missing_function_hook}
1519 @end deftypefn */)
1520 {
1521  return SET_INTERNAL_VARIABLE (missing_component_hook);
1522 }
1523 
1524 // The following function is deprecated.
1525 
1527 get_struct_elts (const std::string& text)
1528 {
1529  int n = 1;
1530 
1531  size_t pos = 0;
1532 
1533  size_t len = text.length ();
1534 
1535  while ((pos = text.find ('.', pos)) != std::string::npos)
1536  {
1537  if (++pos == len)
1538  break;
1539 
1540  n++;
1541  }
1542 
1544 
1545  pos = 0;
1546 
1547  for (int i = 0; i < n; i++)
1548  {
1549  len = text.find ('.', pos);
1550 
1551  if (len != std::string::npos)
1552  len -= pos;
1553 
1554  retval[i] = text.substr (pos, len);
1555 
1556  if (len != std::string::npos)
1557  pos += len + 1;
1558  }
1559 
1560  return retval;
1561 }
bool match(const std::string &str) const
Definition: glob-match.cc:35
Provides threadsafe access to octave.
void clear_workspace(void)
octave_value varval(const std::string &name) const
octave_value_list eval_string(const std::string &eval_str, bool silent, int &parse_status, int nargout)
void clear_variables(void)
std::list< std::string > user_function_names(void)
std::list< std::string > variable_names(void)
void clear_function(const std::string &name)
bool is_local_variable(const std::string &name) const
void clear_function_pattern(const std::string &pat)
void clear_global_variable(const std::string &name)
void clear_global_variable_pattern(const std::string &pattern)
void clear_functions(bool force=false)
void clear_variable_pattern(const std::string &pattern)
load_path & get_load_path(void)
Definition: interpreter.h:243
void clear_variable(const std::string &name)
void clear_objects(void)
symbol_table & get_symbol_table(void)
Definition: interpreter.h:258
void clear_all(bool force=false)
void clear_variable_regexp(const std::string &pattern)
void clear_symbol_pattern(const std::string &pat)
std::list< std::string > global_variable_names(void)
tree_evaluator & get_evaluator(void)
std::string find_method(const std::string &class_name, const std::string &meth, std::string &dir_name, const std::string &pack_name="")
Definition: load-path.h:79
std::string find_fcn(const std::string &fcn, std::string &dir_name, const std::string &pack_name="")
Definition: load-path.h:111
bool is_match(const std::string &buffer)
Definition: lo-regexp.cc:440
octave_value find_cmdline_function(const std::string &name)
Definition: symtab.cc:310
bool is_built_in_function_name(const std::string &name)
Definition: symtab.cc:67
octave_value find_function(const std::string &name, const symbol_scope &search_scope=symbol_scope())
Definition: symtab.cc:249
bool is_dir(void) const
Definition: file-stat.cc:65
octave_value get_auto_fcn_var(stack_frame::auto_var_type avt) const
Definition: pt-eval.cc:1594
std::string lookup_autoload(const std::string &nm) const
Definition: pt-eval.cc:3684
unwind_protect * curr_fcn_unwind_protect_frame(void)
Definition: pt-eval.cc:1897
static void clear_exemplar_map(void)
Definition: ov-class.cc:1099
octave_idx_type length(void) const
Definition: ovl.h:113
bool is_constant(void) const
Definition: ov.h:718
bool is_string(void) const
Definition: ov.h:593
bool is_defined(void) const
Definition: ov.h:551
bool is_function_handle(void) const
Definition: ov.h:721
octave_function * function_value(bool silent=false) const
std::string string_value(bool force=false) const
Definition: ov.h:927
bool is_anonymous_function(void) const
Definition: ov.h:724
bool isobject(void) const
Definition: ov.h:620
std::string xstring_value(const char *fmt,...) const
bool is_inline_function(void) const
Definition: ov.h:727
OCTINTERP_API void print_usage(void)
Definition: defun.cc:53
#define DEFMETHOD(name, interp_name, args_name, nargout_name, doc)
Macro to define a builtin method.
Definition: defun.h:138
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
Definition: defun.h:56
void warning(const char *fmt,...)
Definition: error.cc:1050
void error_with_cfn(const char *fmt,...)
Definition: error.cc:998
void error(const char *fmt,...)
Definition: error.cc:968
QString name
static std::string basename(const std::string &s, bool strip_path=false)
octave_idx_type n
Definition: mx-inlines.cc:753
bool drive_or_unc_share(const std::string &name)
Definition: sysdep.cc:384
interpreter & __get_interpreter__(const std::string &who)
bool iskeyword(const std::string &s)
Definition: lex.cc:1283
tree_evaluator & __get_evaluator__(const std::string &who)
octave_value_list feval(const char *name, const octave_value_list &args, int nargout)
Evaluate an Octave function (built-in or interpreted) and return the list of result values.
Definition: oct-parse.cc:9580
std::string file_in_path(const std::string &name, const std::string &suffix)
Definition: utils.cc:541
symbol_table & __get_symbol_table__(const std::string &who)
octave_value::octave_value(const Array< char > &chm, char type) return retval
Definition: ov.cc:811
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.
Definition: ovl.h:211
octave_value set_internal_variable(bool &var, const octave_value_list &args, int nargout, const char *nm)
Definition: variables.cc:608
static void do_matlab_compatible_clear(octave::interpreter &interp, const string_vector &argv, int argc, int idx)
Definition: variables.cc:1129
#define GET_IDX(LEN)
Definition: variables.cc:366
static void do_clear_globals(octave::interpreter &interp, const string_vector &argv, int argc, int idx, bool exclusive=false)
Definition: variables.cc:1025
static bool try_local_protect(T &var)
Definition: variables.cc:594
static bool name_matches_any_pattern(const std::string &nm, const string_vector &argv, int argc, int idx, bool have_regexp=false)
Definition: variables.cc:956
static void do_clear_functions(octave::interpreter &interp, const string_vector &argv, int argc, int idx, bool exclusive=false)
Definition: variables.cc:998
static void do_clear_symbols(octave::interpreter &interp, const string_vector &argv, int argc, int idx, bool exclusive=false)
Definition: variables.cc:1100
octave_function * extract_function(const octave_value &arg, const std::string &warn_for, const std::string &fname, const std::string &header, const std::string &trailer)
Definition: variables.cc:124
static octave::unwind_protect * curr_fcn_unwind_protect_frame(void)
Definition: variables.cc:584
string_vector get_struct_elts(const std::string &text)
Definition: variables.cc:1527
std::string maybe_missing_function_hook(const std::string &name)
Definition: variables.cc:1433
octave_function * is_valid_function(const std::string &fcn_name, const std::string &warn_for, bool warn)
Definition: variables.cc:77
std::string unique_symbol_name(const std::string &basename)
Definition: variables.cc:370
static void do_clear_variables(octave::interpreter &interp, const string_vector &argv, int argc, int idx, bool exclusive=false, bool have_regexp=false)
Definition: variables.cc:1068
static bool wants_local_change(const octave_value_list &args, int &nargin)
Definition: variables.cc:567
static int symbol_exist(octave::interpreter &interp, const std::string &name, const std::string &type="any")
Definition: variables.cc:200
static std::string Vmissing_function_hook
Definition: variables.cc:1413
static void maybe_warn_exclusive(bool exclusive)
Definition: variables.cc:991
static std::string Vmissing_component_hook
Definition: variables.cc:1491
#define SET_INTERNAL_VARIABLE(NM)
Definition: variables.h:103
F77_RET_T len
Definition: xerbla.cc:61