Mercurial > octave
annotate liboctave/wrappers/getopt-wrapper.c @ 30564:796f54d4ddbf stable
update Octave Project Developers copyright for the new year
In files that have the "Octave Project Developers" copyright notice,
update for 2021.
In all .txi and .texi files except gpl.txi and gpl.texi in the
doc/liboctave and doc/interpreter directories, change the copyright
to "Octave Project Developers", the same as used for other source
files. Update copyright notices for 2022 (not done since 2019). For
gpl.txi and gpl.texi, change the copyright notice to be "Free Software
Foundation, Inc." and leave the date at 2007 only because this file
only contains the text of the GPL, not anything created by the Octave
Project Developers.
Add Paul Thomas to contributors.in.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 28 Dec 2021 18:22:40 -0500 |
parents | 0f41e117789f |
children | 597f3ee61a48 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
29910
diff
changeset
|
3 // Copyright (C) 2016-2022 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
22064 | 25 |
26 // getopt_long may be provided by gnulib. We don't include gnulib | |
27 // headers directly in Octave's C++ source files to avoid problems that | |
28 // may be caused by the way that gnulib overrides standard library | |
29 // functions. | |
30 | |
31 #if defined (HAVE_CONFIG_H) | |
32 # include "config.h" | |
33 #endif | |
34 | |
35 #include <stdlib.h> | |
36 | |
37 #include <getopt.h> | |
38 | |
39 #include "getopt-wrapper.h" | |
40 | |
41 static struct option * | |
42 make_option_struct (const struct octave_getopt_options *opts) | |
43 { | |
44 const struct octave_getopt_options *p = opts; | |
45 struct option *retval = 0, *q = 0; | |
46 | |
47 int n = 0; | |
48 while (p->name) | |
49 { | |
50 n++; | |
51 p++; | |
52 } | |
53 | |
54 retval = (struct option *) malloc ((n+1) * sizeof (struct option)); | |
55 | |
26426
3e43775ab21c
getopt-wrapper.c: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
56 // If we don't have enough memory even to start Octave |
3e43775ab21c
getopt-wrapper.c: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
57 // then we might as well quit now. |
3e43775ab21c
getopt-wrapper.c: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
58 if (! retval) |
3e43775ab21c
getopt-wrapper.c: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
59 abort (); |
3e43775ab21c
getopt-wrapper.c: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
60 |
22064 | 61 p = opts; |
62 q = retval; | |
63 while (p->name) | |
64 { | |
65 q->name = p->name; | |
66 | |
67 switch (p->has_arg) | |
68 { | |
69 case octave_required_arg: | |
70 q->has_arg = required_argument; | |
71 break; | |
72 | |
73 case octave_optional_arg: | |
74 q->has_arg = optional_argument; | |
75 break; | |
76 | |
77 default: | |
78 q->has_arg = no_argument; | |
79 break; | |
80 } | |
81 | |
82 q->flag = p->flag; | |
83 | |
84 q->val = p->val; | |
85 | |
86 q++; | |
87 p++; | |
88 } | |
89 | |
90 q->name = 0; | |
91 q->has_arg = 0; | |
92 q->flag = 0; | |
93 q->val = 0; | |
94 | |
95 return retval; | |
96 } | |
97 | |
98 int | |
22514
1e007e986396
Fix octave_getopt_long_wrapper prototype to avoid warnings on some systems (bug #49131)
Mike Miller <mtmiller@octave.org>
parents:
22402
diff
changeset
|
99 octave_getopt_long_wrapper (int argc, char **argv, |
22064 | 100 const char *shortopts, |
101 const struct octave_getopt_options *longopts, | |
102 int *longind) | |
103 { | |
104 struct option *lopts = make_option_struct (longopts); | |
105 | |
106 int retval = getopt_long (argc, argv, shortopts, lopts, longind); | |
107 | |
108 free (lopts); | |
109 | |
110 return retval; | |
111 } | |
22090
66db9a493c84
avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents:
22064
diff
changeset
|
112 |
66db9a493c84
avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents:
22064
diff
changeset
|
113 char * |
66db9a493c84
avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents:
22064
diff
changeset
|
114 octave_optarg_wrapper (void) |
66db9a493c84
avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents:
22064
diff
changeset
|
115 { |
66db9a493c84
avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents:
22064
diff
changeset
|
116 return optarg; |
66db9a493c84
avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents:
22064
diff
changeset
|
117 } |
66db9a493c84
avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents:
22064
diff
changeset
|
118 |
66db9a493c84
avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents:
22064
diff
changeset
|
119 int |
66db9a493c84
avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents:
22064
diff
changeset
|
120 octave_optind_wrapper (void) |
66db9a493c84
avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents:
22064
diff
changeset
|
121 { |
66db9a493c84
avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents:
22064
diff
changeset
|
122 return optind; |
66db9a493c84
avoid accessing optarg and optind directly (bug #48454)
John W. Eaton <jwe@octave.org>
parents:
22064
diff
changeset
|
123 } |
29910
0f41e117789f
disable getopt error reporting in wrapper program (bug #60886)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
124 |
0f41e117789f
disable getopt error reporting in wrapper program (bug #60886)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
125 int |
0f41e117789f
disable getopt error reporting in wrapper program (bug #60886)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
126 octave_get_opterr_wrapper (void) |
0f41e117789f
disable getopt error reporting in wrapper program (bug #60886)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
127 { |
0f41e117789f
disable getopt error reporting in wrapper program (bug #60886)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
128 return opterr; |
0f41e117789f
disable getopt error reporting in wrapper program (bug #60886)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
129 } |
0f41e117789f
disable getopt error reporting in wrapper program (bug #60886)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
130 |
0f41e117789f
disable getopt error reporting in wrapper program (bug #60886)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
131 int |
0f41e117789f
disable getopt error reporting in wrapper program (bug #60886)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
132 octave_set_opterr_wrapper (int val) |
0f41e117789f
disable getopt error reporting in wrapper program (bug #60886)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
133 { |
0f41e117789f
disable getopt error reporting in wrapper program (bug #60886)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
134 int retval = opterr; |
0f41e117789f
disable getopt error reporting in wrapper program (bug #60886)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
135 |
0f41e117789f
disable getopt error reporting in wrapper program (bug #60886)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
136 opterr = val; |
0f41e117789f
disable getopt error reporting in wrapper program (bug #60886)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
137 |
0f41e117789f
disable getopt error reporting in wrapper program (bug #60886)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
138 return retval; |
0f41e117789f
disable getopt error reporting in wrapper program (bug #60886)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
139 } |
0f41e117789f
disable getopt error reporting in wrapper program (bug #60886)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
140 |