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