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
41
#include "
liboctave-build-info.h
"
42
43
#include "
liboctinterp-build-info.h
"
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
52
static
void
53
check_hg_versions
(
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)
91
extern
"C"
92
int
93
wmain (
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
109
int
110
main
(
int
argc,
char
**argv)
111
{
112
#endif
113
check_hg_versions
();
114
115
octave_block_async_signals
();
116
117
octave::sys::env::set_program_name
(argv[0]);
118
119
octave::cli_application app (argc, argv);
120
121
return
app.execute ();
122
}
octave::sys::env::set_program_name
static void set_program_name(const std::string &s)
Definition:
oct-env.cc:187
liboctave-build-info.h
liboctave_hg_id
OCTAVE_API std::string liboctave_hg_id(void)
Definition:
liboctave-build-info.in.cc:35
liboctinterp-build-info.h
liboctinterp_hg_id
OCTINTERP_API std::string liboctinterp_hg_id(void)
Definition:
liboctinterp-build-info.in.cc:35
main
int main(int argc, char **argv)
Definition:
main-cli.cc:110
check_hg_versions
static void check_hg_versions(void)
Definition:
main-cli.cc:53
oct-env.h
octave-build-info.h
octave_hg_id
std::string octave_hg_id(void)
Definition:
octave-build-info.in.cc:35
octave.h
octave_block_async_signals
void octave_block_async_signals(void)
Definition:
signal-wrappers.c:665
signal-wrappers.h
sysdep.h
src
main-cli.cc
Generated on Sun Jun 26 2022 01:28:05 for GNU Octave by
1.9.4