Mercurial > octave
view libinterp/corefcn/toplev.cc @ 31605:e88a07dec498 stable
maint: Use macros to begin/end C++ namespaces.
* oct-conf-post-public.in.h: Define two macros (OCTAVE_BEGIN_NAMESPACE,
OCTAVE_END_NAMESPACE) that can be used to start/end a namespace.
* mk-opts.pl, build-env.h, build-env.in.cc, __betainc__.cc, __contourc__.cc,
__dsearchn__.cc, __eigs__.cc, __expint__.cc, __ftp__.cc, __gammainc__.cc,
__ichol__.cc, __ilu__.cc, __isprimelarge__.cc, __lin_interpn__.cc,
__magick_read__.cc, __pchip_deriv__.cc, __qp__.cc, amd.cc, auto-shlib.cc,
auto-shlib.h, balance.cc, base-text-renderer.cc, base-text-renderer.h,
besselj.cc, bitfcns.cc, bsxfun.cc, c-file-ptr-stream.cc, c-file-ptr-stream.h,
call-stack.cc, call-stack.h, ccolamd.cc, cellfun.cc, chol.cc, colamd.cc,
colloc.cc, conv2.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc, data.h, debug.cc,
defaults.cc, defaults.h, defun-int.h, defun.cc, det.cc, dirfns.cc, display.cc,
display.h, dlmread.cc, dmperm.cc, dot.cc, dynamic-ld.cc, dynamic-ld.h, eig.cc,
ellipj.cc, environment.cc, environment.h, error.cc, error.h, errwarn.h,
event-manager.cc, event-manager.h, event-queue.cc, event-queue.h, fcn-info.cc,
fcn-info.h, fft.cc, fft2.cc, fftn.cc, file-io.cc, filter.cc, find.cc,
ft-text-renderer.cc, ft-text-renderer.h, gcd.cc, getgrent.cc, getpwent.cc,
getrusage.cc, givens.cc, gl-render.cc, gl-render.h, gl2ps-print.cc,
gl2ps-print.h, graphics-toolkit.cc, graphics-toolkit.h, graphics.cc,
graphics.in.h, gsvd.cc, gtk-manager.cc, gtk-manager.h, hash.cc, help.cc,
help.h, hess.cc, hex2num.cc, hook-fcn.cc, hook-fcn.h, input.cc, input.h,
interpreter-private.cc, interpreter-private.h, interpreter.cc, interpreter.h,
inv.cc, jsondecode.cc, jsonencode.cc, kron.cc, latex-text-renderer.cc,
latex-text-renderer.h, load-path.cc, load-path.h, load-save.cc, load-save.h,
lookup.cc, ls-ascii-helper.cc, ls-ascii-helper.h, ls-oct-text.cc, ls-utils.cc,
ls-utils.h, lsode.cc, lu.cc, mappers.cc, matrix_type.cc, max.cc, mex-private.h,
mex.cc, mgorth.cc, nproc.cc, oct-fstrm.cc, oct-fstrm.h, oct-hdf5-types.cc,
oct-hdf5-types.h, oct-hist.cc, oct-hist.h, oct-iostrm.cc, oct-iostrm.h,
oct-opengl.h, oct-prcstrm.cc, oct-prcstrm.h, oct-procbuf.cc, oct-procbuf.h,
oct-process.cc, oct-process.h, oct-stdstrm.h, oct-stream.cc, oct-stream.h,
oct-strstrm.cc, oct-strstrm.h, oct-tex-lexer.in.ll, oct-tex-parser.yy,
ordqz.cc, ordschur.cc, pager.cc, pager.h, pinv.cc, pow2.cc, pr-flt-fmt.cc,
pr-output.cc, procstream.cc, procstream.h, psi.cc, qr.cc, quad.cc, quadcc.cc,
qz.cc, rand.cc, rcond.cc, regexp.cc, schur.cc, settings.cc, settings.h,
sighandlers.cc, sighandlers.h, sparse-xdiv.cc, sparse-xdiv.h, sparse-xpow.cc,
sparse-xpow.h, sparse.cc, spparms.cc, sqrtm.cc, stack-frame.cc, stack-frame.h,
stream-euler.cc, strfind.cc, strfns.cc, sub2ind.cc, svd.cc, sylvester.cc,
symbfact.cc, syminfo.cc, syminfo.h, symrcm.cc, symrec.cc, symrec.h,
symscope.cc, symscope.h, symtab.cc, symtab.h, syscalls.cc, sysdep.cc, sysdep.h,
text-engine.cc, text-engine.h, text-renderer.cc, text-renderer.h, time.cc,
toplev.cc, tril.cc, tsearch.cc, typecast.cc, url-handle-manager.cc,
url-handle-manager.h, urlwrite.cc, utils.cc, utils.h, variables.cc,
variables.h, xdiv.cc, xdiv.h, xnorm.cc, xnorm.h, xpow.cc, xpow.h,
__delaunayn__.cc, __fltk_uigetfile__.cc, __glpk__.cc, __init_fltk__.cc,
__init_gnuplot__.cc, __ode15__.cc, __voronoi__.cc, audiodevinfo.cc,
audioread.cc, convhulln.cc, fftw.cc, gzip.cc, mk-build-env-features.sh,
mk-builtins.pl, cdef-class.cc, cdef-class.h, cdef-fwd.h, cdef-manager.cc,
cdef-manager.h, cdef-method.cc, cdef-method.h, cdef-object.cc, cdef-object.h,
cdef-package.cc, cdef-package.h, cdef-property.cc, cdef-property.h,
cdef-utils.cc, cdef-utils.h, ov-base.cc, ov-base.h, ov-bool-mat.cc,
ov-builtin.h, ov-cell.cc, ov-class.cc, ov-class.h, ov-classdef.cc,
ov-classdef.h, ov-complex.cc, ov-fcn-handle.cc, ov-fcn-handle.h, ov-fcn.h,
ov-java.cc, ov-java.h, ov-mex-fcn.h, ov-null-mat.cc, ov-oncleanup.cc,
ov-struct.cc, ov-typeinfo.cc, ov-typeinfo.h, ov-usr-fcn.cc, ov-usr-fcn.h,
ov.cc, ov.h, octave.cc, octave.h, mk-ops.sh, op-b-b.cc, op-b-bm.cc,
op-b-sbm.cc, op-bm-b.cc, op-bm-bm.cc, op-bm-sbm.cc, op-cdm-cdm.cc, op-cell.cc,
op-chm.cc, op-class.cc, op-cm-cm.cc, op-cm-cs.cc, op-cm-m.cc, op-cm-s.cc,
op-cm-scm.cc, op-cm-sm.cc, op-cs-cm.cc, op-cs-cs.cc, op-cs-m.cc, op-cs-s.cc,
op-cs-scm.cc, op-cs-sm.cc, op-dm-dm.cc, op-dm-scm.cc, op-dm-sm.cc,
op-dm-template.cc, op-dms-template.cc, op-fcdm-fcdm.cc, op-fcm-fcm.cc,
op-fcm-fcs.cc, op-fcm-fm.cc, op-fcm-fs.cc, op-fcn.cc, op-fcs-fcm.cc,
op-fcs-fcs.cc, op-fcs-fm.cc, op-fcs-fs.cc, op-fdm-fdm.cc, op-fm-fcm.cc,
op-fm-fcs.cc, op-fm-fm.cc, op-fm-fs.cc, op-fs-fcm.cc, op-fs-fcs.cc,
op-fs-fm.cc, op-fs-fs.cc, op-i16-i16.cc, op-i32-i32.cc, op-i64-i64.cc,
op-i8-i8.cc, op-int-concat.cc, op-m-cm.cc, op-m-cs.cc, op-m-m.cc, op-m-s.cc,
op-m-scm.cc, op-m-sm.cc, op-mi.cc, op-pm-pm.cc, op-pm-scm.cc, op-pm-sm.cc,
op-pm-template.cc, op-range.cc, op-s-cm.cc, op-s-cs.cc, op-s-m.cc, op-s-s.cc,
op-s-scm.cc, op-s-sm.cc, op-sbm-b.cc, op-sbm-bm.cc, op-sbm-sbm.cc,
op-scm-cm.cc, op-scm-cs.cc, op-scm-m.cc, op-scm-s.cc, op-scm-scm.cc,
op-scm-sm.cc, op-sm-cm.cc, op-sm-cs.cc, op-sm-m.cc, op-sm-s.cc, op-sm-scm.cc,
op-sm-sm.cc, op-str-m.cc, op-str-s.cc, op-str-str.cc, op-struct.cc,
op-ui16-ui16.cc, op-ui32-ui32.cc, op-ui64-ui64.cc, op-ui8-ui8.cc, ops.h,
anon-fcn-validator.cc, anon-fcn-validator.h, bp-table.cc, bp-table.h,
comment-list.cc, comment-list.h, filepos.h, lex.h, lex.ll, oct-lvalue.cc,
oct-lvalue.h, oct-parse.yy, parse.h, profiler.cc, profiler.h,
pt-anon-scopes.cc, pt-anon-scopes.h, pt-arg-list.cc, pt-arg-list.h,
pt-args-block.cc, pt-args-block.h, pt-array-list.cc, pt-array-list.h,
pt-assign.cc, pt-assign.h, pt-binop.cc, pt-binop.h, pt-bp.cc, pt-bp.h,
pt-cbinop.cc, pt-cbinop.h, pt-cell.cc, pt-cell.h, pt-check.cc, pt-check.h,
pt-classdef.cc, pt-classdef.h, pt-cmd.h, pt-colon.cc, pt-colon.h, pt-const.cc,
pt-const.h, pt-decl.cc, pt-decl.h, pt-eval.cc, pt-eval.h, pt-except.cc,
pt-except.h, pt-exp.cc, pt-exp.h, pt-fcn-handle.cc, pt-fcn-handle.h, pt-id.cc,
pt-id.h, pt-idx.cc, pt-idx.h, pt-jump.h, pt-loop.cc, pt-loop.h, pt-mat.cc,
pt-mat.h, pt-misc.cc, pt-misc.h, pt-pr-code.cc, pt-pr-code.h, pt-select.cc,
pt-select.h, pt-spmd.cc, pt-spmd.h, pt-stmt.cc, pt-stmt.h, pt-tm-const.cc,
pt-tm-const.h, pt-unop.cc, pt-unop.h, pt-vm-eval.cc, pt-walk.cc, pt-walk.h,
pt.cc, pt.h, token.cc, token.h, Range.cc, Range.h, idx-vector.cc, idx-vector.h,
range-fwd.h, CollocWt.cc, CollocWt.h, aepbalance.cc, aepbalance.h, chol.cc,
chol.h, gepbalance.cc, gepbalance.h, gsvd.cc, gsvd.h, hess.cc, hess.h,
lo-mappers.cc, lo-mappers.h, lo-specfun.cc, lo-specfun.h, lu.cc, lu.h,
oct-convn.cc, oct-convn.h, oct-fftw.cc, oct-fftw.h, oct-norm.cc, oct-norm.h,
oct-rand.cc, oct-rand.h, oct-spparms.cc, oct-spparms.h, qr.cc, qr.h, qrp.cc,
qrp.h, randgamma.cc, randgamma.h, randmtzig.cc, randmtzig.h, randpoisson.cc,
randpoisson.h, schur.cc, schur.h, sparse-chol.cc, sparse-chol.h, sparse-lu.cc,
sparse-lu.h, sparse-qr.cc, sparse-qr.h, svd.cc, svd.h, child-list.cc,
child-list.h, dir-ops.cc, dir-ops.h, file-ops.cc, file-ops.h, file-stat.cc,
file-stat.h, lo-sysdep.cc, lo-sysdep.h, lo-sysinfo.cc, lo-sysinfo.h,
mach-info.cc, mach-info.h, oct-env.cc, oct-env.h, oct-group.cc, oct-group.h,
oct-password.cc, oct-password.h, oct-syscalls.cc, oct-syscalls.h, oct-time.cc,
oct-time.h, oct-uname.cc, oct-uname.h, action-container.cc, action-container.h,
base-list.h, cmd-edit.cc, cmd-edit.h, cmd-hist.cc, cmd-hist.h, f77-fcn.h,
file-info.cc, file-info.h, lo-array-errwarn.cc, lo-array-errwarn.h, lo-hash.cc,
lo-hash.h, lo-ieee.h, lo-regexp.cc, lo-regexp.h, lo-utils.cc, lo-utils.h,
oct-base64.cc, oct-base64.h, oct-glob.cc, oct-glob.h, oct-inttypes.h,
oct-mutex.cc, oct-mutex.h, oct-refcount.h, oct-shlib.cc, oct-shlib.h,
oct-sparse.cc, oct-sparse.h, oct-string.h, octave-preserve-stream-state.h,
pathsearch.cc, pathsearch.h, quit.cc, quit.h, unwind-prot.cc, unwind-prot.h,
url-transfer.cc, url-transfer.h : Use new macros to begin/end C++ namespaces.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 01 Dec 2022 14:23:45 -0800 |
parents | 00e2eafd1c0f |
children | aac27ad79be6 |
line wrap: on
line source
//////////////////////////////////////////////////////////////////////// // // Copyright (C) 1995-2022 The Octave Project Developers // // See the file COPYRIGHT.md in the top-level directory of this // distribution or <https://octave.org/copyright/>. // // This file is part of Octave. // // Octave is free software: you can redistribute it and/or modify it // under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Octave is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Octave; see the file COPYING. If not, see // <https://www.gnu.org/licenses/>. // //////////////////////////////////////////////////////////////////////// #if defined (HAVE_CONFIG_H) # include "config.h" #endif #include <cerrno> #include <cstdlib> #include <new> #include <sstream> #include <string> #if defined (OCTAVE_USE_WINDOWS_API) # define WIN32_LEAN_AND_MEAN 1 # include <windows.h> #endif #include "async-system-wrapper.h" #include "child-list.h" #include "lo-error.h" #include "oct-fftw.h" #include "oct-locbuf.h" #include "oct-syscalls.h" #include "signal-wrappers.h" #include "str-vec.h" #include "wait-for-input.h" #include "build-env.h" #include "liboctinterp-build-info.h" #include "defaults.h" #include "defun.h" #include "error.h" #include "help.h" #include "interpreter-private.h" #include "octave.h" #include "oct-map.h" #include "ovl.h" #include "ov.h" #include "pager.h" #include "procstream.h" #include "sysdep.h" #include "unwind-prot.h" #include "utils.h" #include "version.h" #if ! defined (SHELL_PATH) # define SHELL_PATH "/bin/sh" #endif OCTAVE_BEGIN_NAMESPACE(octave) #define STRINGIFY(s) STRINGIFY1(s) #define STRINGIFY1(s) #s DEFUN (warranty, , , doc: /* -*- texinfo -*- @deftypefn {} {} warranty () Describe the conditions for copying and distributing Octave. @end deftypefn */) { octave_stdout << "\n" << octave_name_version_and_copyright () << "\n\ \n\ GNU Octave is free software: you can redistribute it and/or modify it\n\ under the terms of the GNU General Public License as published by\n\ the Free Software Foundation, either version 3 of the License, or\n\ (at your option) any later version.\n\ \n\ GNU Octave is distributed in the hope that it will be useful, but\n\ WITHOUT ANY WARRANTY; without even the implied warranty of\n\ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\ GNU General Public License for more details.\n\ \n\ You should have received a copy of the GNU General Public License\n\ along with GNU Octave; see the file COPYING. If not, see\n\ <https://www.gnu.org/licenses/>.\n\ \n"; return ovl (); } // Execute a shell command. static octave_value_list run_command_and_return_output (const std::string& cmd_str) { octave_value_list retval; unwind_protect frame; iprocstream *cmd = new iprocstream (cmd_str.c_str ()); frame.add_delete (cmd); child_list& kids = __get_child_list__ (); frame.add (&child_list::remove, kids, cmd->pid ()); if (! *cmd) error ("system: unable to start subprocess for '%s'", cmd_str.c_str ()); int fid = cmd->file_number (); std::ostringstream output_buf; char ch; for (;;) { if (cmd->get (ch)) output_buf.put (ch); else { if (! cmd->eof () && errno == EAGAIN) { cmd->clear (); if (octave_wait_for_input (fid) != 1) break; } else break; } } int cmd_status = cmd->close (); if (sys::wifexited (cmd_status)) cmd_status = sys::wexitstatus (cmd_status); else cmd_status = 127; retval = ovl (cmd_status, output_buf.str ()); return retval; } // Combine alloc+get in one action. static void * get_signal_mask (void) { void *mask = octave_alloc_signal_mask (); octave_get_signal_mask (mask); return mask; } // Combine set+free in one action. static void restore_signal_mask (void *mask) { octave_set_signal_mask (mask); octave_free_signal_mask (mask); } enum system_exec_type { et_sync, et_async }; DEFUN (system, args, nargout, doc: /* -*- texinfo -*- @deftypefn {} {} system ("@var{string}") @deftypefnx {} {} system ("@var{string}", @var{return_output}) @deftypefnx {} {} system ("@var{string}", @var{return_output}, @var{type}) @deftypefnx {} {[@var{status}, @var{output}] =} system (@dots{}) Execute a shell command specified by @var{string}. If @var{system} is called with one or more output arguments, or if the optional argument @var{return_output} is true and the subprocess is started synchronously, then the output from the command is returned as a variable. Otherwise, if the subprocess is executed synchronously, its output is sent to the standard output. To send the output of a command executed with @code{system} through the pager, use a command like @example @group [~, text] = system ("cmd"); more on; disp (text); @end group @end example @noindent or @example @group more on; printf ("%s\n", nthargout (2, "system", "cmd")); @end group @end example If the optional argument @var{type} is @qcode{"async"}, the process is started in the background and the process ID of the child process is returned immediately. Otherwise, the child process is started and Octave waits until it exits. If the @var{type} argument is omitted, it defaults to the value @qcode{"sync"}. The @code{system} function can return two values. The first is the exit status of the command and the second is any output from the command that was written to the standard output stream. For example, @example [status, output] = system ("echo foo & exit 2"); @end example @noindent will set the variable @var{output} to the string @samp{foo}, and the variable @var{status} to the integer @samp{2}. For commands run asynchronously, @var{status} is the process id of the command shell that is started to run the command. The shell used for executing commands varies with operating system and is typically @file{/bin/sh} for UNIX systems and @nospell{@file{cmd.exe}} for Windows systems. @seealso{unix, dos} @end deftypefn */) { int nargin = args.length (); if (nargin == 0 || nargin > 3) print_usage (); system_exec_type type = et_sync; if (nargin == 3) { std::string type_str = args(2).xstring_value ("system: TYPE must be a string"); if (type_str == "sync") type = et_sync; else if (type_str == "async") type = et_async; else error (R"(system: TYPE must be "sync" or "async")"); } octave_value_list retval; bool return_output = (nargin == 1 && nargout > 1); if (nargin > 1) { try { return_output = args(1).is_true (); } catch (execution_exception& ee) { error (ee, "system: RETURN_OUTPUT must be boolean value true or false"); } } if (return_output && type == et_async) error ("system: can't return output from commands run asynchronously"); std::string cmd_str = args(0).xstring_value ("system: first argument must be a string"); #if defined (OCTAVE_USE_WINDOWS_API) // Work around weird double-quote handling on Windows systems. if (type == et_sync) cmd_str = '"' + cmd_str + '"'; #endif unwind_action restore_mask ([] (void *mask) { restore_signal_mask (mask); }, get_signal_mask ()); octave_unblock_async_signals (); octave_unblock_signal_by_name ("SIGTSTP"); if (type == et_async) retval(0) = octave_async_system_wrapper (cmd_str.c_str ()); else if (return_output) retval = run_command_and_return_output (cmd_str); else { int status = sys::system (cmd_str); // The value in status is as returned by waitpid. If // the process exited normally, extract the actual exit // status of the command. Otherwise, return 127 as a // failure code. if (sys::wifexited (status)) status = sys::wexitstatus (status); retval(0) = status; } return retval; } /* %!test %! cmd = ls_command (); %! [status, output] = system (cmd); %! assert (status, 0); %! assert (ischar (output)); %! assert (! isempty (output)); %!error system () %!error system (1, 2, 3) */ static octave_value find_config_info (const octave_scalar_map& m, const std::string& key) { if (m.isfield (key)) { Cell c = m.contents (key); if (! c.isempty ()) return c(0); } return octave_value (); } DEFUN (__octave_config_info__, args, , doc: /* -*- texinfo -*- @deftypefn {} {@var{S} =} __octave_config_info__ () @deftypefnx {} {@var{S} =} __octave_config_info__ (@var{option}) Return a structure containing configuration and installation information for Octave. If @var{option} is a string, return the configuration information for the specified option. @seealso{computer} @end deftypefn */) { static octave_scalar_map config; static octave_scalar_map build_env; static octave_scalar_map build_features; static bool initialized = false; if (! initialized) { std::map<std::string, octave_value> conf_info_map = {{ "DEFAULT_PAGER", config::default_pager () }, #if defined (OCTAVE_ENABLE_64) { "ENABLE_64", true }, #else { "ENABLE_64", false }, #endif #if defined (OCTAVE_ENABLE_COMMAND_LINE_PUSH_PARSER) { "ENABLE_COMMAND_LINE_PUSH_PARSER", true }, #else { "ENABLE_COMMAND_LINE_PUSH_PARSER", false }, #endif #if defined (ENABLE_DOCS) { "ENABLE_DOCS", true }, #else { "ENABLE_DOCS", false }, #endif #if defined (OCTAVE_ENABLE_FLOAT_TRUNCATE) { "ENABLE_FLOAT_TRUNCATE", true }, #else { "ENABLE_FLOAT_TRUNCATE", false }, #endif #if defined (OCTAVE_ENABLE_OPENMP) { "ENABLE_OPENMP", true }, #else { "ENABLE_OPENMP", false }, #endif { "api_version", OCTAVE_API_VERSION }, { "archlibdir", config::arch_lib_dir () }, { "bindir", config::bin_dir () }, { "canonical_host_type", config::canonical_host_type () }, { "datadir", config::data_dir () }, { "datarootdir", config::dataroot_dir () }, { "fcnfiledir", config::fcn_file_dir () }, { "fftw_version", fftw_version () }, { "fftwf_version", fftwf_version () }, { "imagedir", config::image_dir () }, { "includedir", config::include_dir () }, { "infodir", config::info_dir () }, { "libdir", config::lib_dir () }, { "libexecdir", config::libexec_dir () }, // Each library and executable has its own definition of the hg // id. We check for consistency when Octave starts so we just // store and report one of them here. { "hg_id", liboctinterp_hg_id () }, { "localapiarchlibdir", config::local_api_arch_lib_dir () }, { "localapifcnfiledir", config::local_api_fcn_file_dir () }, { "localapioctfiledir", config::local_api_oct_file_dir () }, { "localarchlibdir", config::local_arch_lib_dir () }, { "localfcnfiledir", config::local_fcn_file_dir () }, { "localoctfiledir", config::local_oct_file_dir () }, { "localstartupfiledir", config::local_startupfile_dir () }, { "localverarchlibdir", config::local_ver_arch_lib_dir () }, { "localverfcnfiledir", config::local_ver_fcn_file_dir () }, { "localveroctfiledir", config::local_ver_oct_file_dir () }, { "major_version", STRINGIFY (OCTAVE_MAJOR_VERSION) }, { "man1dir", config::man1_dir () }, { "man1ext", config::man1_ext () }, { "mandir", config::man_dir () }, { "minor_version", STRINGIFY (OCTAVE_MINOR_VERSION) }, { "octdatadir", config::oct_data_dir () }, { "octdocdir", config::oct_doc_dir () }, { "octetcdir", config::oct_etc_dir () }, { "octfiledir", config::oct_file_dir () }, { "octfontsdir", config::oct_fonts_dir () }, { "octincludedir", config::oct_include_dir () }, { "octlibdir", config::oct_lib_dir () }, { "octtestsdir", config::oct_tests_dir () }, { "patch_version", STRINGIFY (OCTAVE_PATCH_VERSION) }, { "release_date", OCTAVE_RELEASE_DATE }, { "startupfiledir", config::startupfile_dir () }, { "version", OCTAVE_VERSION }}; std::map<std::string, octave_value> build_env_map = {{ "AMD_CPPFLAGS", build_env::AMD_CPPFLAGS }, { "AMD_LDFLAGS", build_env::AMD_LDFLAGS }, { "AMD_LIBS", build_env::AMD_LIBS }, { "AR", build_env::AR }, { "ARFLAGS", build_env::ARFLAGS }, { "ARPACK_CPPFLAGS", build_env::ARPACK_CPPFLAGS }, { "ARPACK_LDFLAGS", build_env::ARPACK_LDFLAGS }, { "ARPACK_LIBS", build_env::ARPACK_LIBS }, { "BLAS_LIBS", build_env::BLAS_LIBS }, { "CAMD_CPPFLAGS", build_env::CAMD_CPPFLAGS }, { "CAMD_LDFLAGS", build_env::CAMD_LDFLAGS }, { "CAMD_LIBS", build_env::CAMD_LIBS }, { "CARBON_LIBS", build_env::CARBON_LIBS }, { "CC", build_env::CC }, { "CCOLAMD_CPPFLAGS", build_env::CCOLAMD_CPPFLAGS }, { "CCOLAMD_LDFLAGS", build_env::CCOLAMD_LDFLAGS }, { "CCOLAMD_LIBS", build_env::CCOLAMD_LIBS }, { "CFLAGS", build_env::CFLAGS }, { "CHOLMOD_CPPFLAGS", build_env::CHOLMOD_CPPFLAGS }, { "CHOLMOD_LDFLAGS", build_env::CHOLMOD_LDFLAGS }, { "CHOLMOD_LIBS", build_env::CHOLMOD_LIBS }, { "COLAMD_CPPFLAGS", build_env::COLAMD_CPPFLAGS }, { "COLAMD_LDFLAGS", build_env::COLAMD_LDFLAGS }, { "COLAMD_LIBS", build_env::COLAMD_LIBS }, { "CPICFLAG", build_env::CPICFLAG }, { "CPPFLAGS", build_env::CPPFLAGS }, { "CURL_CPPFLAGS", build_env::CURL_CPPFLAGS }, { "CURL_LDFLAGS", build_env::CURL_LDFLAGS }, { "CURL_LIBS", build_env::CURL_LIBS }, { "CXSPARSE_CPPFLAGS", build_env::CXSPARSE_CPPFLAGS }, { "CXSPARSE_LDFLAGS", build_env::CXSPARSE_LDFLAGS }, { "CXSPARSE_LIBS", build_env::CXSPARSE_LIBS }, { "CXX", build_env::CXX }, { "CXXCPP", build_env::CXXCPP }, { "CXXFLAGS", build_env::CXXFLAGS }, { "CXXPICFLAG", build_env::CXXPICFLAG }, { "DEFS", build_env::DEFS }, { "DL_LDFLAGS", build_env::DL_LDFLAGS }, { "GCC_VERSION", build_env::GCC_VERSION }, { "GXX_VERSION", build_env::GXX_VERSION }, { "EXEEXT", build_env::EXEEXT }, { "F77", build_env::F77 }, { "F77_FLOAT_STORE_FLAG", build_env::F77_FLOAT_STORE_FLAG }, { "F77_INTEGER_8_FLAG", build_env::F77_INTEGER_8_FLAG }, { "FFLAGS", build_env::FFLAGS }, { "FFTW3_CPPFLAGS", build_env::FFTW3_CPPFLAGS }, { "FFTW3_LDFLAGS", build_env::FFTW3_LDFLAGS }, { "FFTW3_LIBS", build_env::FFTW3_LIBS }, { "FFTW3F_CPPFLAGS", build_env::FFTW3F_CPPFLAGS }, { "FFTW3F_LDFLAGS", build_env::FFTW3F_LDFLAGS }, { "FFTW3F_LIBS", build_env::FFTW3F_LIBS }, { "FLIBS", build_env::FLIBS }, { "FLTK_CPPFLAGS", build_env::FLTK_CPPFLAGS }, { "FLTK_LDFLAGS", build_env::FLTK_LDFLAGS }, { "FLTK_LIBS", build_env::FLTK_LIBS }, { "FONTCONFIG_CPPFLAGS", build_env::FONTCONFIG_CPPFLAGS }, { "FONTCONFIG_LIBS", build_env::FONTCONFIG_LIBS }, { "FPICFLAG", build_env::FPICFLAG }, { "FT2_CPPFLAGS", build_env::FT2_CPPFLAGS }, { "FT2_LIBS", build_env::FT2_LIBS }, { "GLPK_CPPFLAGS", build_env::GLPK_CPPFLAGS }, { "GLPK_LDFLAGS", build_env::GLPK_LDFLAGS }, { "GLPK_LIBS", build_env::GLPK_LIBS }, { "GNUPLOT", build_env::GNUPLOT }, { "HDF5_CPPFLAGS", build_env::HDF5_CPPFLAGS }, { "HDF5_LDFLAGS", build_env::HDF5_LDFLAGS }, { "HDF5_LIBS", build_env::HDF5_LIBS }, { "LAPACK_LIBS", build_env::LAPACK_LIBS }, { "LDFLAGS", build_env::LDFLAGS }, { "LD_STATIC_FLAG", build_env::LD_STATIC_FLAG }, { "LEX", build_env::LEX }, { "LEXLIB", build_env::LEXLIB }, { "LFLAGS", build_env::LFLAGS }, { "LIBOCTAVE", build_env::LIBOCTAVE }, { "LIBOCTINTERP", build_env::LIBOCTINTERP }, { "LIBS", build_env::LIBS }, { "LN_S", build_env::LN_S }, { "MAGICK_CPPFLAGS", build_env::MAGICK_CPPFLAGS }, { "MAGICK_LDFLAGS", build_env::MAGICK_LDFLAGS }, { "MAGICK_LIBS", build_env::MAGICK_LIBS }, { "MKOCTFILE_DL_LDFLAGS", build_env::MKOCTFILE_DL_LDFLAGS }, { "OCTAVE_LINK_DEPS", build_env::OCTAVE_LINK_DEPS }, { "OCTAVE_LINK_OPTS", build_env::OCTAVE_LINK_OPTS }, { "OCT_LINK_DEPS", build_env::OCT_LINK_DEPS }, { "OCT_LINK_OPTS", build_env::OCT_LINK_OPTS }, { "OPENGL_LIBS", build_env::OPENGL_LIBS }, { "PCRE_CPPFLAGS", build_env::PCRE_CPPFLAGS }, { "PCRE_LDFLAGS", build_env::PCRE_LDFLAGS }, { "PCRE_LIBS", build_env::PCRE_LIBS }, { "PTHREAD_CFLAGS", build_env::PTHREAD_CFLAGS }, { "PTHREAD_LIBS", build_env::PTHREAD_LIBS }, { "QHULL_CPPFLAGS", build_env::QHULL_CPPFLAGS }, { "QHULL_LDFLAGS", build_env::QHULL_LDFLAGS }, { "QHULL_LIBS", build_env::QHULL_LIBS }, { "QRUPDATE_CPPFLAGS", build_env::QRUPDATE_CPPFLAGS }, { "QRUPDATE_LDFLAGS", build_env::QRUPDATE_LDFLAGS }, { "QRUPDATE_LIBS", build_env::QRUPDATE_LIBS }, { "QT_CPPFLAGS", build_env::QT_CPPFLAGS }, { "QT_LDFLAGS", build_env::QT_LDFLAGS }, { "QT_LIBS", build_env::QT_LIBS }, { "QT_OPENGL_LIBS", build_env::QT_OPENGL_LIBS }, { "RANLIB", build_env::RANLIB }, { "RDYNAMIC_FLAG", build_env::RDYNAMIC_FLAG }, { "READLINE_LIBS", build_env::READLINE_LIBS }, { "SHARED_LIBS", build_env::SHARED_LIBS }, { "SH_LDFLAGS", build_env::SH_LDFLAGS }, { "STATIC_LIBS", build_env::STATIC_LIBS }, { "SUITESPARSECONFIG_LIBS", build_env::SUITESPARSECONFIG_LIBS }, { "UMFPACK_CPPFLAGS", build_env::UMFPACK_CPPFLAGS }, { "UMFPACK_LDFLAGS", build_env::UMFPACK_LDFLAGS }, { "UMFPACK_LIBS", build_env::UMFPACK_LIBS }, { "WARN_CFLAGS", build_env::WARN_CFLAGS }, { "WARN_CXXFLAGS", build_env::WARN_CXXFLAGS }, { "X11_INCFLAGS", build_env::X11_INCFLAGS }, { "X11_LIBS", build_env::X11_LIBS }, { "XTRA_CFLAGS", build_env::XTRA_CFLAGS }, { "XTRA_CXXFLAGS", build_env::XTRA_CXXFLAGS }, { "YACC", build_env::YACC }, { "YFLAGS", build_env::YFLAGS }, { "Z_CPPFLAGS", build_env::Z_CPPFLAGS }, { "Z_LDFLAGS", build_env::Z_LDFLAGS }, { "Z_LIBS", build_env::Z_LIBS }, { "config_opts", build_env::config_opts }}; config = octave_scalar_map (conf_info_map); build_env = octave_scalar_map (build_env_map); build_features = build_env::features (); bool unix_system = true; bool mac_system = false; bool windows_system = false; #if defined (__WIN32__) windows_system = true; #if ! defined (__CYGWIN__) unix_system = false; #endif #endif #if defined (OCTAVE_USE_OS_X_API) mac_system = true; #endif config.assign ("unix", octave_value (unix_system)); config.assign ("mac", octave_value (mac_system)); config.assign ("windows", octave_value (windows_system)); mach_info::float_format ff = mach_info::native_float_format (); config.assign ("float_format", octave_value (mach_info::float_format_as_string (ff))); config.assign ("words_big_endian", octave_value (mach_info::words_big_endian ())); config.assign ("words_little_endian", octave_value (mach_info::words_little_endian ())); config.assign ("build_environment", octave_value (build_env)); config.assign ("build_features", octave_value (build_features)); initialized = true; } int nargin = args.length (); if (nargin > 1) print_usage (); octave_value_list retval; if (nargin == 1) { std::string arg = args(0).xstring_value ("__octave_config_info__: OPTION argument must be a string"); octave_value info = find_config_info (config, arg); if (info.is_undefined ()) info = find_config_info (build_env, arg); if (info.is_undefined ()) info = find_config_info (build_features, arg); if (info.is_undefined ()) error ("__octave_config_info__: no info for '%s'", arg.c_str ()); return info; } else retval = ovl (config); return retval; } /* %!assert (ischar (__octave_config_info__ ("version"))) %!assert (__octave_config_info__ ("version"), OCTAVE_VERSION ()) %!test %! x = __octave_config_info__ (); %! assert (isstruct (x)); %! assert (! isempty (x)); %! assert (x.version, OCTAVE_VERSION ()); %!error __octave_config_info__ (1, 2) */ OCTAVE_END_NAMESPACE(octave) #if defined (__GNUG__) && defined (DEBUG_NEW_DELETE) int debug_new_delete = 0; typedef void (*vfp)(void); extern vfp __new_handler; void * __builtin_new (std::size_t sz) { void *p; // malloc (0) is unpredictable; avoid it. if (sz == 0) sz = 1; p = std::malloc (sz); while (p == 0) { (*__new_handler) (); p = std::malloc (sz); } if (debug_new_delete) std::cerr << "__builtin_new: " << p << std::endl; return p; } void __builtin_delete (void *ptr) { if (debug_new_delete) std::cerr << "__builtin_delete: " << ptr << std::endl; free (ptr); } #endif