GNU Octave 7.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
toplev.cc
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 1995-2022 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 <cerrno>
31#include <cstdlib>
32
33#include <new>
34#include <sstream>
35#include <string>
36
37#if defined (OCTAVE_USE_WINDOWS_API)
38# define WIN32_LEAN_AND_MEAN 1
39# include <windows.h>
40#endif
41
43#include "child-list.h"
44#include "lo-error.h"
45#include "oct-fftw.h"
46#include "oct-locbuf.h"
47#include "oct-syscalls.h"
48#include "signal-wrappers.h"
49#include "str-vec.h"
50#include "wait-for-input.h"
51
52#include "build-env.h"
54#include "defaults.h"
55#include "defun.h"
56#include "error.h"
57#include "file-io.h"
58#include "help.h"
59#include "interpreter-private.h"
60#include "octave.h"
61#include "oct-map.h"
62#include "ovl.h"
63#include "ov.h"
64#include "pager.h"
65#include "procstream.h"
66#include "sysdep.h"
67#include "unwind-prot.h"
68#include "utils.h"
69#include "version.h"
70
71#if ! defined (SHELL_PATH)
72# define SHELL_PATH "/bin/sh"
73#endif
74
75OCTAVE_NAMESPACE_BEGIN
76
77#define STRINGIFY(s) STRINGIFY1(s)
78#define STRINGIFY1(s) #s
79
80DEFUN (warranty, , ,
81 doc: /* -*- texinfo -*-
82@deftypefn {} {} warranty ()
83Describe the conditions for copying and distributing Octave.
84@end deftypefn */)
85{
87\n\
88GNU Octave is free software: you can redistribute it and/or modify it\n\
89under the terms of the GNU General Public License as published by\n\
90the Free Software Foundation, either version 3 of the License, or\n\
91(at your option) any later version.\n\
92\n\
93GNU Octave is distributed in the hope that it will be useful, but\n\
94WITHOUT ANY WARRANTY; without even the implied warranty of\n\
95MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\
96GNU General Public License for more details.\n\
97\n\
98You should have received a copy of the GNU General Public License\n\
99along with GNU Octave; see the file COPYING. If not, see\n\
100<https://www.gnu.org/licenses/>.\n\
101\n";
102
103 return ovl ();
104}
105
106// Execute a shell command.
107
109run_command_and_return_output (const std::string& cmd_str)
110{
111 octave_value_list retval;
112 unwind_protect frame;
113
114 iprocstream *cmd = new iprocstream (cmd_str.c_str ());
115 frame.add_delete (cmd);
116
117 child_list& kids
118 = __get_child_list__ ("run_command_and_return_output");
119 frame.add (&child_list::remove, kids, cmd->pid ());
120
121 if (! *cmd)
122 error ("system: unable to start subprocess for '%s'", cmd_str.c_str ());
123
124 int fid = cmd->file_number ();
125
126 std::ostringstream output_buf;
127
128 char ch;
129
130 for (;;)
131 {
132 if (cmd->get (ch))
133 output_buf.put (ch);
134 else
135 {
136 if (! cmd->eof () && errno == EAGAIN)
137 {
138 cmd->clear ();
139
140 if (octave_wait_for_input (fid) != 1)
141 break;
142 }
143 else
144 break;
145 }
146 }
147
148 int cmd_status = cmd->close ();
149
150 if (sys::wifexited (cmd_status))
151 cmd_status = sys::wexitstatus (cmd_status);
152 else
153 cmd_status = 127;
154
155 retval = ovl (cmd_status, output_buf.str ());
156
157 return retval;
158}
159
160// Combine alloc+get in one action.
161
162static void *
164{
165 void *mask = octave_alloc_signal_mask ();
166
168
169 return mask;
170}
171
172// Combine set+free in one action.
173
174static void
176{
178
180}
181
183
184DEFUN (system, args, nargout,
185 doc: /* -*- texinfo -*-
186@deftypefn {} {} system ("@var{string}")
187@deftypefnx {} {} system ("@var{string}", @var{return_output})
188@deftypefnx {} {} system ("@var{string}", @var{return_output}, @var{type})
189@deftypefnx {} {[@var{status}, @var{output}] =} system (@dots{})
190Execute a shell command specified by @var{string}.
191
192If @var{system} is called with one or more output arguments, or if the optional
193argument @var{return_output} is true and the subprocess is started
194synchronously, then the output from the command is returned as a variable.
195Otherwise, if the subprocess is executed synchronously, its output is sent to
196the standard output. To send the output of a command executed with
197@code{system} through the pager, use a command like
198
199@example
200@group
201[~, text] = system ("cmd");
202more on;
203disp (text);
204@end group
205@end example
206
207@noindent
208or
209
210@example
211@group
212more on;
213printf ("%s\n", nthargout (2, "system", "cmd"));
214@end group
215@end example
216
217If the optional argument @var{type} is @qcode{"async"}, the process is started
218in the background and the process ID of the child process is returned
219immediately. Otherwise, the child process is started and Octave waits until it
220exits. If the @var{type} argument is omitted, it defaults to the value
221@qcode{"sync"}.
222
223The @code{system} function can return two values. The first is the exit status
224of the command and the second is any output from the command that was written
225to the standard output stream. For example,
226
227@example
228[status, output] = system ("echo foo & exit 2");
229@end example
230
231@noindent
232will set the variable @var{output} to the string @samp{foo}, and the variable
233@var{status} to the integer @samp{2}.
234
235For commands run asynchronously, @var{status} is the process id of the command
236shell that is started to run the command.
237
238The shell used for executing commands varies with operating system and is
239typically @file{/bin/sh} for UNIX systems and @nospell{@file{cmd.exe}} for
240Windows systems.
241@seealso{unix, dos}
242@end deftypefn */)
243{
244 int nargin = args.length ();
245
246 if (nargin == 0 || nargin > 3)
247 print_usage ();
248
250 if (nargin == 3)
251 {
252 std::string type_str = args(2).xstring_value ("system: TYPE must be a string");
253
254 if (type_str == "sync")
255 type = et_sync;
256 else if (type_str == "async")
257 type = et_async;
258 else
259 error (R"(system: TYPE must be "sync" or "async")");
260 }
261
262 octave_value_list retval;
263
264 bool return_output = (nargin == 1 && nargout > 1);
265
266 if (nargin > 1)
267 {
268 try
269 {
270 return_output = args(1).is_true ();
271 }
272 catch (execution_exception& ee)
273 {
274 error (ee, "system: RETURN_OUTPUT must be boolean value true or false");
275 }
276 }
277
278 if (return_output && type == et_async)
279 error ("system: can't return output from commands run asynchronously");
280
281 std::string cmd_str = args(0).xstring_value ("system: first argument must be a string");
282
283#if defined (OCTAVE_USE_WINDOWS_API)
284 // Work around weird double-quote handling on Windows systems.
285 if (type == et_sync)
286 cmd_str = '"' + cmd_str + '"';
287#endif
288
289 unwind_action restore_mask
290 ([] (void *mask) { restore_signal_mask (mask); }, get_signal_mask ());
291
294
295 if (type == et_async)
296 retval(0) = octave_async_system_wrapper (cmd_str.c_str ());
297 else if (return_output)
298 retval = run_command_and_return_output (cmd_str);
299 else
300 {
301 int status = sys::system (cmd_str);
302
303 // The value in status is as returned by waitpid. If
304 // the process exited normally, extract the actual exit
305 // status of the command. Otherwise, return 127 as a
306 // failure code.
307
308 if (sys::wifexited (status))
309 status = sys::wexitstatus (status);
310
311 retval(0) = status;
312 }
313
314 return retval;
315}
316
317/*
318%!test
319%! cmd = ls_command ();
320%! [status, output] = system (cmd);
321%! assert (status, 0);
322%! assert (ischar (output));
323%! assert (! isempty (output));
324
325%!error system ()
326%!error system (1, 2, 3)
327*/
328
329static octave_value
330find_config_info (const octave_scalar_map& m, const std::string& key)
331{
332 if (m.isfield (key))
333 {
334 Cell c = m.contents (key);
335
336 if (! c.isempty ())
337 return c(0);
338 }
339
340 return octave_value ();
341}
342
343DEFUN (__octave_config_info__, args, ,
344 doc: /* -*- texinfo -*-
345@deftypefn {} {} __octave_config_info__ ()
346@deftypefnx {} {} __octave_config_info__ (@var{option})
347Return a structure containing configuration and installation information for
348Octave.
349
350If @var{option} is a string, return the configuration information for the
351specified option.
352
353@seealso{computer}
354@end deftypefn */)
355{
357 static octave_scalar_map build_env;
358 static octave_scalar_map build_features;
359
360 static bool initialized = false;
361
362 if (! initialized)
363 {
364 std::map<std::string, octave_value> conf_info_map
365 = {{ "DEFAULT_PAGER", config::default_pager () },
366
367#if defined (OCTAVE_ENABLE_64)
368 { "ENABLE_64", true },
369#else
370 { "ENABLE_64", false },
371#endif
372
373#if defined (OCTAVE_ENABLE_COMMAND_LINE_PUSH_PARSER)
374 { "ENABLE_COMMAND_LINE_PUSH_PARSER", true },
375#else
376 { "ENABLE_COMMAND_LINE_PUSH_PARSER", false },
377#endif
378
379#if defined (ENABLE_DOCS)
380 { "ENABLE_DOCS", true },
381#else
382 { "ENABLE_DOCS", false },
383#endif
384
385#if defined (OCTAVE_ENABLE_FLOAT_TRUNCATE)
386 { "ENABLE_FLOAT_TRUNCATE", true },
387#else
388 { "ENABLE_FLOAT_TRUNCATE", false },
389#endif
390
391#if defined (OCTAVE_ENABLE_OPENMP)
392 { "ENABLE_OPENMP", true },
393#else
394 { "ENABLE_OPENMP", false },
395#endif
396
397 { "api_version", OCTAVE_API_VERSION },
398 { "archlibdir", config::arch_lib_dir () },
399 { "bindir", config::bin_dir () },
400 { "canonical_host_type", config::canonical_host_type () },
401 { "datadir", config::data_dir () },
402 { "datarootdir", config::dataroot_dir () },
403 { "fcnfiledir", config::fcn_file_dir () },
404 { "fftw_version", fftw_version () },
405 { "fftwf_version", fftwf_version () },
406 { "imagedir", config::image_dir () },
407 { "includedir", config::include_dir () },
408 { "infodir", config::info_dir () },
409 { "libdir", config::lib_dir () },
410 { "libexecdir", config::libexec_dir () },
411 // Each library and executable has its own definition of the hg
412 // id. We check for consistency when Octave starts so we just
413 // store and report one of them here.
414 { "hg_id", liboctinterp_hg_id () },
415 { "localapiarchlibdir", config::local_api_arch_lib_dir () },
416 { "localapifcnfiledir", config::local_api_fcn_file_dir () },
417 { "localapioctfiledir", config::local_api_oct_file_dir () },
418 { "localarchlibdir", config::local_arch_lib_dir () },
419 { "localfcnfiledir", config::local_fcn_file_dir () },
420 { "localoctfiledir", config::local_oct_file_dir () },
421 { "localstartupfiledir", config::local_startupfile_dir () },
422 { "localverarchlibdir", config::local_ver_arch_lib_dir () },
423 { "localverfcnfiledir", config::local_ver_fcn_file_dir () },
424 { "localveroctfiledir", config::local_ver_oct_file_dir () },
425 { "major_version", STRINGIFY (OCTAVE_MAJOR_VERSION) },
426 { "man1dir", config::man1_dir () },
427 { "man1ext", config::man1_ext () },
428 { "mandir", config::man_dir () },
429 { "minor_version", STRINGIFY (OCTAVE_MINOR_VERSION) },
430 { "octdatadir", config::oct_data_dir () },
431 { "octdocdir", config::oct_doc_dir () },
432 { "octetcdir", config::oct_etc_dir () },
433 { "octfiledir", config::oct_file_dir () },
434 { "octfontsdir", config::oct_fonts_dir () },
435 { "octincludedir", config::oct_include_dir () },
436 { "octlibdir", config::oct_lib_dir () },
437 { "octtestsdir", config::oct_tests_dir () },
438 { "patch_version", STRINGIFY (OCTAVE_PATCH_VERSION) },
439 { "release_date", OCTAVE_RELEASE_DATE },
440 { "startupfiledir", config::startupfile_dir () },
441 { "version", OCTAVE_VERSION }};
442
443 std::map<std::string, octave_value> build_env_map
444 = {{ "AMD_CPPFLAGS", build_env::AMD_CPPFLAGS },
445 { "AMD_LDFLAGS", build_env::AMD_LDFLAGS },
446 { "AMD_LIBS", build_env::AMD_LIBS },
447 { "AR", build_env::AR },
448 { "ARFLAGS", build_env::ARFLAGS },
449 { "ARPACK_CPPFLAGS", build_env::ARPACK_CPPFLAGS },
450 { "ARPACK_LDFLAGS", build_env::ARPACK_LDFLAGS },
451 { "ARPACK_LIBS", build_env::ARPACK_LIBS },
452 { "BLAS_LIBS", build_env::BLAS_LIBS },
453 { "CAMD_CPPFLAGS", build_env::CAMD_CPPFLAGS },
454 { "CAMD_LDFLAGS", build_env::CAMD_LDFLAGS },
455 { "CAMD_LIBS", build_env::CAMD_LIBS },
456 { "CARBON_LIBS", build_env::CARBON_LIBS },
457 { "CC", build_env::CC },
458 { "CCOLAMD_CPPFLAGS", build_env::CCOLAMD_CPPFLAGS },
459 { "CCOLAMD_LDFLAGS", build_env::CCOLAMD_LDFLAGS },
460 { "CCOLAMD_LIBS", build_env::CCOLAMD_LIBS },
461 { "CFLAGS", build_env::CFLAGS },
462 { "CHOLMOD_CPPFLAGS", build_env::CHOLMOD_CPPFLAGS },
463 { "CHOLMOD_LDFLAGS", build_env::CHOLMOD_LDFLAGS },
464 { "CHOLMOD_LIBS", build_env::CHOLMOD_LIBS },
465 { "COLAMD_CPPFLAGS", build_env::COLAMD_CPPFLAGS },
466 { "COLAMD_LDFLAGS", build_env::COLAMD_LDFLAGS },
467 { "COLAMD_LIBS", build_env::COLAMD_LIBS },
468 { "CPICFLAG", build_env::CPICFLAG },
469 { "CPPFLAGS", build_env::CPPFLAGS },
470 { "CURL_CPPFLAGS", build_env::CURL_CPPFLAGS },
471 { "CURL_LDFLAGS", build_env::CURL_LDFLAGS },
472 { "CURL_LIBS", build_env::CURL_LIBS },
473 { "CXSPARSE_CPPFLAGS", build_env::CXSPARSE_CPPFLAGS },
474 { "CXSPARSE_LDFLAGS", build_env::CXSPARSE_LDFLAGS },
475 { "CXSPARSE_LIBS", build_env::CXSPARSE_LIBS },
476 { "CXX", build_env::CXX },
477 { "CXXCPP", build_env::CXXCPP },
478 { "CXXFLAGS", build_env::CXXFLAGS },
479 { "CXXPICFLAG", build_env::CXXPICFLAG },
480 { "DEFS", build_env::DEFS },
481 { "DL_LDFLAGS", build_env::DL_LDFLAGS },
482 { "GCC_VERSION", build_env::GCC_VERSION },
483 { "GXX_VERSION", build_env::GXX_VERSION },
484 { "EXEEXT", build_env::EXEEXT },
485 { "F77", build_env::F77 },
486 { "F77_FLOAT_STORE_FLAG", build_env::F77_FLOAT_STORE_FLAG },
487 { "F77_INTEGER_8_FLAG", build_env::F77_INTEGER_8_FLAG },
488 { "FFLAGS", build_env::FFLAGS },
489 { "FFTW3_CPPFLAGS", build_env::FFTW3_CPPFLAGS },
490 { "FFTW3_LDFLAGS", build_env::FFTW3_LDFLAGS },
491 { "FFTW3_LIBS", build_env::FFTW3_LIBS },
492 { "FFTW3F_CPPFLAGS", build_env::FFTW3F_CPPFLAGS },
493 { "FFTW3F_LDFLAGS", build_env::FFTW3F_LDFLAGS },
494 { "FFTW3F_LIBS", build_env::FFTW3F_LIBS },
495 { "FLIBS", build_env::FLIBS },
496 { "FLTK_CPPFLAGS", build_env::FLTK_CPPFLAGS },
497 { "FLTK_LDFLAGS", build_env::FLTK_LDFLAGS },
498 { "FLTK_LIBS", build_env::FLTK_LIBS },
499 { "FONTCONFIG_CPPFLAGS", build_env::FONTCONFIG_CPPFLAGS },
500 { "FONTCONFIG_LIBS", build_env::FONTCONFIG_LIBS },
501 { "FPICFLAG", build_env::FPICFLAG },
502 { "FT2_CPPFLAGS", build_env::FT2_CPPFLAGS },
503 { "FT2_LIBS", build_env::FT2_LIBS },
504 { "GLPK_CPPFLAGS", build_env::GLPK_CPPFLAGS },
505 { "GLPK_LDFLAGS", build_env::GLPK_LDFLAGS },
506 { "GLPK_LIBS", build_env::GLPK_LIBS },
507 { "GNUPLOT", build_env::GNUPLOT },
508 { "HDF5_CPPFLAGS", build_env::HDF5_CPPFLAGS },
509 { "HDF5_LDFLAGS", build_env::HDF5_LDFLAGS },
510 { "HDF5_LIBS", build_env::HDF5_LIBS },
511 { "LAPACK_LIBS", build_env::LAPACK_LIBS },
512 { "LDFLAGS", build_env::LDFLAGS },
513 { "LD_STATIC_FLAG", build_env::LD_STATIC_FLAG },
514 { "LEX", build_env::LEX },
515 { "LEXLIB", build_env::LEXLIB },
516 { "LFLAGS", build_env::LFLAGS },
517 { "LIBOCTAVE", build_env::LIBOCTAVE },
518 { "LIBOCTINTERP", build_env::LIBOCTINTERP },
519 { "LIBS", build_env::LIBS },
520 { "LN_S", build_env::LN_S },
521 { "MAGICK_CPPFLAGS", build_env::MAGICK_CPPFLAGS },
522 { "MAGICK_LDFLAGS", build_env::MAGICK_LDFLAGS },
523 { "MAGICK_LIBS", build_env::MAGICK_LIBS },
524 { "MKOCTFILE_DL_LDFLAGS", build_env::MKOCTFILE_DL_LDFLAGS },
525 { "OCTAVE_LINK_DEPS", build_env::OCTAVE_LINK_DEPS },
526 { "OCTAVE_LINK_OPTS", build_env::OCTAVE_LINK_OPTS },
527 { "OCT_LINK_DEPS", build_env::OCT_LINK_DEPS },
528 { "OCT_LINK_OPTS", build_env::OCT_LINK_OPTS },
529 { "OPENGL_LIBS", build_env::OPENGL_LIBS },
530 { "PCRE_CPPFLAGS", build_env::PCRE_CPPFLAGS },
531 { "PCRE_LDFLAGS", build_env::PCRE_LDFLAGS },
532 { "PCRE_LIBS", build_env::PCRE_LIBS },
533 { "PTHREAD_CFLAGS", build_env::PTHREAD_CFLAGS },
534 { "PTHREAD_LIBS", build_env::PTHREAD_LIBS },
535 { "QHULL_CPPFLAGS", build_env::QHULL_CPPFLAGS },
536 { "QHULL_LDFLAGS", build_env::QHULL_LDFLAGS },
537 { "QHULL_LIBS", build_env::QHULL_LIBS },
538 { "QRUPDATE_CPPFLAGS", build_env::QRUPDATE_CPPFLAGS },
539 { "QRUPDATE_LDFLAGS", build_env::QRUPDATE_LDFLAGS },
540 { "QRUPDATE_LIBS", build_env::QRUPDATE_LIBS },
541 { "QT_CPPFLAGS", build_env::QT_CPPFLAGS },
542 { "QT_LDFLAGS", build_env::QT_LDFLAGS },
543 { "QT_LIBS", build_env::QT_LIBS },
544 { "QT_OPENGL_LIBS", build_env::QT_OPENGL_LIBS },
545 { "RANLIB", build_env::RANLIB },
546 { "RDYNAMIC_FLAG", build_env::RDYNAMIC_FLAG },
547 { "READLINE_LIBS", build_env::READLINE_LIBS },
548 { "SHARED_LIBS", build_env::SHARED_LIBS },
549 { "SH_LDFLAGS", build_env::SH_LDFLAGS },
550 { "STATIC_LIBS", build_env::STATIC_LIBS },
551 { "SUITESPARSECONFIG_LIBS", build_env::SUITESPARSECONFIG_LIBS },
552 { "TERM_LIBS", build_env::TERM_LIBS },
553 { "UMFPACK_CPPFLAGS", build_env::UMFPACK_CPPFLAGS },
554 { "UMFPACK_LDFLAGS", build_env::UMFPACK_LDFLAGS },
555 { "UMFPACK_LIBS", build_env::UMFPACK_LIBS },
556 { "WARN_CFLAGS", build_env::WARN_CFLAGS },
557 { "WARN_CXXFLAGS", build_env::WARN_CXXFLAGS },
558 { "X11_INCFLAGS", build_env::X11_INCFLAGS },
559 { "X11_LIBS", build_env::X11_LIBS },
560 { "XTRA_CFLAGS", build_env::XTRA_CFLAGS },
561 { "XTRA_CXXFLAGS", build_env::XTRA_CXXFLAGS },
562 { "YACC", build_env::YACC },
563 { "YFLAGS", build_env::YFLAGS },
564 { "Z_CPPFLAGS", build_env::Z_CPPFLAGS },
565 { "Z_LDFLAGS", build_env::Z_LDFLAGS },
566 { "Z_LIBS", build_env::Z_LIBS },
567 { "config_opts", build_env::config_opts }};
568
569 config = octave_scalar_map (conf_info_map);
570 build_env = octave_scalar_map (build_env_map);
571 build_features = build_env::features ();
572
573 bool unix_system = true;
574 bool mac_system = false;
575 bool windows_system = false;
576
577#if defined (__WIN32__)
578 windows_system = true;
579#if ! defined (__CYGWIN__)
580 unix_system = false;
581#endif
582#endif
583
584#if defined (OCTAVE_USE_OS_X_API)
585 mac_system = true;
586#endif
587
588 config.assign ("unix", octave_value (unix_system));
589 config.assign ("mac", octave_value (mac_system));
590 config.assign ("windows", octave_value (windows_system));
591
593 config.assign ("float_format",
595
596 config.assign ("words_big_endian",
598
599 config.assign ("words_little_endian",
601
602 config.assign ("build_environment", octave_value (build_env));
603
604 config.assign ("build_features", octave_value (build_features));
605
606 initialized = true;
607 }
608
609 int nargin = args.length ();
610
611 if (nargin > 1)
612 print_usage ();
613
614 octave_value_list retval;
615
616 if (nargin == 1)
617 {
618 std::string arg = args(0).xstring_value ("__octave_config_info__: OPTION argument must be a string");
619
621
622 if (info.is_undefined ())
623 info = find_config_info (build_env, arg);
624
625 if (info.is_undefined ())
626 info = find_config_info (build_features, arg);
627
628 if (info.is_undefined ())
629 error ("__octave_config_info__: no info for '%s'", arg.c_str ());
630
631 return info;
632 }
633 else
634 retval = ovl (config);
635
636 return retval;
637}
638
639/*
640%!assert (ischar (__octave_config_info__ ("version")))
641%!assert (__octave_config_info__ ("version"), OCTAVE_VERSION ())
642%!test
643%! x = __octave_config_info__ ();
644%! assert (isstruct (x));
645%! assert (! isempty (x));
646%! assert (x.version, OCTAVE_VERSION ());
647
648%!error __octave_config_info__ (1, 2)
649*/
650
651OCTAVE_NAMESPACE_END
652
653#if defined (__GNUG__) && defined (DEBUG_NEW_DELETE)
654
655int debug_new_delete = 0;
656
657typedef void (*vfp)(void);
658extern vfp __new_handler;
659
660void *
661__builtin_new (std::size_t sz)
662{
663 void *p;
664
665 // malloc (0) is unpredictable; avoid it.
666 if (sz == 0)
667 sz = 1;
668 p = std::malloc (sz);
669 while (p == 0)
670 {
671 (*__new_handler) ();
672 p = std::malloc (sz);
673 }
674
675 if (debug_new_delete)
676 std::cerr << "__builtin_new: " << p << std::endl;
677
678 return p;
679}
680
681void
682__builtin_delete (void *ptr)
683{
684 if (debug_new_delete)
685 std::cerr << "__builtin_delete: " << ptr << std::endl;
686
687 free (ptr);
688}
689
690#endif
pid_t octave_async_system_wrapper(const char *cmd)
bool isempty(void) const
Size of the specified dimension.
Definition: Array.h:607
Definition: Cell.h:43
const octave_value & contents(const_iterator p) const
Definition: oct-map.h:205
bool isfield(const std::string &name) const
Definition: oct-map.h:221
bool is_undefined(void) const
Definition: ov.h:640
int file_number(void) const
Definition: procstream.h:67
int close(void)
Definition: procstream.cc:62
pid_t pid(void) const
Definition: procstream.h:65
OCTINTERP_API void print_usage(void)
Definition: defun-int.h:72
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
Definition: defun.h:56
void error(const char *fmt,...)
Definition: error.cc:980
OCTINTERP_API std::string liboctinterp_hg_id(void)
#define OCTAVE_VERSION
Definition: main.in.cc:63
std::string local_arch_lib_dir(void)
Definition: defaults.cc:251
std::string man_dir(void)
Definition: defaults.cc:387
std::string oct_doc_dir(void)
Definition: defaults.cc:331
std::string lib_dir(void)
Definition: defaults.cc:203
std::string include_dir(void)
Definition: defaults.cc:195
std::string arch_lib_dir(void)
Definition: defaults.cc:219
std::string data_dir(void)
Definition: defaults.cc:179
std::string oct_data_dir(void)
Definition: defaults.cc:323
std::string local_oct_file_dir(void)
Definition: defaults.cc:275
std::string local_api_fcn_file_dir(void)
Definition: defaults.cc:299
std::string oct_tests_dir(void)
Definition: defaults.cc:379
std::string startupfile_dir(void)
Definition: defaults.cc:426
std::string local_api_oct_file_dir(void)
Definition: defaults.cc:267
std::string local_ver_arch_lib_dir(void)
Definition: defaults.cc:235
std::string fcn_file_dir(void)
Definition: defaults.cc:315
std::string local_startupfile_dir(void)
Definition: defaults.cc:418
std::string oct_etc_dir(void)
Definition: defaults.cc:339
std::string canonical_host_type(void)
Definition: defaults.cc:135
std::string info_dir(void)
Definition: defaults.cc:227
std::string image_dir(void)
Definition: defaults.cc:410
std::string local_ver_fcn_file_dir(void)
Definition: defaults.cc:291
std::string oct_fonts_dir(void)
Definition: defaults.cc:347
std::string local_fcn_file_dir(void)
Definition: defaults.cc:307
std::string bin_dir(void)
Definition: defaults.cc:171
std::string oct_file_dir(void)
Definition: defaults.cc:283
std::string local_api_arch_lib_dir(void)
Definition: defaults.cc:243
std::string local_ver_oct_file_dir(void)
Definition: defaults.cc:259
std::string dataroot_dir(void)
Definition: defaults.cc:187
std::string libexec_dir(void)
Definition: defaults.cc:211
std::string default_pager(void)
Definition: defaults.cc:150
std::string oct_lib_dir(void)
Definition: defaults.cc:363
std::string oct_include_dir(void)
Definition: defaults.cc:355
std::string man1_dir(void)
Definition: defaults.cc:395
std::string man1_ext(void)
Definition: defaults.cc:403
OCTINTERP_API const char * CCOLAMD_LIBS
Definition: build-env.in.cc:70
OCTINTERP_API const char * UMFPACK_LIBS
OCTINTERP_API const char * CHOLMOD_CPPFLAGS
Definition: build-env.in.cc:74
OCTINTERP_API const char * TERM_LIBS
OCTINTERP_API const char * PCRE_LDFLAGS
OCTINTERP_API const char * CPPFLAGS
Definition: build-env.in.cc:88
OCTINTERP_API const char * PTHREAD_CFLAGS
OCTINTERP_API const char * AR
Definition: build-env.in.cc:46
OCTINTERP_API const char * CXX
OCTINTERP_API const char * PTHREAD_LIBS
OCTINTERP_API const char * CCOLAMD_LDFLAGS
Definition: build-env.in.cc:68
OCTINTERP_API const char * HDF5_CPPFLAGS
OCTINTERP_API const char * CAMD_LIBS
Definition: build-env.in.cc:60
OCTINTERP_API const char * F77_FLOAT_STORE_FLAG
OCTINTERP_API const char * HDF5_LIBS
OCTINTERP_API const char * CXSPARSE_LIBS
OCTINTERP_API const char * CARBON_LIBS
Definition: build-env.in.cc:62
OCTINTERP_API const char * YACC
OCTINTERP_API const char * CURL_LDFLAGS
Definition: build-env.in.cc:92
OCTINTERP_API const char * DEFS
OCTINTERP_API const char * SUITESPARSECONFIG_LIBS
OCTINTERP_API const char * CXXCPP
OCTINTERP_API const char * LIBOCTAVE
OCTINTERP_API const char * FONTCONFIG_CPPFLAGS
OCTINTERP_API const char * COLAMD_CPPFLAGS
Definition: build-env.in.cc:80
OCTINTERP_API const char * FLTK_LIBS
OCTINTERP_API const char * FFTW3_LDFLAGS
OCTINTERP_API const char * FFTW3F_LIBS
OCTINTERP_API const char * READLINE_LIBS
OCTINTERP_API const char * LFLAGS
OCTINTERP_API const char * CHOLMOD_LIBS
Definition: build-env.in.cc:78
OCTINTERP_API const char * OCTAVE_LINK_DEPS
OCTINTERP_API const char * QT_OPENGL_LIBS
OCTINTERP_API const char * FFTW3_LIBS
OCTINTERP_API const char * GLPK_LIBS
OCTINTERP_API const char * CHOLMOD_LDFLAGS
Definition: build-env.in.cc:76
OCTINTERP_API const char * LAPACK_LIBS
OCTINTERP_API const char * LIBS
OCTINTERP_API const char * COLAMD_LIBS
Definition: build-env.in.cc:84
OCTINTERP_API const char * CFLAGS
Definition: build-env.in.cc:72
OCTINTERP_API const char * QRUPDATE_LDFLAGS
OCTINTERP_API const char * GCC_VERSION
OCTINTERP_API const char * FFTW3F_LDFLAGS
OCTINTERP_API const char * FT2_CPPFLAGS
OCTINTERP_API const char * STATIC_LIBS
OCTINTERP_API const char * EXEEXT
OCTINTERP_API const char * CXSPARSE_LDFLAGS
Definition: build-env.in.cc:98
OCTINTERP_API const char * QHULL_CPPFLAGS
OCTINTERP_API const char * QT_LIBS
OCTINTERP_API const char * OCTAVE_LINK_OPTS
OCTINTERP_API const char * FPICFLAG
OCTINTERP_API const char * XTRA_CFLAGS
OCTINTERP_API const char * AMD_LDFLAGS
Definition: build-env.in.cc:40
OCTINTERP_API const char * DL_LDFLAGS
OCTINTERP_API const char * ARPACK_LDFLAGS
Definition: build-env.in.cc:50
OCTINTERP_API const char * FLTK_CPPFLAGS
OCTINTERP_API const char * LEX
OCTINTERP_API const char * WARN_CXXFLAGS
OCTINTERP_API const char * UMFPACK_CPPFLAGS
OCTINTERP_API const char * MAGICK_LIBS
OCTINTERP_API const char * LN_S
OCTINTERP_API const char * XTRA_CXXFLAGS
OCTINTERP_API const char * GNUPLOT
OCTINTERP_API const char * QRUPDATE_LIBS
OCTINTERP_API const char * ARPACK_CPPFLAGS
Definition: build-env.in.cc:48
OCTINTERP_API const char * AMD_CPPFLAGS
Definition: build-env.in.cc:38
OCTINTERP_API const char * FLIBS
OCTINTERP_API const char * RDYNAMIC_FLAG
OCTINTERP_API const char * ARFLAGS
Definition: build-env.in.cc:44
OCTINTERP_API const char * X11_INCFLAGS
OCTINTERP_API const char * WARN_CFLAGS
OCTINTERP_API const char * QHULL_LDFLAGS
OCTINTERP_API const char * F77
OCTINTERP_API const char * MKOCTFILE_DL_LDFLAGS
OCTINTERP_API const char * CC
Definition: build-env.in.cc:64
OCTINTERP_API const char * LD_STATIC_FLAG
OCTINTERP_API const char * SHARED_LIBS
OCTINTERP_API const char * FONTCONFIG_LIBS
OCTINTERP_API const char * YFLAGS
OCTINTERP_API const char * MAGICK_CPPFLAGS
OCTINTERP_API const char * PCRE_CPPFLAGS
OCTINTERP_API const char * LIBOCTINTERP
OCTINTERP_API const char * BLAS_LIBS
Definition: build-env.in.cc:54
OCTINTERP_API const char * Z_LDFLAGS
OCTINTERP_API octave_scalar_map features(void)
OCTINTERP_API const char * CXSPARSE_CPPFLAGS
Definition: build-env.in.cc:96
OCTINTERP_API const char * PCRE_LIBS
OCTINTERP_API const char * QHULL_LIBS
OCTINTERP_API const char * CCOLAMD_CPPFLAGS
Definition: build-env.in.cc:66
OCTINTERP_API const char * OCT_LINK_DEPS
OCTINTERP_API const char * FT2_LIBS
OCTINTERP_API const char * CURL_LIBS
Definition: build-env.in.cc:94
OCTINTERP_API const char * ARPACK_LIBS
Definition: build-env.in.cc:52
OCTINTERP_API const char * OCT_LINK_OPTS
OCTINTERP_API const char * QT_CPPFLAGS
OCTINTERP_API const char * Z_LIBS
OCTINTERP_API const char * SH_LDFLAGS
OCTINTERP_API const char * CAMD_LDFLAGS
Definition: build-env.in.cc:58
OCTINTERP_API const char * OPENGL_LIBS
OCTINTERP_API const char * AMD_LIBS
Definition: build-env.in.cc:42
OCTINTERP_API const char * CXXFLAGS
OCTINTERP_API const char * FFTW3_CPPFLAGS
OCTINTERP_API const char * Z_CPPFLAGS
OCTINTERP_API const char * MAGICK_LDFLAGS
OCTINTERP_API const char * config_opts
OCTINTERP_API const char * GXX_VERSION
OCTINTERP_API const char * GLPK_CPPFLAGS
OCTINTERP_API const char * QRUPDATE_CPPFLAGS
OCTINTERP_API const char * FFTW3F_CPPFLAGS
OCTINTERP_API const char * CURL_CPPFLAGS
Definition: build-env.in.cc:90
OCTINTERP_API const char * LEXLIB
OCTINTERP_API const char * X11_LIBS
OCTINTERP_API const char * RANLIB
OCTINTERP_API const char * GLPK_LDFLAGS
OCTINTERP_API const char * FFLAGS
OCTINTERP_API const char * FLTK_LDFLAGS
OCTINTERP_API const char * UMFPACK_LDFLAGS
OCTINTERP_API const char * CPICFLAG
Definition: build-env.in.cc:86
OCTINTERP_API const char * HDF5_LDFLAGS
OCTINTERP_API const char * F77_INTEGER_8_FLAG
OCTINTERP_API const char * LDFLAGS
OCTINTERP_API const char * COLAMD_LDFLAGS
Definition: build-env.in.cc:82
OCTINTERP_API const char * CXXPICFLAG
OCTINTERP_API const char * QT_LDFLAGS
OCTINTERP_API const char * CAMD_CPPFLAGS
Definition: build-env.in.cc:56
float_format native_float_format(void)
Definition: mach-info.cc:65
bool words_big_endian(void)
Definition: mach-info.cc:72
bool words_little_endian(void)
Definition: mach-info.cc:79
std::string float_format_as_string(float_format flt_fmt)
Definition: mach-info.cc:105
int wexitstatus(int status)
bool wifexited(int status)
int system(const std::string &cmd_str)
Definition: lo-sysdep.cc:59
child_list & __get_child_list__(const std::string &who)
std::string fftw_version(void)
Definition: oct-fftw.cc:1133
std::string fftwf_version(void)
Definition: oct-fftw.cc:1143
void * malloc(unsigned)
void free(void *)
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.
Definition: ovl.h:211
#define octave_stdout
Definition: pager.h:314
void octave_unblock_signal_by_name(const char *signame)
void octave_set_signal_mask(void *mask)
void octave_free_signal_mask(void *mask)
void octave_get_signal_mask(void *mask)
void octave_unblock_async_signals(void)
void * octave_alloc_signal_mask(void)
static octave_value_list run_command_and_return_output(const std::string &cmd_str)
Definition: toplev.cc:109
#define STRINGIFY(s)
Definition: toplev.cc:77
system_exec_type
Definition: toplev.cc:182
@ et_sync
Definition: toplev.cc:182
@ et_async
Definition: toplev.cc:182
static void restore_signal_mask(void *mask)
Definition: toplev.cc:175
static void * get_signal_mask(void)
Definition: toplev.cc:163
static octave_value find_config_info(const octave_scalar_map &m, const std::string &key)
Definition: toplev.cc:330
std::string octave_name_version_and_copyright(void)
Definition: version.cc:71
int octave_wait_for_input(int fid)