GNU Octave 11.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-2026 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 "oct-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://gnu.org/licenses/gpl.html>.\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 unwind_action restore_mask
273 ([] (void *mask) { restore_signal_mask (mask); }, get_signal_mask ());
274
277
278 if (type == et_async)
279 retval(0) = octave_async_system_wrapper (cmd_str.c_str ());
280 else if (return_output)
281 retval = run_command_and_return_output (cmd_str);
282 else
283 {
284 int status = sys::system (cmd_str);
285
286 // The value in status is as returned by waitpid. If
287 // the process exited normally, extract the actual exit
288 // status of the command. Otherwise, return 127 as a
289 // failure code.
290
291 if (sys::wifexited (status))
292 status = sys::wexitstatus (status);
293
294 retval(0) = status;
295 }
296
297 return retval;
298}
299
300/*
301%!test
302%! cmd = ls_command ();
303%! [status, output] = system (cmd);
304%! assert (status, 0);
305%! assert (ischar (output));
306%! assert (! isempty (output));
307
308%!shared octave_exe_path, nul_device
309%! exe_ext = __octave_config_info__ ("EXEEXT");
310%! octave_path = getenv ("OCTAVE_BINDIR");
311%! if (isempty (octave_path))
312%! octave_path = EXEC_PATH;
313%! endif
314%! octave_exe_path = file_in_path (octave_path, ["octave", exe_ext]);
315%! if (ispc ())
316%! nul_device = "nul";
317%! else
318%! nul_device = "/dev/null";
319%! endif
320
321## Test double-quoted commands and redirecting output
322%!test <*68033>
323%! status = system (sprintf ('"%s" "--version" 1>%s 2>&1', ...
324%! octave_exe_path, nul_device));
325%! assert (status, 0);
326
327## Test double-quoted commands and redirecting output capturing output
328%!test <*68033>
329%! [status, output] = system (sprintf ('"%s" "--version" 1>%s 2>&1', ...
330%! octave_exe_path, nul_device));
331%! assert (status, 0);
332%! assert (ischar (output));
333%! assert (output, "");
334
335## Test double-quoted commands capturing output
336%!test <*68033>
337%! [status, output] = system (sprintf ('"%s" "--version" 2>&1', ...
338%! octave_exe_path));
339%! assert (status, 0);
340%! assert (ischar (output));
341%! assert (! isempty (output));
342
343%!error system ()
344%!error system (1, 2, 3)
345%!error <RETURN_OUTPUT must be boolean value> system (ls_command (), "foo")
346%!error <TYPE must be .*sync.* or .*async> system (ls_command (), true, "foo")
347%!warning <converted to logical 1> system (ls_command (), 0.5);
348*/
349
350static octave_value
351find_config_info (const octave_scalar_map& m, const std::string& key)
352{
353 if (m.isfield (key))
354 {
355 Cell c = m.contents (key);
356
357 if (! c.isempty ())
358 return c(0);
359 }
360
361 return octave_value ();
362}
363
364DEFUN (__octave_config_info__, args, ,
365 doc: /* -*- texinfo -*-
366@deftypefn {} {@var{S} =} __octave_config_info__ ()
367@deftypefnx {} {@var{S} =} __octave_config_info__ (@var{option})
368Return a structure containing configuration and installation information for
369Octave.
370
371If @var{option} is a string, return the configuration information for the
372specified option.
373
374@seealso{computer}
375@end deftypefn */)
376{
377 static octave_scalar_map config;
378 static octave_scalar_map build_env;
379 static octave_scalar_map build_features;
380
381 static bool initialized = false;
382
383 if (! initialized)
384 {
385 std::map<std::string, octave_value> conf_info_map
386 = {{ "DEFAULT_PAGER", config::default_pager () },
387
388#if defined (OCTAVE_ENABLE_64)
389 { "ENABLE_64", true },
390#else
391 { "ENABLE_64", false },
392#endif
393
394#if defined (OCTAVE_ENABLE_COMMAND_LINE_PUSH_PARSER)
395 { "ENABLE_COMMAND_LINE_PUSH_PARSER", true },
396#else
397 { "ENABLE_COMMAND_LINE_PUSH_PARSER", false },
398#endif
399
400#if defined (ENABLE_DOCS)
401 { "ENABLE_DOCS", true },
402#else
403 { "ENABLE_DOCS", false },
404#endif
405
406#if defined (OCTAVE_ENABLE_OPENMP)
407 { "ENABLE_OPENMP", true },
408#else
409 { "ENABLE_OPENMP", false },
410#endif
411
412 { "api_version", OCTAVE_API_VERSION },
413 { "archlibdir", config::arch_lib_dir () },
414 { "bindir", config::bin_dir () },
415 { "canonical_host_type", config::canonical_host_type () },
416 { "datadir", config::data_dir () },
417 { "datarootdir", config::dataroot_dir () },
418 { "fcnfiledir", config::fcn_file_dir () },
419 { "fftw_version", fftw_version () },
420 { "fftwf_version", fftwf_version () },
421 { "imagedir", config::image_dir () },
422 { "includedir", config::include_dir () },
423 { "infodir", config::info_dir () },
424 { "libdir", config::lib_dir () },
425 { "libexecdir", config::libexec_dir () },
426 // Each library and executable has its own definition of the hg
427 // id. We check for consistency when Octave starts so we just
428 // store and report one of them here.
429 { "hg_id", liboctinterp_hg_id () },
430 { "localapiarchlibdir", config::local_api_arch_lib_dir () },
431 { "localapifcnfiledir", config::local_api_fcn_file_dir () },
432 { "localapioctfiledir", config::local_api_oct_file_dir () },
433 { "localapipkgdir", config::local_api_pkg_dir () },
434 { "localarchlibdir", config::local_arch_lib_dir () },
435 { "localfcnfiledir", config::local_fcn_file_dir () },
436 { "localoctfiledir", config::local_oct_file_dir () },
437 { "localstartupfiledir", config::local_startupfile_dir () },
438 { "localverarchlibdir", config::local_ver_arch_lib_dir () },
439 { "localverfcnfiledir", config::local_ver_fcn_file_dir () },
440 { "localveroctfiledir", config::local_ver_oct_file_dir () },
441 { "major_version", STRINGIFY (OCTAVE_MAJOR_VERSION) },
442 { "man1dir", config::man1_dir () },
443 { "man1ext", config::man1_ext () },
444 { "mandir", config::man_dir () },
445 { "minor_version", STRINGIFY (OCTAVE_MINOR_VERSION) },
446 { "octdatadir", config::oct_data_dir () },
447 { "octdocdir", config::oct_doc_dir () },
448 { "octetcdir", config::oct_etc_dir () },
449 { "octfiledir", config::oct_file_dir () },
450 { "octfontsdir", config::oct_fonts_dir () },
451 { "octincludedir", config::oct_include_dir () },
452 { "octlibdir", config::oct_lib_dir () },
453 { "octtestsdir", config::oct_tests_dir () },
454 { "patch_version", STRINGIFY (OCTAVE_PATCH_VERSION) },
455 { "release_date", OCTAVE_RELEASE_DATE },
456 { "startupfiledir", config::startupfile_dir () },
457 { "version", OCTAVE_VERSION }
458 };
459
460 std::map<std::string, octave_value> build_env_map
461 = {{ "AMD_CPPFLAGS", build_env::AMD_CPPFLAGS },
462 { "AMD_LDFLAGS", build_env::AMD_LDFLAGS },
463 { "AMD_LIBS", build_env::AMD_LIBS },
464 { "AR", build_env::AR },
465 { "ARFLAGS", build_env::ARFLAGS },
466 { "ARPACK_CPPFLAGS", build_env::ARPACK_CPPFLAGS },
467 { "ARPACK_LDFLAGS", build_env::ARPACK_LDFLAGS },
468 { "ARPACK_LIBS", build_env::ARPACK_LIBS },
469 { "BLAS_LIBS", build_env::BLAS_LIBS },
470 { "CAMD_CPPFLAGS", build_env::CAMD_CPPFLAGS },
471 { "CAMD_LDFLAGS", build_env::CAMD_LDFLAGS },
472 { "CAMD_LIBS", build_env::CAMD_LIBS },
473 { "CARBON_LIBS", build_env::CARBON_LIBS },
474 { "CC", build_env::CC },
475 { "CCOLAMD_CPPFLAGS", build_env::CCOLAMD_CPPFLAGS },
476 { "CCOLAMD_LDFLAGS", build_env::CCOLAMD_LDFLAGS },
477 { "CCOLAMD_LIBS", build_env::CCOLAMD_LIBS },
478 { "CFLAGS", build_env::CFLAGS },
479 { "CHOLMOD_CPPFLAGS", build_env::CHOLMOD_CPPFLAGS },
480 { "CHOLMOD_LDFLAGS", build_env::CHOLMOD_LDFLAGS },
481 { "CHOLMOD_LIBS", build_env::CHOLMOD_LIBS },
482 { "COLAMD_CPPFLAGS", build_env::COLAMD_CPPFLAGS },
483 { "COLAMD_LDFLAGS", build_env::COLAMD_LDFLAGS },
484 { "COLAMD_LIBS", build_env::COLAMD_LIBS },
485 { "CPICFLAG", build_env::CPICFLAG },
486 { "CPPFLAGS", build_env::CPPFLAGS },
487 { "CURL_CPPFLAGS", build_env::CURL_CPPFLAGS },
488 { "CURL_LDFLAGS", build_env::CURL_LDFLAGS },
489 { "CURL_LIBS", build_env::CURL_LIBS },
490 { "CXSPARSE_CPPFLAGS", build_env::CXSPARSE_CPPFLAGS },
491 { "CXSPARSE_LDFLAGS", build_env::CXSPARSE_LDFLAGS },
492 { "CXSPARSE_LIBS", build_env::CXSPARSE_LIBS },
493 { "CXX", build_env::CXX },
494 { "CXXCPP", build_env::CXXCPP },
495 { "CXXFLAGS", build_env::CXXFLAGS },
496 { "CXXPICFLAG", build_env::CXXPICFLAG },
497 { "DEFS", build_env::DEFS },
498 { "DL_LDFLAGS", build_env::DL_LDFLAGS },
499 { "GCC_VERSION", build_env::GCC_VERSION },
500 { "GXX_VERSION", build_env::GXX_VERSION },
501 { "EXEEXT", build_env::EXEEXT },
502 { "F77", build_env::F77 },
503 { "F77_FLOAT_STORE_FLAG", build_env::F77_FLOAT_STORE_FLAG },
504 { "F77_INTEGER_8_FLAG", build_env::F77_INTEGER_8_FLAG },
505 { "FFLAGS", build_env::FFLAGS },
506 { "FFTW3_CPPFLAGS", build_env::FFTW3_CPPFLAGS },
507 { "FFTW3_LDFLAGS", build_env::FFTW3_LDFLAGS },
508 { "FFTW3_LIBS", build_env::FFTW3_LIBS },
509 { "FFTW3F_CPPFLAGS", build_env::FFTW3F_CPPFLAGS },
510 { "FFTW3F_LDFLAGS", build_env::FFTW3F_LDFLAGS },
511 { "FFTW3F_LIBS", build_env::FFTW3F_LIBS },
512 { "FLIBS", build_env::FLIBS },
513 { "FLTK_CPPFLAGS", build_env::FLTK_CPPFLAGS },
514 { "FLTK_LDFLAGS", build_env::FLTK_LDFLAGS },
515 { "FLTK_LIBS", build_env::FLTK_LIBS },
516 { "FONTCONFIG_CPPFLAGS", build_env::FONTCONFIG_CPPFLAGS },
517 { "FONTCONFIG_LIBS", build_env::FONTCONFIG_LIBS },
518 { "FPICFLAG", build_env::FPICFLAG },
519 { "FT2_CPPFLAGS", build_env::FT2_CPPFLAGS },
520 { "FT2_LIBS", build_env::FT2_LIBS },
521 { "GLPK_CPPFLAGS", build_env::GLPK_CPPFLAGS },
522 { "GLPK_LDFLAGS", build_env::GLPK_LDFLAGS },
523 { "GLPK_LIBS", build_env::GLPK_LIBS },
524 { "GNUPLOT", build_env::GNUPLOT },
525 { "HDF5_CPPFLAGS", build_env::HDF5_CPPFLAGS },
526 { "HDF5_LDFLAGS", build_env::HDF5_LDFLAGS },
527 { "HDF5_LIBS", build_env::HDF5_LIBS },
528 { "LAPACK_LIBS", build_env::LAPACK_LIBS },
529 { "LDFLAGS", build_env::LDFLAGS },
530 { "LD_STATIC_FLAG", build_env::LD_STATIC_FLAG },
531 { "LEX", build_env::LEX },
532 { "LEXLIB", build_env::LEXLIB },
533 { "LFLAGS", build_env::LFLAGS },
534 { "LIBOCTAVE", build_env::LIBOCTAVE },
535 { "LIBOCTINTERP", build_env::LIBOCTINTERP },
536 { "LIBS", build_env::LIBS },
537 { "LN_S", build_env::LN_S },
538 { "MAGICK_CPPFLAGS", build_env::MAGICK_CPPFLAGS },
539 { "MAGICK_LDFLAGS", build_env::MAGICK_LDFLAGS },
540 { "MAGICK_LIBS", build_env::MAGICK_LIBS },
541 { "MKOCTFILE_DL_LDFLAGS", build_env::MKOCTFILE_DL_LDFLAGS },
542 { "OCTAVE_LINK_DEPS", build_env::OCTAVE_LINK_DEPS },
543 { "OCTAVE_LINK_OPTS", build_env::OCTAVE_LINK_OPTS },
544 { "OCT_LINK_DEPS", build_env::OCT_LINK_DEPS },
545 { "OCT_LINK_OPTS", build_env::OCT_LINK_OPTS },
546 { "OPENGL_LIBS", build_env::OPENGL_LIBS },
547 { "PCRE_CPPFLAGS", build_env::PCRE_CPPFLAGS },
548 { "PCRE_LDFLAGS", build_env::PCRE_LDFLAGS },
549 { "PCRE_LIBS", build_env::PCRE_LIBS },
550 { "PTHREAD_CFLAGS", build_env::PTHREAD_CFLAGS },
551 { "PTHREAD_LIBS", build_env::PTHREAD_LIBS },
552 { "QHULL_CPPFLAGS", build_env::QHULL_CPPFLAGS },
553 { "QHULL_LDFLAGS", build_env::QHULL_LDFLAGS },
554 { "QHULL_LIBS", build_env::QHULL_LIBS },
555 { "QRUPDATE_CPPFLAGS", build_env::QRUPDATE_CPPFLAGS },
556 { "QRUPDATE_LDFLAGS", build_env::QRUPDATE_LDFLAGS },
557 { "QRUPDATE_LIBS", build_env::QRUPDATE_LIBS },
558 { "QT_CPPFLAGS", build_env::QT_CPPFLAGS },
559 { "QT_LDFLAGS", build_env::QT_LDFLAGS },
560 { "QT_LIBS", build_env::QT_LIBS },
561 { "RANLIB", build_env::RANLIB },
562 { "RDYNAMIC_FLAG", build_env::RDYNAMIC_FLAG },
563 { "READLINE_LIBS", build_env::READLINE_LIBS },
564 { "SHARED_LIBS", build_env::SHARED_LIBS },
565 { "SH_LDFLAGS", build_env::SH_LDFLAGS },
566 { "STATIC_LIBS", build_env::STATIC_LIBS },
567 { "SUITESPARSECONFIG_LIBS", build_env::SUITESPARSECONFIG_LIBS },
568 { "UMFPACK_CPPFLAGS", build_env::UMFPACK_CPPFLAGS },
569 { "UMFPACK_LDFLAGS", build_env::UMFPACK_LDFLAGS },
570 { "UMFPACK_LIBS", build_env::UMFPACK_LIBS },
571 { "WARN_CFLAGS", build_env::WARN_CFLAGS },
572 { "WARN_CXXFLAGS", build_env::WARN_CXXFLAGS },
573 { "X11_INCFLAGS", build_env::X11_INCFLAGS },
574 { "X11_LIBS", build_env::X11_LIBS },
575 { "XTRA_CFLAGS", build_env::XTRA_CFLAGS },
576 { "XTRA_CXXFLAGS", build_env::XTRA_CXXFLAGS },
577 { "YACC", build_env::YACC },
578 { "YFLAGS", build_env::YFLAGS },
579 { "Z_CPPFLAGS", build_env::Z_CPPFLAGS },
580 { "Z_LDFLAGS", build_env::Z_LDFLAGS },
581 { "Z_LIBS", build_env::Z_LIBS },
582 { "config_opts", build_env::config_opts }
583 };
584
585 config = octave_scalar_map (conf_info_map);
586 build_env = octave_scalar_map (build_env_map);
587 build_features = build_env::features ();
588
589 bool unix_system = true;
590 bool mac_system = false;
591 bool windows_system = false;
592
593#if defined (__WIN32__)
594 windows_system = true;
595#if ! defined (__CYGWIN__)
596 unix_system = false;
597#endif
598#endif
599
600#if defined (OCTAVE_USE_OS_X_API)
601 mac_system = true;
602#endif
603
604 config.assign ("unix", octave_value (unix_system));
605 config.assign ("mac", octave_value (mac_system));
606 config.assign ("windows", octave_value (windows_system));
607
608 mach_info::float_format ff = mach_info::native_float_format ();
609 config.assign ("float_format",
610 octave_value (mach_info::float_format_as_string (ff)));
611
612 config.assign ("words_big_endian",
613 octave_value (mach_info::words_big_endian ()));
614
615 config.assign ("words_little_endian",
616 octave_value (mach_info::words_little_endian ()));
617
618 config.assign ("nan_with_payload",
619 octave_value (mach_info::nan_with_payload ()));
620
621 config.assign ("build_environment", octave_value (build_env));
622
623 config.assign ("build_features", octave_value (build_features));
624
625 initialized = true;
626 }
627
628 int nargin = args.length ();
629
630 if (nargin > 1)
631 print_usage ();
632
633 octave_value_list retval;
634
635 if (nargin == 1)
636 {
637 std::string arg = args(0).xstring_value ("__octave_config_info__: OPTION argument must be a string");
638
639 octave_value info = find_config_info (config, arg);
640
641 if (info.is_undefined ())
642 info = find_config_info (build_env, arg);
643
644 if (info.is_undefined ())
645 info = find_config_info (build_features, arg);
646
647 if (info.is_undefined ())
648 error ("__octave_config_info__: no info for '%s'", arg.c_str ());
649
650 return info;
651 }
652 else
653 retval = ovl (config);
654
655 return retval;
656}
657
658/*
659%!assert (ischar (__octave_config_info__ ("version")))
660%!assert (__octave_config_info__ ("version"), OCTAVE_VERSION ())
661%!test
662%! x = __octave_config_info__ ();
663%! assert (isstruct (x));
664%! assert (! isempty (x));
665%! assert (x.version, OCTAVE_VERSION ());
666
667%!error __octave_config_info__ (1, 2)
668*/
669
670OCTAVE_END_NAMESPACE(octave)
pid_t octave_async_system_wrapper(const char *cmd)
bool isempty() const
Size of the specified dimension.
Definition Array-base.h:674
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:593
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:1008
child_list & __get_child_list__()
std::string liboctinterp_hg_id()
#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)
int system(const std::string &cmd_str)
Definition oct-sysdep.cc:63
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_copyright(bool html)
Definition version.cc:65
int octave_wait_for_input(int fid)