Mercurial > gnulib
annotate lib/long-options.h @ 40198:5a34193cbc07
long-options: add parse_gnu_standard_options_only
Discussed in https://bugs.gnu.org/33468 .
* lib/long-options.c (parse_long_options): Use EXIT_SUCCESS instead
of 0.
(parse_gnu_standard_options_only): Add function to
process the GNU default options --help and --version and fail for any other
unknown long or short option. See
https://gnu.org/prep/standards/html_node/Command_002dLine-Interfaces.html .
* lib/long-options.h (parse_gnu_standard_options_only): Declare it.
* modules/long-options (depends-on): Add stdbool, exitfail.
* top/maint.mk (sc_prohibit_long_options_without_use): Update
syntax-check rule, add new function name.
author | Bernhard Voelker <mail@bernhard-voelker.de> |
---|---|
date | Thu, 29 Nov 2018 09:06:26 +0100 |
parents | b06060465f09 |
children |
rev | line source |
---|---|
743 | 1 /* long-options.h -- declaration for --help- and --version-handling function. |
40057
b06060465f09
maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents:
19484
diff
changeset
|
2 Copyright (C) 1993-1994, 1998-1999, 2003, 2009-2019 Free Software |
12559
c2cbabec01dd
update nearly all FSF copyright year lists to include 2010
Jim Meyering <meyering@redhat.com>
parents:
12518
diff
changeset
|
3 Foundation, Inc. |
743 | 4 |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
5848
diff
changeset
|
5 This program is free software: you can redistribute it and/or modify |
743 | 6 it under the terms of the GNU General Public License as published by |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
5848
diff
changeset
|
7 the Free Software Foundation; either version 3 of the License, or |
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
5848
diff
changeset
|
8 (at your option) any later version. |
743 | 9 |
10 This program is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 GNU General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU General Public License | |
19190 | 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */ |
743 | 17 |
18 /* Written by Jim Meyering. */ | |
19 | |
40198
5a34193cbc07
long-options: add parse_gnu_standard_options_only
Bernhard Voelker <mail@bernhard-voelker.de>
parents:
40057
diff
changeset
|
20 #ifndef LONG_OPTIONS_H_ |
5a34193cbc07
long-options: add parse_gnu_standard_options_only
Bernhard Voelker <mail@bernhard-voelker.de>
parents:
40057
diff
changeset
|
21 # define LONG_OPTIONS_H_ 1 |
5a34193cbc07
long-options: add parse_gnu_standard_options_only
Bernhard Voelker <mail@bernhard-voelker.de>
parents:
40057
diff
changeset
|
22 |
5a34193cbc07
long-options: add parse_gnu_standard_options_only
Bernhard Voelker <mail@bernhard-voelker.de>
parents:
40057
diff
changeset
|
23 # include <stdbool.h> |
5a34193cbc07
long-options: add parse_gnu_standard_options_only
Bernhard Voelker <mail@bernhard-voelker.de>
parents:
40057
diff
changeset
|
24 |
4397
c6450308f123
Assume C89, so PARAMS isn't needed.
Paul Eggert <eggert@cs.ucla.edu>
parents:
2807
diff
changeset
|
25 void parse_long_options (int _argc, |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
26 char **_argv, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
27 const char *_command_name, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
28 const char *_package, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
29 const char *_version, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
30 void (*_usage) (int), |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
31 /* const char *author1, ...*/ ...); |
40198
5a34193cbc07
long-options: add parse_gnu_standard_options_only
Bernhard Voelker <mail@bernhard-voelker.de>
parents:
40057
diff
changeset
|
32 |
5a34193cbc07
long-options: add parse_gnu_standard_options_only
Bernhard Voelker <mail@bernhard-voelker.de>
parents:
40057
diff
changeset
|
33 void parse_gnu_standard_options_only (int argc, |
5a34193cbc07
long-options: add parse_gnu_standard_options_only
Bernhard Voelker <mail@bernhard-voelker.de>
parents:
40057
diff
changeset
|
34 char **argv, |
5a34193cbc07
long-options: add parse_gnu_standard_options_only
Bernhard Voelker <mail@bernhard-voelker.de>
parents:
40057
diff
changeset
|
35 const char *command_name, |
5a34193cbc07
long-options: add parse_gnu_standard_options_only
Bernhard Voelker <mail@bernhard-voelker.de>
parents:
40057
diff
changeset
|
36 const char *package, |
5a34193cbc07
long-options: add parse_gnu_standard_options_only
Bernhard Voelker <mail@bernhard-voelker.de>
parents:
40057
diff
changeset
|
37 const char *version, |
5a34193cbc07
long-options: add parse_gnu_standard_options_only
Bernhard Voelker <mail@bernhard-voelker.de>
parents:
40057
diff
changeset
|
38 bool scan_all, |
5a34193cbc07
long-options: add parse_gnu_standard_options_only
Bernhard Voelker <mail@bernhard-voelker.de>
parents:
40057
diff
changeset
|
39 void (*usage_func) (int), |
5a34193cbc07
long-options: add parse_gnu_standard_options_only
Bernhard Voelker <mail@bernhard-voelker.de>
parents:
40057
diff
changeset
|
40 /* const char *author1, ...*/ ...); |
5a34193cbc07
long-options: add parse_gnu_standard_options_only
Bernhard Voelker <mail@bernhard-voelker.de>
parents:
40057
diff
changeset
|
41 |
5a34193cbc07
long-options: add parse_gnu_standard_options_only
Bernhard Voelker <mail@bernhard-voelker.de>
parents:
40057
diff
changeset
|
42 #endif /* LONG_OPTIONS_H_ */ |