File: help.c

package info (click to toggle)
gnucobol3 3.2-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 30,032 kB
  • sloc: sh: 201,859; ansic: 99,735; yacc: 18,930; lex: 5,521; cobol: 1,078; makefile: 593; perl: 555; awk: 184; sed: 16
file content (289 lines) | stat: -rw-r--r-- 12,095 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
/*
   Copyright (C) 2001-2023 Free Software Foundation, Inc.
   Written by Keisuke Nishida, Roger While, Ron Norman, Simon Sobisch,
   Brian Tiffin, Edward Hart, Dave Pitts

   This file is part of GnuCOBOL.

   The GnuCOBOL compiler is free software: you can redistribute it
   and/or modify it under the terms of the GNU General Public License
   as published by the Free Software Foundation, either version 3 of the
   License, or (at your option) any later version.

   GnuCOBOL is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with GnuCOBOL.  If not, see <https://www.gnu.org/licenses/>.
*/

#include "config.h"

#include <stdio.h>
#include <string.h>

#include "cobc.h"
#include "tree.h"	/* for COB_INTERNAL_XREF */

void
cobc_print_usage (char * prog)
{
	puts (_("GnuCOBOL compiler for most COBOL dialects with lots of extensions"));
	putchar ('\n');
	printf (_("Usage: %s [options]... file..."), prog);
	putchar ('\n');
	putchar ('\n');

	cobc_print_usage_common_options ();

	cobc_print_usage_warnings ();

	cobc_print_usage_flags ();

	cobc_print_usage_dialect ();

	putchar ('\n');
	printf (_("Report bugs to: %s\n"
	          "or (preferably) use the issue tracker via the home page."),
			"bug-gnucobol@gnu.org");
	putchar ('\n');
	printf (_("GnuCOBOL home page: <%s>"), "https://www.gnu.org/software/gnucobol/");
	putchar ('\n');
	printf (_("General help using GNU software: <%s>"), "https://www.gnu.org/gethelp/");
	putchar ('\n');
}

