GNU Octave 7.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
main-cli.cc
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 2012-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 <cstdlib>
31
32#include <iostream>
33#include <string>
34
35#if defined (OCTAVE_USE_WINDOWS_API) && defined (_UNICODE)
36# include <vector>
37# include <locale>
38# include <codecvt>
39#endif
40
42
44
45#include "oct-env.h"
46#include "signal-wrappers.h"
47
48#include "octave.h"
49#include "octave-build-info.h"
50#include "sysdep.h"
51
52static void
54{
55 bool ok = true;
56
57 // Each library and executable has its own definition of the hg
58 // id. They should always match but may be different because of a
59 // botched installation or incorrect LD_LIBRARY_PATH or some other
60 // unusual problem.
61
62 std::string octave_id = octave_hg_id ();
63 std::string liboctave_id = liboctave_hg_id ();
64 std::string liboctinterp_id = liboctinterp_hg_id ();
65
66 if (octave_id != liboctave_id)
67 {
68 std::cerr << "octave hg id ("
69 << octave_id
70 << ") does not match liboctave hg id ("
71 << liboctave_id
72 << ')' << std::endl;
73 ok = false;
74 }
75
76 if (octave_id != liboctinterp_id)
77 {
78 std::cerr << "octave hg id ("
79 << octave_id
80 << ") does not match liboctinterp hg id ("
81 << liboctinterp_id
82 << ')' << std::endl;
83 ok = false;
84 }
85
86 if (! ok)
87 exit (1);
88}
89
90#if defined (OCTAVE_USE_WINDOWS_API) && defined (_UNICODE)
91extern "C"
92int
93wmain (int argc, wchar_t **wargv)
94{
95 static char **argv = new char * [argc + 1];
96 std::vector<std::string> argv_str;
97
98 // convert wide character strings to multibyte UTF-8 strings
99 std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> wchar_conv;
100 for (int i_arg = 0; i_arg < argc; i_arg++)
101 argv_str.push_back (wchar_conv.to_bytes (wargv[i_arg]));
102
103 // Get pointers to C strings not before vector is stable.
104 for (int i_arg = 0; i_arg < argc; i_arg++)
105 argv[i_arg] = &argv_str[i_arg][0];
106 argv[argc] = nullptr;
107
108#else
109int
110main (int argc, char **argv)
111{
112#endif
114
116
118
119 octave::cli_application app (argc, argv);
120
121 return app.execute ();
122}
static void set_program_name(const std::string &s)
Definition: oct-env.cc:187
OCTAVE_API std::string liboctave_hg_id(void)
OCTINTERP_API std::string liboctinterp_hg_id(void)
int main(int argc, char **argv)
Definition: main-cli.cc:110
static void check_hg_versions(void)
Definition: main-cli.cc:53
std::string octave_hg_id(void)
void octave_block_async_signals(void)