annotate lwlib/lw_cmdline.h @ 416:b4d0eafc5bfe

Fix code generation error in gcc6809 It turned out that under some circumstances, the gcc optimizer would select an instruction sequence that had the sense of a branch inverted. It seems this was due to a particular instruction pattern included in the machine description not being quite right with respect to how the condition codes were tracked. Removing that instruction pattern seems to fix things (subtraction with the arguments reversed). gcc seems to be smart enough to figure out how to reorganize code to work without this reversed sense subtraction and then do the right thing.
author William Astle <lost@l-w.ca>
date Thu, 24 Mar 2016 20:07:20 -0600
parents 8e25147c2aa8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
1 /*
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
2 lw_cmdline.h
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
3
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
4 Copyright © 2010 William Astle
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
5
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
6 This file is part of LWTOOLS.
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
7
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
8 LWTOOLS is free software: you can redistribute it and/or modify it under the
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
9 terms of the GNU General Public License as published by the Free Software
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
10 Foundation, either version 3 of the License, or (at your option) any later
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
11 version.
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
12
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
13 This program is distributed in the hope that it will be useful, but WITHOUT
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
16 more details.
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
17
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
18 You should have received a copy of the GNU General Public License along with
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
19 this program. If not, see <http://www.gnu.org/licenses/>.
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
20 */
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
21
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
22 /*
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
23
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
24 This argument parser is patterned after argp from the gnu C library but
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
25 has much of the functionality removed. It is provided here because not
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
26 every system has glibc.
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
27
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
28 Most notably, it does not support option groups or i18n.
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
29
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
30 */
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
31
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
32 #ifndef ___lw_cmdline_h_seen___
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
33 #define ___lw_cmdline_h_seen___
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
34
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
35 struct lw_cmdline_options
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
36 {
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
37 char *name;
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
38 int key;
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
39 char *arg;
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
40 int flags;
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
41 char *doc;
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
42 };
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
43
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
44 enum
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
45 {
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
46 lw_cmdline_opt_optional = 1,
192
8ae2670377ca Added hidden options to lw_cmdline
lost@l-w.ca
parents: 5
diff changeset
47 lw_cmdline_opt_hidden = 2,
5
0e01d1343c02 Added basic --help routine to lw_cmdline
lost@l-w.ca
parents: 4
diff changeset
48 /* lw_cmdline_opt_alias = 4,*/
0e01d1343c02 Added basic --help routine to lw_cmdline
lost@l-w.ca
parents: 4
diff changeset
49 /* lw_cmdline_opt_nousage = 0x10,*/
0e01d1343c02 Added basic --help routine to lw_cmdline
lost@l-w.ca
parents: 4
diff changeset
50 lw_cmdline_opt_doc = 0x80
4
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
51 };
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
52
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
53 enum
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
54 {
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
55 lw_cmdline_err_unknown = -1
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
56 };
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
57
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
58 enum
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
59 {
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
60 lw_cmdline_key_arg = -1,
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
61 lw_cmdline_key_end = 0
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
62 };
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
63
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
64 struct lw_cmdline_parser
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
65 {
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
66 struct lw_cmdline_options *options;
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
67 int (*parser)(int key, char *arg, void *input);
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
68 char *args_doc;
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
69 char *doc;
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
70 char *program_version;
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
71 };
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
72
374
8e25147c2aa8 Clean up various "externs"
William Astle <lost@l-w.ca>
parents: 192
diff changeset
73 int lw_cmdline_parse(struct lw_cmdline_parser *parser, int argc, char **argv, unsigned flags, int *arg_index, void *input);
4
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
74
a4812d57ed13 Started implementing command line parsing in lwlib
lost@l-w.ca
parents:
diff changeset
75 #endif /* ___lw_cmdline_h_seen___ */