void
cobc_print_usage_common_options (void)
{
	puts (_("Options:"));
	puts (_("  -h, --help            display this help and exit"));
	puts (_("  -V, --version         display compiler version information and exit"));
	puts (_("  -dumpversion          display compiler version and exit"));
	puts (_("  -i, --info            display compiler information (build/environment)\n"
	        "                        and exit"));
	puts (_("  -v, --verbose         verbose mode, display additional information;\n"
		    "                        multiple -v options increase the verbosity,\n"
		    "                        the maximum is 3 as follows:\n"
		    "                        (1) display compiler version and the commands\n"
	        "                        invoked by the compiler,\n"
		    "                        (2) pass verbose option to assembler/compiler\n"
		    "                        (3) pass verbose option to linker"));
	puts (_("  -q, --brief           reduced displays, commands invoked not shown"));
	puts (_("  -###                  like -v but commands not executed"));
	puts (_("  -x                    build an executable program"));
	puts (_("  -m                    build a dynamically loadable module (default)"));
	puts (_("  -j [<args>], --job[=<args>]\trun program after build, passing <args>"));
	puts (_("  -std=<dialect>        warnings/features for a specific dialect\n"
	        "                        <dialect> can be one of:\n"
	        "                        default, cobol2014, cobol2002, cobol85, xopen,\n"
	        "                        ibm-strict, ibm, mvs-strict, mvs,\n"
	        "                        mf-strict, mf, bs2000-strict, bs2000,\n"
	        "                        acu-strict, acu, rm-strict, rm, gcos-strict,\n"
	        "                        gcos;\n"
	        "                        see configuration files in directory config"));
	puts (_("  -F, --free            use free source format (alias for -fformat=free)"));
	puts (_("  --fixed               use fixed source format (default; alias for\n"
	        "                        -fformat=fixed)"));
	puts (_("  -O, -O2, -O3, -Os     enable optimization"));
	puts (_("  -O0                   disable optimization"));
	puts (_("  -g                    enable C compiler debug and stack check"));
	puts (_("  -d, --debug           enable all run-time error checking,\n"
	        "                        equal to -fstack-check -fec=EC-ALL"));
	/* "duplicated" from flags.def where output is suppressed and untranslated,
	   to place it next to --debug in the help output */
	puts (_("  -fec=<exception-name>\tenable code generation for <exception-name>,\n"
	        "                        see --list-exceptions for the possible values,\n"
	        "                        sets -fsource-location"));
	puts (_("  -fno-ec=<exception-name>\tdisable code generation for <exception-name>"));
	puts (_("  -o <file>             place the output into <file>"));
	puts (_("  -b                    combine all input files into a single\n"
	        "                        dynamically loadable module"));
	puts (_("  -E                    preprocess only; do not compile or link"));
	puts (_("  -C                    translation only; convert COBOL to C"));
	puts (_("  -S                    compile only; output assembly file"));
	puts (_("  -c                    compile and assemble, but do not link"));
	puts (_("  -T <file>             generate and place a wide program listing into <file>"));
	puts (_("  -t <file>             generate and place a program listing into <file>"));
	puts (_("  --tlines=<lines>      specify lines per page in listing, default = 55"));
	puts (_("  -P[=<dir or file>]    generate preprocessed program listing (.lst)"));
#ifndef COB_INTERNAL_XREF
	puts (_("  -X, --Xref            generate cross reference through 'cobxref'\n"
	        "                        (V. Coen's 'cobxref' must be in path)"));
#else
	puts (_("  -X, --Xref            specify cross reference in listing"));
#endif
	puts (_("  -I <directory>        add <directory> to copy/include search path"));
	puts (_("  -L <directory>        add <directory> to library search path"));
	puts (_("  -l <lib>              link the library <lib>"));
	puts (_("  -K <entry>            generate CALL to <entry> as static"));
	puts (_("  -D <define>           define <define> for COBOL compilation"));
	puts (_("  -A <options>          add <options> to the C compile phase"));
	puts (_("  -Q <options>          add <options> to the C link phase"));
	puts (_("  --coverage            instrument generated binaries for coverage"));
	puts (_("  --conf=<file>         user-defined dialect configuration; see -std"));
	puts (_("  --list-reserved       display reserved words"));
	puts (_("  --list-intrinsics     display intrinsic functions"));
	puts (_("  --list-mnemonics      display mnemonic names"));
	puts (_("  --list-exceptions     display exception names"));
	puts (_("  --list-system         display system routines"));
	puts (_("  --save-temps[=<dir>]  save intermediate files\n"
	        "                        * default: current directory"));
	puts (_("  -MT <target>          set/add target file used in dependency list"));
	puts (_("  -MF <file>            place dependency list into <file>"));
	puts (_("  -ext <extension>      add file extension for resolving COPY"));
	putchar ('\n');
}

void
cobc_print_usage_warnings (void)
{
	puts (_("Warning options:"));
	puts (_("  -Wall                 enable most warnings (all except as noted below)"));
	puts (_("  -Wextra               like -Wall but enable some extra warning flags"));
	puts (_("  -w                    disable all warnings"));
	puts (_("  -Wno-<warning>        disable warning enabled by default, -Wall or -Wextra"));
#define	CB_WARNDEF(opt,name,doc)		\
	puts (doc);
#define	CB_ONWARNDEF(opt,name,doc)		\
	puts (doc);							\
	/* TRANSLATORS: This msgid is appended to msgid for -Wno-pending and others */ \
	puts (_("                        * ALWAYS active"));
#define	CB_NOWARNDEF(opt,name,doc)		\
	puts (doc);							\
	/* TRANSLATORS: This msgid is appended to msgid for -Wpossible-truncate and others */ \
	puts (_("                        * NOT set with -Wall"));
#define	CB_ERRWARNDEF(opt,name,doc)		\
	puts (doc);
#include "warning.def"
#undef	CB_WARNDEF
#undef	CB_ONWARNDEF
#undef	CB_NOWARNDEF
#undef	CB_ERRWARNDEF
	puts (_("  -fdiagnostics-plain-output\tmake diagnostic output as plain as possible"));
	puts (_("  -Werror               treat all warnings as errors"));
	puts (_("  -Wno-error            don't treat warnings as errors"));
	puts (_("  -Werror=<warning>     treat specified <warning> as error"));
	puts (_("  -Wno-error=<warning>  don't treat specified <warning> as error"));
	putchar ('\n');
}

static void
cobc_print_active (const char *doc, const int print_help)
{
	if (!print_help) {
		return;
	}
	puts (doc);
}

void
cobc_print_usage_flags (void)
{
	puts (_("Compiler options:"));
#define	CB_FLAG(var,print_help,name,doc)		\
	cobc_print_active (doc, print_help);
#define	CB_FLAG_ON(var,print_help,name,doc)		\
	cobc_print_active (doc, print_help);
#define	CB_FLAG_RQ(var,print_help,name,def,opt,doc)		\
	cobc_print_active (doc, print_help);
#define	CB_FLAG_NQ(print_help,name,opt,doc)		\
	cobc_print_active (doc, print_help);
#define	CB_FLAG_OP(print_help,name,opt,doc)		\
	cobc_print_active (doc, print_help);
#include "flag.def"
#undef	CB_FLAG
#undef	CB_FLAG_ON
#undef	CB_FLAG_RQ
#undef	CB_FLAG_NQ
#undef	CB_FLAG_OP
	cobc_print_active (
	_("  -fibmcomp             sets -fbinary-size=2-4-8 -fsynchronized-clause=ok\n"
	  "  -fno-ibmcomp          sets -fbinary-size=1--8  -fsynchronized-clause=ignore"), 0);
	cobc_print_active (
	_("  -falternate-ebcdic    use restricted ASCII to EBCDIC translate\n"
	  "  -fno-alternate-ebcdic use extended ASCII to EBCDIC translate"), 0);
	putchar ('\n');
}

static void
cobc_print_config_flag (const char *name, const char *doc,
		 const char *odoc)
{
	char		buff[78];

	if (!doc) {
		return;
	}
	if (odoc) {
		snprintf (buff, sizeof (buff) - 1, "%s=%s", name, odoc);
		buff [77] = 0;	/* keep analyzer happy ... */
		name = (const char *) &buff;
	}
	if (strlen (name) <= 19) {
		printf ("  -f%-19s  %s\n", name, doc);
	} else {
		printf ("  -f%s\t%s\n", name, doc);
	}
}

void
cobc_print_usage_dialect (void)
{
	puts (_("Compiler dialect configuration options:"));
#define	CB_CONFIG_STRING(var,name,doc)		\
	cobc_print_config_flag (name, doc, _("<value>"));
#define	CB_CONFIG_INT(var,name,min,max,odoc,doc)		\
	cobc_print_config_flag (name, doc, odoc);
#define	CB_CONFIG_SINT(var,name,min,max,odoc,doc)		\
	cobc_print_config_flag (name, doc, odoc);
#define	CB_CONFIG_ANY(type,var,name,doc)		\
	cobc_print_config_flag (name, doc, _("<value>"));
#define	CB_CONFIG_BOOLEAN(var,name,doc)		\
	cobc_print_config_flag (name, doc, NULL);
#define	CB_CONFIG_SUPPORT(var,name,doc)		\
	cobc_print_config_flag (name, doc, _("<support>"));
#include "config.def"
#undef	CB_CONFIG_ANY
#undef	CB_CONFIG_INT
#undef	CB_CONFIG_SINT
#undef	CB_CONFIG_STRING
#undef	CB_CONFIG_BOOLEAN
#undef	CB_CONFIG_SUPPORT
	putchar ('\t');
	puts (_("where <support> is one of the following:"));
	putchar ('\t');
	/* Note: separated as translators should be able to replace the single quote */
	printf (_("'%s'"), "ok");
	putchar (',');
	putchar (' ');
	printf (_("'%s'"), "warning");
	putchar (',');
	putchar (' ');
	printf (_("'%s'"), "archaic");
	putchar (',');
	putchar (' ');
	printf (_("'%s'"), "obsolete");
	putchar (',');
	putchar (' ');
	printf (_("'%s'"), "skip");
	putchar (',');
	putchar (' ');
	printf (_("'%s'"), "ignore");
	putchar (',');
	putchar (' ');
	printf (_("'%s'"), "error");
	putchar (',');
	putchar (' ');
	printf (_("'%s'"), "unconformable");
	putchar ('\n');
	cobc_print_config_flag ("not-reserved", _("word to be taken out of the reserved words list"), _("<word>"));
	cobc_print_config_flag ("reserved", _("word to be added to reserved words list"), _("<word>"));
	cobc_print_config_flag ("reserved", _("word to be added to reserved words list as alias"), _("<word>:<alias>"));
	cobc_print_config_flag ("not-register", _("special register to disable"), _("<word>"));
	cobc_print_config_flag ("register", _("special register to enable"),
		_("<word> or <word>:<definition>, where definition uses backslash escaped spaces"));
	putchar ('\n');
}