Debian Codegraph @

src/opts.c

raw
1 /* -*- buffer-read-only: t -*- vi: set ro:
2 *
3 * DO NOT EDIT THIS FILE (opts.c)
4 *
5 * It has been AutoGen-ed
6 * From the definitions opts.def
7 * and the template file options
8 *
9 * Generated from AutoOpts 42:2:17 templates.
10 *
11 * AutoOpts is a copyrighted work. This source file is not encumbered
12 * by AutoOpts licensing, but is provided under the licensing terms chosen
13 * by the complexity author or copyright holder. AutoOpts is
14 * licensed under the terms of the LGPL. The redistributable library
15 * (``libopts'') is licensed under the terms of either the LGPL or, at the
16 * users discretion, the BSD license. See the AutoOpts and/or libopts sources
17 * for details.
18 *
19 * The complexity program is copyrighted and licensed
20 * under the following terms:
21 *
22 * Copyright (C) 2011-2020 Bruce Korb, all rights reserved.
23 * This is free software. It is licensed for use, modification and
24 * redistribution under the terms of the GNU General Public License,
25 * version 3 or later <http://gnu.org/licenses/gpl.html>
26 *
27 * complexity is free software: you can redistribute it and/or modify it
28 * under the terms of the GNU General Public License as published by the
29 * Free Software Foundation, either version 3 of the License, or
30 * (at your option) any later version.
31 *
32 * complexity is distributed in the hope that it will be useful, but
33 * WITHOUT ANY WARRANTY; without even the implied warranty of
34 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
35 * See the GNU General Public License for more details.
36 *
37 * You should have received a copy of the GNU General Public License along
38 * with this program. If not, see <http://www.gnu.org/licenses/>.
39 */
40
41 #ifndef __doxygen__
42 #define OPTION_CODE_COMPILE 1
43 #include "opts.h"
44 #include <sys/types.h>
45 #include <sys/stat.h>
46
47 #include <ctype.h>
48 #include <errno.h>
49 #include <fcntl.h>
50 #include <limits.h>
51 #include <stdio.h>
52 #include <stdlib.h>
53 #include <string.h>
54 #include <unistd.h>
55
56 #ifdef __cplusplus
57 extern "C" {
58 #endif
59 extern FILE * option_usage_fp;
60 #define zCopyright (complexity_opt_strs+0)
61 #define zLicenseDescrip (complexity_opt_strs+275)
62
63 /*
64 * global included definitions
65 */
66 score_t penalty = DEFAULT_PENALTY;
67 FILE * trace_fp = NULL;
68 int score_ct = 0;
69 char const assert_fail_fmt[] =
70 "COMPLEX ASSERTION FAILURE in %s line %u: %s\n";
71
72 #ifndef NULL
73 # define NULL 0
74 #endif
75
76 /**
77 * static const strings for complexity options
78 */
79 static char const complexity_opt_strs[2611] =
80 /* 0 */ "complexity (GNU Complexity) 1.13\n"
81 "Copyright (C) 2011-2020 Bruce Korb, all rights reserved.\n"
82 "This is free software. It is licensed for use, modification and\n"
83 "redistribution under the terms of the GNU General Public License,\n"
84 "version 3 or later <http://gnu.org/licenses/gpl.html>\n\0"
85 /* 275 */ "complexity is free software: you can redistribute it and/or modify it under\n"
86 "the terms of the GNU General Public License as published by the Free\n"
87 "Software Foundation, either version 3 of the License, or (at your option)\n"
88 "any later version.\n\n"
89 "complexity is distributed in the hope that it will be useful, but WITHOUT\n"
90 "ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\n"
91 "FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for\n"
92 "more details.\n\n"
93 "You should have received a copy of the GNU General Public License along\n"
94 "with this program. If not, see <http://www.gnu.org/licenses/>.\n\0"
95 /* 884 */ "Reporting threshold\0"
96 /* 904 */ "THRESHOLD\0"
97 /* 914 */ "threshold\0"
98 /* 924 */ "zero exit threshold\0"
99 /* 944 */ "HORRID_THRESHOLD\0"
100 /* 961 */ "horrid-threshold\0"
101 /* 978 */ "score multiplier for nested code\0"
102 /* 1011 */ "NESTING_PENALTY\0"
103 /* 1027 */ "nesting-penalty\0"
104 /* 1043 */ "score multiplier for nested expressions\0"
105 /* 1083 */ "DEMI_NESTING_PENALTY\0"
106 /* 1104 */ "demi-nesting-penalty\0"
107 /* 1125 */ "complexity scaling factor\0"
108 /* 1151 */ "SCALE\0"
109 /* 1157 */ "scale\0"
110 /* 1163 */ "Display histogram of complexity numbers\0"
111 /* 1203 */ "HISTOGRAM\0"
112 /* 1213 */ "no-histogram\0"
113 /* 1226 */ "no\0"
114 /* 1229 */ "Display the score for each procedure\0"
115 /* 1266 */ "SCORES\0"
116 /* 1273 */ "no-scores\0"
117 /* 1283 */ "procedure name to be ignored\0"
118 /* 1312 */ "IGNORE\0"
119 /* 1319 */ "ignore\0"
120 /* 1326 */ "do not print scoring header\0"
121 /* 1354 */ "NO_HEADER\0"
122 /* 1364 */ "no-header\0"
123 /* 1374 */ "Run the source(s) through unifdef(1BSD)\0"
124 /* 1414 */ "UNIFDEF\0"
125 /* 1422 */ "unifdef\0"
126 /* 1430 */ "Specify the unifdef program\0"
127 /* 1458 */ "UNIF_EXE\0"
128 /* 1467 */ "unif-exe\0"
129 /* 1476 */ "file of file list\0"
130 /* 1494 */ "INPUT\0"
131 /* 1500 */ "input\0"
132 /* 1506 */ "trace output file\0"
133 /* 1524 */ "TRACE\0"
134 /* 1530 */ "trace\0"
135 /* 1536 */ "display extended usage information and exit\0"
136 /* 1580 */ "help\0"
137 /* 1585 */ "extended usage information passed thru pager\0"
138 /* 1630 */ "more-help\0"
139 /* 1640 */ "output version information and exit\0"
140 /* 1676 */ "version\0"
141 /* 1684 */ "save the option state to a config file\0"
142 /* 1723 */ "save-opts\0"
143 /* 1733 */ "load options from a config file\0"
144 /* 1765 */ "LOAD_OPTS\0"
145 /* 1775 */ "no-load-opts\0"
146 /* 1788 */ "COMPLEXITY\0"
147 /* 1799 */ "complexity (GNU Complexity) - Measure complexity of C source\n"
148 "Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \\\n"
149 "\t\t[ <file-name> ... ]\n\0"
150 /* 1942 */ "$@/complex.conf\0"
151 /* 1958 */ "$HOME\0"
152 /* 1964 */ "$PROJECT_ROOT/complex.conf\0"
153 /* 1991 */ ".\0"
154 /* 1993 */ ".complexityrc\0"
155 /* 2007 */ "[email protected]\0"
156 /* 2021 */ "Compute the complexity of source code not just with a path-through-the-code\n"
157 "count, but also amplifying line counts by logic level nesting.\n\n"
158 "If no arguments are provided, input arguments are read from stdin,\n"
159 "one per line; blank and '#'-prefixed lines are comments.\n"
160 "'stdin' may not be a terminal (tty).\n\0"
161 /* 2323 */ "'complexity' ignores all cpp preprocessor directives - calculating the\n"
162 "complexity of the appearance of the code, rather than the complexity after\n"
163 "the preprocessor manipulates the code. 'getchar(3)', for example, will\n"
164 "expand into quite complicated code.\n\0"
165 /* 2578 */ "complexity (GNU Complexity) 1.13";
166
167 /**
168 * threshold option description:
169 */
170 /** Descriptive text for the threshold option */
171 #define THRESHOLD_DESC (complexity_opt_strs+884)
172 /** Upper-cased name for the threshold option */
173 #define THRESHOLD_NAME (complexity_opt_strs+904)
174 /** Name string for the threshold option */
175 #define THRESHOLD_name (complexity_opt_strs+914)
176 /** The compiled in default value for the threshold option argument */
177 #define THRESHOLD_DFT_ARG ((char const*)30)
178 /** Compiled in flag settings for the threshold option */
179 #define THRESHOLD_FLAGS (OPTST_DISABLED \
180 | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
181
182 /**
183 * horrid-threshold option description:
184 */
185 /** Descriptive text for the horrid-threshold option */
186 #define HORRID_THRESHOLD_DESC (complexity_opt_strs+924)
187 /** Upper-cased name for the horrid-threshold option */
188 #define HORRID_THRESHOLD_NAME (complexity_opt_strs+944)
189 /** Name string for the horrid-threshold option */
190 #define HORRID_THRESHOLD_name (complexity_opt_strs+961)
191 /** The compiled in default value for the horrid-threshold option argument */
192 #define HORRID_THRESHOLD_DFT_ARG ((char const*)100)
193 /** Compiled in flag settings for the horrid-threshold option */
194 #define HORRID_THRESHOLD_FLAGS (OPTST_DISABLED \
195 | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
196
197 /**
198 * nesting-penalty option description:
199 */
200 /** Descriptive text for the nesting-penalty option */
201 #define NESTING_PENALTY_DESC (complexity_opt_strs+978)
202 /** Upper-cased name for the nesting-penalty option */
203 #define NESTING_PENALTY_NAME (complexity_opt_strs+1011)
204 /** Name string for the nesting-penalty option */
205 #define NESTING_PENALTY_name (complexity_opt_strs+1027)
206 /** Compiled in flag settings for the nesting-penalty option */
207 #define NESTING_PENALTY_FLAGS (OPTST_DISABLED \
208 | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
209
210 /**
211 * demi-nesting-penalty option description:
212 */
213 /** Descriptive text for the demi-nesting-penalty option */
214 #define DEMI_NESTING_PENALTY_DESC (complexity_opt_strs+1043)
215 /** Upper-cased name for the demi-nesting-penalty option */
216 #define DEMI_NESTING_PENALTY_NAME (complexity_opt_strs+1083)
217 /** Name string for the demi-nesting-penalty option */
218 #define DEMI_NESTING_PENALTY_name (complexity_opt_strs+1104)
219 /** Compiled in flag settings for the demi-nesting-penalty option */
220 #define DEMI_NESTING_PENALTY_FLAGS (OPTST_DISABLED \
221 | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
222
223 /**
224 * scale option description:
225 */
226 /** Descriptive text for the scale option */
227 #define SCALE_DESC (complexity_opt_strs+1125)
228 /** Upper-cased name for the scale option */
229 #define SCALE_NAME (complexity_opt_strs+1151)
230 /** Name string for the scale option */
231 #define SCALE_name (complexity_opt_strs+1157)
232 /** Compiled in flag settings for the scale option */
233 #define SCALE_FLAGS (OPTST_DISABLED \
234 | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
235
236 /**
237 * histogram option description:
238 */
239 /** Descriptive text for the histogram option */
240 #define HISTOGRAM_DESC (complexity_opt_strs+1163)
241 /** Upper-cased name for the histogram option */
242 #define HISTOGRAM_NAME (complexity_opt_strs+1203)
243 /** disablement name for the histogram option */
244 #define NOT_HISTOGRAM_name (complexity_opt_strs+1213)
245 /** disablement prefix for the histogram option */
246 #define NOT_HISTOGRAM_PFX (complexity_opt_strs+1226)
247 /** Name string for the histogram option */
248 #define HISTOGRAM_name (NOT_HISTOGRAM_name + 3)
249 /** Compiled in flag settings for the histogram option */
250 #define HISTOGRAM_FLAGS (OPTST_DISABLED | OPTST_NO_INIT)
251
252 /**
253 * scores option description:
254 */
255 /** Descriptive text for the scores option */
256 #define SCORES_DESC (complexity_opt_strs+1229)
257 /** Upper-cased name for the scores option */
258 #define SCORES_NAME (complexity_opt_strs+1266)
259 /** disablement name for the scores option */
260 #define NOT_SCORES_name (complexity_opt_strs+1273)
261 /** disablement prefix for the scores option */
262 #define NOT_SCORES_PFX (complexity_opt_strs+1226)
263 /** Name string for the scores option */
264 #define SCORES_name (NOT_SCORES_name + 3)
265 /** Compiled in flag settings for the scores option */
266 #define SCORES_FLAGS (OPTST_DISABLED | OPTST_NO_INIT)
267
268 /**
269 * ignore option description:
270 */
271 /** Descriptive text for the ignore option */
272 #define IGNORE_DESC (complexity_opt_strs+1283)
273 /** Upper-cased name for the ignore option */
274 #define IGNORE_NAME (complexity_opt_strs+1312)
275 /** Name string for the ignore option */
276 #define IGNORE_name (complexity_opt_strs+1319)
277 /** Compiled in flag settings for the ignore option */
278 #define IGNORE_FLAGS (OPTST_DISABLED | OPTST_STACKED \
279 | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
280
281 /**
282 * no-header option description:
283 */
284 /** Descriptive text for the no-header option */
285 #define NO_HEADER_DESC (complexity_opt_strs+1326)
286 /** Upper-cased name for the no-header option */
287 #define NO_HEADER_NAME (complexity_opt_strs+1354)
288 /** Name string for the no-header option */
289 #define NO_HEADER_name (complexity_opt_strs+1364)
290 /** Compiled in flag settings for the no-header option */
291 #define NO_HEADER_FLAGS (OPTST_DISABLED | OPTST_NO_INIT)
292
293 /**
294 * unifdef option description:
295 */
296 /** Descriptive text for the unifdef option */
297 #define UNIFDEF_DESC (complexity_opt_strs+1374)
298 /** Upper-cased name for the unifdef option */
299 #define UNIFDEF_NAME (complexity_opt_strs+1414)
300 /** Name string for the unifdef option */
301 #define UNIFDEF_name (complexity_opt_strs+1422)
302 /** Compiled in flag settings for the unifdef option */
303 #define UNIFDEF_FLAGS (OPTST_DISABLED | OPTST_STACKED \
304 | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
305
306 /**
307 * unif-exe option description:
308 */
309 /** Descriptive text for the unif-exe option */
310 #define UNIF_EXE_DESC (complexity_opt_strs+1430)
311 /** Upper-cased name for the unif-exe option */
312 #define UNIF_EXE_NAME (complexity_opt_strs+1458)
313 /** Name string for the unif-exe option */
314 #define UNIF_EXE_name (complexity_opt_strs+1467)
315 /** Compiled in flag settings for the unif-exe option */
316 #define UNIF_EXE_FLAGS (OPTST_DISABLED \
317 | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
318
319 /**
320 * input option description:
321 */
322 /** Descriptive text for the input option */
323 #define INPUT_DESC (complexity_opt_strs+1476)
324 /** Upper-cased name for the input option */
325 #define INPUT_NAME (complexity_opt_strs+1494)
326 /** Name string for the input option */
327 #define INPUT_name (complexity_opt_strs+1500)
328 /** Compiled in flag settings for the input option */
329 #define INPUT_FLAGS (OPTST_DISABLED \
330 | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
331
332 /**
333 * trace option description:
334 */
335 /** Descriptive text for the trace option */
336 #define TRACE_DESC (complexity_opt_strs+1506)
337 /** Upper-cased name for the trace option */
338 #define TRACE_NAME (complexity_opt_strs+1524)
339 /** Name string for the trace option */
340 #define TRACE_name (complexity_opt_strs+1530)
341 /** Compiled in flag settings for the trace option */
342 #define TRACE_FLAGS (OPTST_DISABLED \
343 | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
344
345 /*
346 * Help/More_Help/Version option descriptions:
347 */
348 #define HELP_DESC (complexity_opt_strs+1536)
349 #define HELP_name (complexity_opt_strs+1580)
350 #ifdef HAVE_WORKING_FORK
351 #define MORE_HELP_DESC (complexity_opt_strs+1585)
352 #define MORE_HELP_name (complexity_opt_strs+1630)
353 #define MORE_HELP_FLAGS (OPTST_IMM | OPTST_NO_INIT)
354 #else
355 #define MORE_HELP_DESC HELP_DESC
356 #define MORE_HELP_name HELP_name
357 #define MORE_HELP_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
358 #endif
359 #ifdef NO_OPTIONAL_OPT_ARGS
360 # define VER_FLAGS (OPTST_IMM | OPTST_NO_INIT)
361 #else
362 # define VER_FLAGS (OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \
363 OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT)
364 #endif
365 #define VER_DESC (complexity_opt_strs+1640)
366 #define VER_name (complexity_opt_strs+1676)
367 #define SAVE_OPTS_DESC (complexity_opt_strs+1684)
368 #define SAVE_OPTS_name (complexity_opt_strs+1723)
369 #define LOAD_OPTS_DESC (complexity_opt_strs+1733)
370 #define LOAD_OPTS_NAME (complexity_opt_strs+1765)
371 #define NO_LOAD_OPTS_name (complexity_opt_strs+1775)
372 #define LOAD_OPTS_pfx (complexity_opt_strs+1226)
373 #define LOAD_OPTS_name (NO_LOAD_OPTS_name + 3)
374 /**
375 * Declare option callback procedures
376 */
377 extern tOptProc
378 optionBooleanVal, optionNestedVal, optionNumericVal,
379 optionPagedUsage, optionPrintVersion, optionResetOpt,
380 optionStackArg, optionTimeDate, optionTimeVal,
381 optionUnstackArg, optionVendorOption;
382 static tOptProc
383 doOptInput, doOptTrace, doUsageOpt;
384 #define VER_PROC optionPrintVersion
385
386 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
387 /**
388 * Define the complexity Option Descriptions.
389 * This is an array of OPTION_CT entries, one for each
390 * option that the complexity program responds to.
391 */
392 static tOptDesc optDesc[OPTION_CT] = {
393 { /* entry idx, value */ 0, VALUE_OPT_THRESHOLD,
394 /* equiv idx, value */ 0, VALUE_OPT_THRESHOLD,
395 /* equivalenced to */ NO_EQUIVALENT,
396 /* min, max, act ct */ 0, 1, 0,
397 /* opt state flags */ THRESHOLD_FLAGS, 0,
398 /* last opt argumnt */ { THRESHOLD_DFT_ARG },
399 /* arg list/cookie */ NULL,
400 /* must/cannot opts */ NULL, NULL,
401 /* option proc */ optionNumericVal,
402 /* desc, NAME, name */ THRESHOLD_DESC, THRESHOLD_NAME, THRESHOLD_name,
403 /* disablement strs */ NULL, NULL },
404
405 { /* entry idx, value */ 1, VALUE_OPT_HORRID_THRESHOLD,
406 /* equiv idx, value */ 1, VALUE_OPT_HORRID_THRESHOLD,
407 /* equivalenced to */ NO_EQUIVALENT,
408 /* min, max, act ct */ 0, 1, 0,
409 /* opt state flags */ HORRID_THRESHOLD_FLAGS, 0,
410 /* last opt argumnt */ { HORRID_THRESHOLD_DFT_ARG },
411 /* arg list/cookie */ NULL,
412 /* must/cannot opts */ NULL, NULL,
413 /* option proc */ optionNumericVal,
414 /* desc, NAME, name */ HORRID_THRESHOLD_DESC, HORRID_THRESHOLD_NAME, HORRID_THRESHOLD_name,
415 /* disablement strs */ NULL, NULL },
416
417 { /* entry idx, value */ 2, VALUE_OPT_NESTING_PENALTY,
418 /* equiv idx, value */ 2, VALUE_OPT_NESTING_PENALTY,
419 /* equivalenced to */ NO_EQUIVALENT,
420 /* min, max, act ct */ 0, 1, 0,
421 /* opt state flags */ NESTING_PENALTY_FLAGS, 0,
422 /* last opt argumnt */ { NULL }, /* --nesting-penalty */
423 /* arg list/cookie */ NULL,
424 /* must/cannot opts */ NULL, NULL,
425 /* option proc */ NULL,
426 /* desc, NAME, name */ NESTING_PENALTY_DESC, NESTING_PENALTY_NAME, NESTING_PENALTY_name,
427 /* disablement strs */ NULL, NULL },
428
429 { /* entry idx, value */ 3, VALUE_OPT_DEMI_NESTING_PENALTY,
430 /* equiv idx, value */ 3, VALUE_OPT_DEMI_NESTING_PENALTY,
431 /* equivalenced to */ NO_EQUIVALENT,
432 /* min, max, act ct */ 0, 1, 0,
433 /* opt state flags */ DEMI_NESTING_PENALTY_FLAGS, 0,
434 /* last opt argumnt */ { NULL }, /* --demi-nesting-penalty */
435 /* arg list/cookie */ NULL,
436 /* must/cannot opts */ NULL, NULL,
437 /* option proc */ NULL,
438 /* desc, NAME, name */ DEMI_NESTING_PENALTY_DESC, DEMI_NESTING_PENALTY_NAME, DEMI_NESTING_PENALTY_name,
439 /* disablement strs */ NULL, NULL },
440
441 { /* entry idx, value */ 4, VALUE_OPT_SCALE,
442 /* equiv idx, value */ 4, VALUE_OPT_SCALE,
443 /* equivalenced to */ NO_EQUIVALENT,
444 /* min, max, act ct */ 0, 1, 0,
445 /* opt state flags */ SCALE_FLAGS, 0,
446 /* last opt argumnt */ { NULL }, /* --scale */
447 /* arg list/cookie */ NULL,
448 /* must/cannot opts */ NULL, NULL,
449 /* option proc */ optionNumericVal,
450 /* desc, NAME, name */ SCALE_DESC, SCALE_NAME, SCALE_name,
451 /* disablement strs */ NULL, NULL },
452
453 { /* entry idx, value */ 5, VALUE_OPT_HISTOGRAM,
454 /* equiv idx, value */ 5, VALUE_OPT_HISTOGRAM,
455 /* equivalenced to */ NO_EQUIVALENT,
456 /* min, max, act ct */ 0, 1, 0,
457 /* opt state flags */ HISTOGRAM_FLAGS, 0,
458 /* last opt argumnt */ { NULL }, /* --histogram */
459 /* arg list/cookie */ NULL,
460 /* must/cannot opts */ NULL, NULL,
461 /* option proc */ NULL,
462 /* desc, NAME, name */ HISTOGRAM_DESC, HISTOGRAM_NAME, HISTOGRAM_name,
463 /* disablement strs */ NOT_HISTOGRAM_name, NOT_HISTOGRAM_PFX },
464
465 { /* entry idx, value */ 6, VALUE_OPT_SCORES,
466 /* equiv idx, value */ 6, VALUE_OPT_SCORES,
467 /* equivalenced to */ NO_EQUIVALENT,
468 /* min, max, act ct */ 0, 1, 0,
469 /* opt state flags */ SCORES_FLAGS, 0,
470 /* last opt argumnt */ { NULL }, /* --scores */
471 /* arg list/cookie */ NULL,
472 /* must/cannot opts */ NULL, NULL,
473 /* option proc */ NULL,
474 /* desc, NAME, name */ SCORES_DESC, SCORES_NAME, SCORES_name,
475 /* disablement strs */ NOT_SCORES_name, NOT_SCORES_PFX },
476
477 { /* entry idx, value */ 7, VALUE_OPT_IGNORE,
478 /* equiv idx, value */ 7, VALUE_OPT_IGNORE,
479 /* equivalenced to */ NO_EQUIVALENT,
480 /* min, max, act ct */ 0, NOLIMIT, 0,
481 /* opt state flags */ IGNORE_FLAGS, 0,
482 /* last opt argumnt */ { NULL }, /* --ignore */
483 /* arg list/cookie */ NULL,
484 /* must/cannot opts */ NULL, NULL,
485 /* option proc */ optionStackArg,
486 /* desc, NAME, name */ IGNORE_DESC, IGNORE_NAME, IGNORE_name,
487 /* disablement strs */ NULL, NULL },
488
489 { /* entry idx, value */ 8, VALUE_OPT_NO_HEADER,
490 /* equiv idx, value */ 8, VALUE_OPT_NO_HEADER,
491 /* equivalenced to */ NO_EQUIVALENT,
492 /* min, max, act ct */ 0, 1, 0,
493 /* opt state flags */ NO_HEADER_FLAGS, 0,
494 /* last opt argumnt */ { NULL }, /* --no-header */
495 /* arg list/cookie */ NULL,
496 /* must/cannot opts */ NULL, NULL,
497 /* option proc */ NULL,
498 /* desc, NAME, name */ NO_HEADER_DESC, NO_HEADER_NAME, NO_HEADER_name,
499 /* disablement strs */ NULL, NULL },
500
501 { /* entry idx, value */ 9, VALUE_OPT_UNIFDEF,
502 /* equiv idx, value */ 9, VALUE_OPT_UNIFDEF,
503 /* equivalenced to */ NO_EQUIVALENT,
504 /* min, max, act ct */ 0, NOLIMIT, 0,
505 /* opt state flags */ UNIFDEF_FLAGS, 0,
506 /* last opt argumnt */ { NULL }, /* --unifdef */
507 /* arg list/cookie */ NULL,
508 /* must/cannot opts */ NULL, NULL,
509 /* option proc */ optionStackArg,
510 /* desc, NAME, name */ UNIFDEF_DESC, UNIFDEF_NAME, UNIFDEF_name,
511 /* disablement strs */ NULL, NULL },
512
513 { /* entry idx, value */ 10, VALUE_OPT_UNIF_EXE,
514 /* equiv idx, value */ 10, VALUE_OPT_UNIF_EXE,
515 /* equivalenced to */ NO_EQUIVALENT,
516 /* min, max, act ct */ 0, 1, 0,
517 /* opt state flags */ UNIF_EXE_FLAGS, 0,
518 /* last opt argumnt */ { NULL }, /* --unif-exe */
519 /* arg list/cookie */ NULL,
520 /* must/cannot opts */ NULL, NULL,
521 /* option proc */ NULL,
522 /* desc, NAME, name */ UNIF_EXE_DESC, UNIF_EXE_NAME, UNIF_EXE_name,
523 /* disablement strs */ NULL, NULL },
524
525 { /* entry idx, value */ 11, VALUE_OPT_INPUT,
526 /* equiv idx, value */ 11, VALUE_OPT_INPUT,
527 /* equivalenced to */ NO_EQUIVALENT,
528 /* min, max, act ct */ 0, 1, 0,
529 /* opt state flags */ INPUT_FLAGS, 0,
530 /* last opt argumnt */ { NULL }, /* --input */
531 /* arg list/cookie */ NULL,
532 /* must/cannot opts */ NULL, NULL,
533 /* option proc */ doOptInput,
534 /* desc, NAME, name */ INPUT_DESC, INPUT_NAME, INPUT_name,
535 /* disablement strs */ NULL, NULL },
536
537 { /* entry idx, value */ 12, VALUE_OPT_TRACE,
538 /* equiv idx, value */ 12, VALUE_OPT_TRACE,
539 /* equivalenced to */ NO_EQUIVALENT,
540 /* min, max, act ct */ 0, 1, 0,
541 /* opt state flags */ TRACE_FLAGS, 0,
542 /* last opt argumnt */ { NULL }, /* --trace */
543 /* arg list/cookie */ NULL,
544 /* must/cannot opts */ NULL, NULL,
545 /* option proc */ doOptTrace,
546 /* desc, NAME, name */ TRACE_DESC, TRACE_NAME, TRACE_name,
547 /* disablement strs */ NULL, NULL },
548
549 { /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION,
550 /* equiv idx value */ NO_EQUIVALENT, VALUE_OPT_VERSION,
551 /* equivalenced to */ NO_EQUIVALENT,
552 /* min, max, act ct */ 0, 1, 0,
553 /* opt state flags */ VER_FLAGS, AOUSE_VERSION,
554 /* last opt argumnt */ { NULL },
555 /* arg list/cookie */ NULL,
556 /* must/cannot opts */ NULL, NULL,
557 /* option proc */ VER_PROC,
558 /* desc, NAME, name */ VER_DESC, NULL, VER_name,
559 /* disablement strs */ NULL, NULL },
560
561
562
563 { /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP,
564 /* equiv idx value */ NO_EQUIVALENT, VALUE_OPT_HELP,
565 /* equivalenced to */ NO_EQUIVALENT,
566 /* min, max, act ct */ 0, 1, 0,
567 /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, AOUSE_HELP,
568 /* last opt argumnt */ { NULL },
569 /* arg list/cookie */ NULL,
570 /* must/cannot opts */ NULL, NULL,
571 /* option proc */ doUsageOpt,
572 /* desc, NAME, name */ HELP_DESC, NULL, HELP_name,
573 /* disablement strs */ NULL, NULL },
574
575 { /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP,
576 /* equiv idx value */ NO_EQUIVALENT, VALUE_OPT_MORE_HELP,
577 /* equivalenced to */ NO_EQUIVALENT,
578 /* min, max, act ct */ 0, 1, 0,
579 /* opt state flags */ MORE_HELP_FLAGS, AOUSE_MORE_HELP,
580 /* last opt argumnt */ { NULL },
581 /* arg list/cookie */ NULL,
582 /* must/cannot opts */ NULL, NULL,
583 /* option proc */ optionPagedUsage,
584 /* desc, NAME, name */ MORE_HELP_DESC, NULL, MORE_HELP_name,
585 /* disablement strs */ NULL, NULL },
586
587 { /* entry idx, value */ INDEX_OPT_SAVE_OPTS, VALUE_OPT_SAVE_OPTS,
588 /* equiv idx value */ NO_EQUIVALENT, VALUE_OPT_SAVE_OPTS,
589 /* equivalenced to */ NO_EQUIVALENT,
590 /* min, max, act ct */ 0, 1, 0,
591 /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)
592 | OPTST_ARG_OPTIONAL | OPTST_NO_INIT, AOUSE_SAVE_OPTS,
593 /* last opt argumnt */ { NULL },
594 /* arg list/cookie */ NULL,
595 /* must/cannot opts */ NULL, NULL,
596 /* option proc */ NULL,
597 /* desc, NAME, name */ SAVE_OPTS_DESC, NULL, SAVE_OPTS_name,
598 /* disablement strs */ NULL, NULL },
599
600 { /* entry idx, value */ INDEX_OPT_LOAD_OPTS, VALUE_OPT_LOAD_OPTS,
601 /* equiv idx value */ NO_EQUIVALENT, VALUE_OPT_LOAD_OPTS,
602 /* equivalenced to */ NO_EQUIVALENT,
603 /* min, max, act ct */ 0, NOLIMIT, 0,
604 /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)
605 | OPTST_DISABLE_IMM, AOUSE_LOAD_OPTS,
606 /* last opt argumnt */ { NULL },
607 /* arg list/cookie */ NULL,
608 /* must/cannot opts */ NULL, NULL,
609 /* option proc */ optionLoadOpt,
610 /* desc, NAME, name */ LOAD_OPTS_DESC, LOAD_OPTS_NAME, LOAD_OPTS_name,
611 /* disablement strs */ NO_LOAD_OPTS_name, LOAD_OPTS_pfx }
612 };
613
614
615 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
616 /** Reference to the upper cased version of complexity. */
617 #define zPROGNAME (complexity_opt_strs+1788)
618 /** Reference to the title line for complexity usage. */
619 #define zUsageTitle (complexity_opt_strs+1799)
620 /** complexity configuration file name. */
621 #define zRcName (complexity_opt_strs+1993)
622 /** Directories to search for complexity config files. */
623 static char const * const apzHomeList[5] = {
624 complexity_opt_strs+1942,
625 complexity_opt_strs+1958,
626 complexity_opt_strs+1964,
627 complexity_opt_strs+1991,
628 NULL };
629 /** The complexity program bug email address. */
630 #define zBugsAddr (complexity_opt_strs+2007)
631 /** Clarification/explanation of what complexity does. */
632 #define zExplain (complexity_opt_strs+2021)
633 /** Extra detail explaining what complexity does. */
634 #define zDetail (complexity_opt_strs+2323)
635 /** The full version string for complexity. */
636 #define zFullVersion (complexity_opt_strs+2578)
637 /* extracted from optcode.tlib near line 342 */
638
639 #if defined(ENABLE_NLS)
640 # define OPTPROC_BASE OPTPROC_TRANSLATE
641 static tOptionXlateProc translate_option_strings;
642 #else
643 # define OPTPROC_BASE OPTPROC_NONE
644 # define translate_option_strings NULL
645 #endif /* ENABLE_NLS */
646
647 #define complexity_full_usage (NULL)
648 #define complexity_short_usage (NULL)
649
650 #endif /* not defined __doxygen__ */
651
652 /*
653 * Create the static procedure(s) declared above.
654 */
655 /**
656 * The callout function that invokes the optionUsage function.
657 *
658 * @param[in] opts the AutoOpts option description structure
659 * @param[in] od the descriptor for the "help" (usage) option.
660 * @noreturn
661 */
662 static void
663 doUsageOpt(tOptions * opts, tOptDesc * od)
664 {
665 int ex_code;
666 ex_code = COMPLEXITY_EXIT_SUCCESS;
667 optionUsage(&complexityOptions, ex_code);
668 /* NOTREACHED */
669 exit(COMPLEXITY_EXIT_FAILURE);
670 (void)opts;
671 (void)od;
672 }
673
674 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
675 /**
676 * Code to handle the input option.
677 * Instead of either a command line list of input files or reading
678 * them from standard input, read the list of files from this file.
679 * @param[in] pOptions the complexity options data structure
680 * @param[in,out] pOptDesc the option descriptor for this option.
681 */
682 static void
683 doOptInput(tOptions* pOptions, tOptDesc* pOptDesc)
684 {
685 /*
686 * Be sure the flag-code[0] handles special values for the options pointer
687 * viz. (poptions <= OPTPROC_EMIT_LIMIT) *and also* the special flag bit
688 * ((poptdesc->fOptState & OPTST_RESET) != 0) telling the option to
689 * reset its state.
690 */
691 /* extracted from opts.def, line 317 */
692 FILE * fp = freopen(pOptDesc->optArg.argString, "r", stdin);
693 if (fp != stdin) {
694 fprintf(stderr, "fs error %d (%s) reopening %s as stdin\n",
695 errno, strerror(errno), pOptDesc->optArg.argString);
696 exit(COMPLEXITY_EXIT_BAD_FILE);
697 }
698 (void)pOptions;
699 }
700
701 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
702 /**
703 * Code to handle the trace option.
704 * Print intermediate scores to a trace file.
705 * @param[in] pOptions the complexity options data structure
706 * @param[in,out] pOptDesc the option descriptor for this option.
707 */
708 static void
709 doOptTrace(tOptions* pOptions, tOptDesc* pOptDesc)
710 {
711 /*
712 * Be sure the flag-code[0] handles special values for the options pointer
713 * viz. (poptions <= OPTPROC_EMIT_LIMIT) *and also* the special flag bit
714 * ((poptdesc->fOptState & OPTST_RESET) != 0) telling the option to
715 * reset its state.
716 */
717 /* extracted from opts.def, line 337 */
718 trace_fp = fopen(pOptDesc->optArg.argString, "w");
719 if (trace_fp == NULL) {
720 fprintf(stderr, "fs error %d (%s) opening %s for tracing\n",
721 errno, strerror(errno), pOptDesc->optArg.argString);
722 exit(COMPLEXITY_EXIT_BAD_FILE);
723 }
724 (void)pOptions;
725 }
726 /* extracted from optmain.tlib near line 116 */
727
728
729 extern int complex_eval(char const * fname);
730 /* extracted from optmain.tlib near line 204 */
731
732 /**
733 * validate file name and dispach callout procedure.
734 * This procedure is generated by AutoOpts.
735 * It will make sure that the input file name refers to a file
736 * that exists.
737 *
738 * @param fname the name of the file to process
739 * @returns program exit code flag
740 */
741 static complexity_exit_code_t
742 validate_fname(char const * fname)
743 {
744 static char const * err_str = NULL;
745
746 if (err_str == NULL)
747 err_str = _("fs error %d (%s) %s-ing %s\n");
748 {
749 struct stat sb;
750 if (stat(fname, &sb) < 0) {
751 fprintf(stderr, err_str, errno, strerror(errno), "stat",
752 fname);
753 return COMPLEXITY_EXIT_BAD_FILE;
754 }
755 }
756 /* extracted from optmain.tlib near line 291 */
757
758
759 return complex_eval(fname);
760 }
761 /* extracted from optmain.tlib near line 131 */
762
763 /**
764 * strip (destructively) the leading and trailing white space.
765 * Trailing white space is trimmed with a NUL byte.
766 * The returned address is that of the first character after the
767 * leading white space. Characters are not moved.
768 *
769 * @param[in,out] pz_s source text pointer
770 * @returns pointer to the same text buffer, but after skipping over the
771 * leading white space characters.
772 */
773 static char *
774 trim_input_line(char * src_str)
775 {
776 while ((unsigned int)isspace(*src_str))
777 src_str++;
778
779 {
780 char * end = src_str + strlen(src_str);
781 while ((end > src_str) && isspace((unsigned int)end[-1]))
782 end--;
783 *end = '\0';
784 }
785
786 switch (*src_str) {
787 case '\0':
788 case '#':
789 return NULL;
790 default:
791 return src_str;
792 }
793 }
794
795 /**
796 * Generated main procedure. This will call the validate_fname procedure
797 * for every operand on the command line. If there are no operands, then stdin
798 * is read for a list of file names to process. stdin must not be a terminal.
799 * It must be a pipe or a file.
800 *
801 * @param[in] argc argument count
802 * @param[in] argv argument vector
803 * @returns program exit code
804 */
805 int
806 main(int argc, char ** argv)
807 {
808 int res = 0;
809 int proc_ct = 0;
810 int arg_ix = optionProcess(&complexityOptions, argc, argv);
811
812 /* extracted from opts.def near line 87 */
813
814 initialize(argc, argv);
815 /* extracted from optmain.tlib near line 160 */
816
817 /*
818 * IF the input list is from the command line...
819 */
820 if (arg_ix < argc) {
821 for (; arg_ix < argc; arg_ix++) {
822 char * arg = argv[arg_ix];
823 res |= validate_fname(arg);
824 proc_ct++;
825 }
826 }
827 /*
828 * Input list from tty input
829 */
830 else if (isatty(STDIN_FILENO)) {
831 fputs(_("complexity ERROR: input list is a tty\n"), stderr);
832 USAGE(COMPLEXITY_EXIT_BAD_FILE);
833 /* NOTREACHED */
834 }
835
836 /*
837 * Input list from a pipe or file or some such
838 */
839 else {
840 long pg_size = sysconf(_SC_PAGESIZE);
841 char * buf = malloc((size_t)pg_size);
842 if (buf == NULL) {
843 fputs(_("complexity ERROR: no memory for input list\n"), stderr);
844 return COMPLEXITY_EXIT_NOMEM;
845 }
846
847 for (;;) {
848 char * pz = fgets(buf, (ssize_t)pg_size, stdin);
849 if (pz == NULL)
850 break;
851
852 pz = trim_input_line(pz);
853 if (pz == NULL)
854 continue;
855 res |= validate_fname(pz);
856 proc_ct++;
857 }
858
859 if (proc_ct == 0)
860 fputs(_("complexity Warning: no input lines were read\n"), stderr);
861 free(buf);
862 }
863
864
865 /* extracted from opts.def near line 89 */
866
867 if (score_ct == 0) {
868 printf("No procedures were scored\n");
869 exit(res | COMPLEXITY_EXIT_NO_DATA);
870 }
871 do_summary(res);
872 return res;
873 }
874 /* extracted from optmain.tlib near line 1250 */
875
876 /**
877 * Print a fatal error message and die, \a va_list style.
878 *
879 * @param[in] exit_code the value to call exit(3) with
880 * @param[in] fmt the death rattle message
881 * @param[in] ap the argument list for the message
882 * @noreturn
883 */
884 noreturn extern void
885 vdie(int exit_code, char const * fmt, va_list ap)
886 {
887 char const * die_leader = _("complexity fatal error:\n");
888 fputs(die_leader, stderr);
889 vfprintf(stderr, fmt, ap);
890 fflush(stderr);
891 exit(exit_code);
892 }
893
894 /**
895 * Print a fatal error message and die, var-arg style.
896 *
897 * @param[in] exit_code the value to call exit(3) with
898 * @param[in] fmt the death rattle message
899 * @param[in] ... the list of arguments for the message
900 * @noreturn
901 */
902 noreturn extern void
903 die(int exit_code, char const * fmt, ...)
904 {
905 va_list ap;
906 va_start(ap, fmt);
907 vdie(exit_code, fmt, ap);
908 }
909
910 /**
911 * Print a file system error fatal error message and die.
912 *
913 * @param[in] exit_code the value to call exit(3) with.
914 * @param[in] op the operation that failed.
915 * @param[in] fname the file name the operation was on.
916 * @noreturn
917 */
918 noreturn extern void
919 fserr(int exit_code, char const * op, char const * fname)
920 {
921 char const * fserr_fmt = _("fserr %d (%s) performing '%s' on %s\n");
922 die(exit_code, fserr_fmt, errno, strerror(errno), op, fname);
923 }
924
925 /**
926 * The directory containing the data associated with complexity.
927 */
928 #ifndef PKGDATADIR
929 # define PKGDATADIR ""
930 #endif
931
932 /**
933 * Information about the person or institution that packaged complexity
934 * for the current distribution.
935 */
936 #ifndef WITH_PACKAGER
937 # define complexity_packager_info NULL
938 #else
939 /** Packager information for complexity. */
940 static char const complexity_packager_info[] =
941 "Packaged by " WITH_PACKAGER
942
943 # ifdef WITH_PACKAGER_VERSION
944 " ("WITH_PACKAGER_VERSION")"
945 # endif
946
947 # ifdef WITH_PACKAGER_BUG_REPORTS
948 "\nReport complexity bugs to " WITH_PACKAGER_BUG_REPORTS
949 # endif
950 "\n";
951 #endif
952 #ifndef __doxygen__
953
954 #endif /* __doxygen__ */
955 /**
956 * The option definitions for complexity. The one structure that
957 * binds them all.
958 */
959 tOptions complexityOptions = {
960 OPTIONS_STRUCT_VERSION,
961 0, NULL, /* original argc + argv */
962 ( OPTPROC_BASE
963 + OPTPROC_ERRSTOP
964 + OPTPROC_SHORTOPT
965 + OPTPROC_LONGOPT
966 + OPTPROC_NO_REQ_OPT
967 + OPTPROC_NEGATIONS
968 + OPTPROC_ENVIRON
969 + OPTPROC_GNUUSAGE ),
970 0, NULL, /* current option index, current option */
971 NULL, NULL, zPROGNAME,
972 zRcName, zCopyright, zLicenseDescrip,
973 zFullVersion, apzHomeList, zUsageTitle,
974 zExplain, zDetail, optDesc,
975 zBugsAddr, /* address to send bugs to */
976 NULL, NULL, /* extensions/saved state */
977 optionUsage, /* usage procedure */
978 translate_option_strings, /* translation procedure */
979 /*
980 * Indexes to special options
981 */
982 { INDEX_OPT_MORE_HELP, /* more-help option index */
983 INDEX_OPT_SAVE_OPTS, /* save option index */
984 NO_EQUIVALENT, /* '-#' option index */
985 NO_EQUIVALENT /* index of default opt */
986 },
987 18 /* full option count */, 13 /* user option count */,
988 complexity_full_usage, complexity_short_usage,
989 NULL, NULL,
990 PKGDATADIR, complexity_packager_info
991 };
992
993 #if ENABLE_NLS
994 /**
995 * This code is designed to translate translatable option text for the
996 * complexity program. These translations happen upon entry
997 * to optionProcess().
998 */
999 #include <stdio.h>
1000 #include <stdlib.h>
1001 #include <string.h>
1002 #include <unistd.h>
1003 #ifdef HAVE_DCGETTEXT
1004 # include <gettext.h>
1005 #endif
1006 #include <autoopts/usage-txt.h>
1007
1008 static char * AO_gettext(char const * pz);
1009 static void coerce_it(void ** s);
1010
1011 /**
1012 * AutoGen specific wrapper function for gettext. It relies on the macro _()
1013 * to convert from English to the target language, then strdup-duplicates the
1014 * result string. It tries the "libopts" domain first, then whatever has been
1015 * set via the \a textdomain(3) call.
1016 *
1017 * @param[in] pz the input text used as a lookup key.
1018 * @returns the translated text (if there is one),
1019 * or the original text (if not).
1020 */
1021 static char *
1022 AO_gettext(char const * pz)
1023 {
1024 char * res;
1025 if (pz == NULL)
1026 return NULL;
1027 #ifdef HAVE_DCGETTEXT
1028 /*
1029 * While processing the option_xlateable_txt data, try to use the
1030 * "libopts" domain. Once we switch to the option descriptor data,
1031 * do *not* use that domain.
1032 */
1033 if (option_xlateable_txt.field_ct != 0) {
1034 res = dgettext("libopts", pz);
1035 if (res == pz)
1036 res = (char *)VOIDP(_(pz));
1037 } else
1038 res = (char *)VOIDP(_(pz));
1039 #else
1040 res = (char *)VOIDP(_(pz));
1041 #endif
1042 if (res == pz)
1043 return res;
1044 res = strdup(res);
1045 if (res == NULL) {
1046 fputs(_("No memory for duping translated strings\n"), stderr);
1047 exit(COMPLEXITY_EXIT_NOMEM);
1048 }
1049 return res;
1050 }
1051
1052 /**
1053 * All the pointers we use are marked "* const", but they are stored in
1054 * writable memory. Coerce the mutability and set the pointer.
1055 */
1056 static void coerce_it(void ** s) { *s = AO_gettext(*s);
1057 }
1058
1059 /**
1060 * Translate all the translatable strings in the complexityOptions
1061 * structure defined above. This is done only once.
1062 */
1063 static void
1064 translate_option_strings(void)
1065 {
1066 tOptions * const opts = &complexityOptions;
1067
1068 /*
1069 * Guard against re-translation. It won't work. The strings will have
1070 * been changed by the first pass through this code. One shot only.
1071 */
1072 if (option_xlateable_txt.field_ct != 0) {
1073 /*
1074 * Do the translations. The first pointer follows the field count
1075 * field. The field count field is the size of a pointer.
1076 */
1077 char ** ppz = (char**)VOIDP(&(option_xlateable_txt));
1078 int ix = option_xlateable_txt.field_ct;
1079
1080 do {
1081 ppz++; /* skip over field_ct */
1082 *ppz = AO_gettext(*ppz);
1083 } while (--ix > 0);
1084 /* prevent re-translation and disable "libopts" domain lookup */
1085 option_xlateable_txt.field_ct = 0;
1086
1087 coerce_it(VOIDP(&(opts->pzCopyright)));
1088 coerce_it(VOIDP(&(opts->pzCopyNotice)));
1089 coerce_it(VOIDP(&(opts->pzFullVersion)));
1090 coerce_it(VOIDP(&(opts->pzUsageTitle)));
1091 coerce_it(VOIDP(&(opts->pzExplain)));
1092 coerce_it(VOIDP(&(opts->pzDetail)));
1093 {
1094 tOptDesc * od = opts->pOptDesc;
1095 for (ix = opts->optCt; ix > 0; ix--, od++)
1096 coerce_it(VOIDP(&(od->pzText)));
1097 }
1098 }
1099 }
1100 #endif /* ENABLE_NLS */
1101
1102 #ifdef DO_NOT_COMPILE_THIS_CODE_IT_IS_FOR_GETTEXT
1103 /** I18N function strictly for xgettext. Do not compile. */
1104 static void bogus_function(void) {
1105 /* TRANSLATORS:
1106
1107 The following dummy function was crated solely so that xgettext can
1108 extract the correct strings. These strings are actually referenced
1109 by a field name in the complexityOptions structure noted in the
1110 comments below. The literal text is defined in complexity_opt_strs.
1111
1112 NOTE: the strings below are segmented with respect to the source string
1113 complexity_opt_strs. The strings above are handed off for translation
1114 at run time a paragraph at a time. Consequently, they are presented here
1115 for translation a paragraph at a time.
1116
1117 ALSO: often the description for an option will reference another option
1118 by name. These are set off with apostrophe quotes (I hope). Do not
1119 translate option names.
1120 */
1121 /* referenced via complexityOptions.pzCopyright */
1122 puts(_("complexity (GNU Complexity) 1.13\n\
1123 Copyright (C) 2011-2020 Bruce Korb, all rights reserved.\n\
1124 This is free software. It is licensed for use, modification and\n\
1125 redistribution under the terms of the GNU General Public License,\n\
1126 version 3 or later <http://gnu.org/licenses/gpl.html>\n"));
1127
1128 /* referenced via complexityOptions.pzCopyNotice */
1129 puts(_("complexity is free software: you can redistribute it and/or modify it under\n\
1130 the terms of the GNU General Public License as published by the Free\n\
1131 Software Foundation, either version 3 of the License, or (at your option)\n\
1132 any later version.\n\n"));
1133 puts(_("complexity is distributed in the hope that it will be useful, but WITHOUT\n\
1134 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\n\
1135 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for\n\
1136 more details.\n\n"));
1137 puts(_("You should have received a copy of the GNU General Public License along\n\
1138 with this program. If not, see <http://www.gnu.org/licenses/>.\n"));
1139
1140 /* referenced via complexityOptions.pOptDesc->pzText */
1141 puts(_("Reporting threshold"));
1142
1143 /* referenced via complexityOptions.pOptDesc->pzText */
1144 puts(_("zero exit threshold"));
1145
1146 /* referenced via complexityOptions.pOptDesc->pzText */
1147 puts(_("score multiplier for nested code"));
1148
1149 /* referenced via complexityOptions.pOptDesc->pzText */
1150 puts(_("score multiplier for nested expressions"));
1151
1152 /* referenced via complexityOptions.pOptDesc->pzText */
1153 puts(_("complexity scaling factor"));
1154
1155 /* referenced via complexityOptions.pOptDesc->pzText */
1156 puts(_("Display histogram of complexity numbers"));
1157
1158 /* referenced via complexityOptions.pOptDesc->pzText */
1159 puts(_("Display the score for each procedure"));
1160
1161 /* referenced via complexityOptions.pOptDesc->pzText */
1162 puts(_("procedure name to be ignored"));
1163
1164 /* referenced via complexityOptions.pOptDesc->pzText */
1165 puts(_("do not print scoring header"));
1166
1167 /* referenced via complexityOptions.pOptDesc->pzText */
1168 puts(_("Run the source(s) through unifdef(1BSD)"));
1169
1170 /* referenced via complexityOptions.pOptDesc->pzText */
1171 puts(_("Specify the unifdef program"));
1172
1173 /* referenced via complexityOptions.pOptDesc->pzText */
1174 puts(_("file of file list"));
1175
1176 /* referenced via complexityOptions.pOptDesc->pzText */
1177 puts(_("trace output file"));
1178
1179 /* referenced via complexityOptions.pOptDesc->pzText */
1180 puts(_("display extended usage information and exit"));
1181
1182 /* referenced via complexityOptions.pOptDesc->pzText */
1183 puts(_("extended usage information passed thru pager"));
1184
1185 /* referenced via complexityOptions.pOptDesc->pzText */
1186 puts(_("output version information and exit"));
1187
1188 /* referenced via complexityOptions.pOptDesc->pzText */
1189 puts(_("save the option state to a config file"));
1190
1191 /* referenced via complexityOptions.pOptDesc->pzText */
1192 puts(_("load options from a config file"));
1193
1194 /* referenced via complexityOptions.pzUsageTitle */
1195 puts(_("complexity (GNU Complexity) - Measure complexity of C source\n\
1196 Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \\\n\
1197 \t\t[ <file-name> ... ]\n"));
1198
1199 /* referenced via complexityOptions.pzExplain */
1200 puts(_("Compute the complexity of source code not just with a path-through-the-code\n\
1201 count, but also amplifying line counts by logic level nesting.\n\n"));
1202 puts(_("If no arguments are provided, input arguments are read from stdin,\n\
1203 one per line; blank and '#'-prefixed lines are comments.\n\
1204 'stdin' may not be a terminal (tty).\n"));
1205
1206 /* referenced via complexityOptions.pzDetail */
1207 puts(_("'complexity' ignores all cpp preprocessor directives - calculating the\n\
1208 complexity of the appearance of the code, rather than the complexity after\n\
1209 the preprocessor manipulates the code. 'getchar(3)', for example, will\n\
1210 expand into quite complicated code.\n"));
1211
1212 /* referenced via complexityOptions.pzFullVersion */
1213 puts(_("complexity (GNU Complexity) 1.13"));
1214
1215 /* referenced via complexityOptions.pzFullUsage */
1216 puts(_("<<<NOT-FOUND>>>"));
1217
1218 /* referenced via complexityOptions.pzShortUsage */
1219 puts(_("<<<NOT-FOUND>>>"));
1220 /* LIBOPTS-MESSAGES: */
1221 #line 62 "../autoopts.c"
1222 puts(_("allocation of %d bytes failed\n"));
1223 #line 84 "../autoopts.c"
1224 puts(_("allocation of %d bytes failed\n"));
1225 #line 49 "../init.c"
1226 puts(_("AutoOpts function called without option descriptor\n"));
1227 #line 82 "../init.c"
1228 puts(_("\tThis exceeds the compiled library version: "));
1229 #line 80 "../init.c"
1230 puts(_("Automated Options Processing Error!\n"
1231 "\t%s called AutoOpts function with structure version %d:%d:%d.\n"));
1232 #line 73 "../autoopts.c"
1233 puts(_("realloc of %d bytes at 0x%p failed\n"));
1234 #line 84 "../init.c"
1235 puts(_("\tThis is less than the minimum library version: "));
1236 #line 122 "../version.c"
1237 puts(_("Automated Options version %s\n"
1238 "\tCopyright (C) 1999-2020 by Bruce Korb - all rights reserved\n"));
1239 #line 49 "../makeshell.c"
1240 puts(_("(AutoOpts bug): %s.\n"));
1241 #line 90 "../reset.c"
1242 puts(_("optionResetOpt() called, but reset-option not configured"));
1243 #line 241 "../usage.c"
1244 puts(_("could not locate the 'help' option"));
1245 #line 325 "../autoopts.c"
1246 puts(_("optionProcess() was called with invalid data"));
1247 #line 697 "../usage.c"
1248 puts(_("invalid argument type specified"));
1249 #line 569 "../find.c"
1250 puts(_("defaulted to option with optional arg"));
1251 #line 76 "../alias.c"
1252 puts(_("aliasing option is out of range."));
1253 #line 210 "../enum.c"
1254 puts(_("%s error: the keyword '%s' is ambiguous for %s\n"));
1255 #line 79 "../find.c"
1256 puts(_(" The following options match:\n"));
1257 #line 264 "../find.c"
1258 puts(_("%s: ambiguous option name: %s (matches %d options)\n"));
1259 #line 162 "../check.c"
1260 puts(_("%s: Command line arguments required\n"));
1261 #line 43 "../alias.c"
1262 puts(_("%d %s%s options allowed\n"));
1263 #line 56 "../makeshell.c"
1264 puts(_("%s error %d (%s) calling %s for '%s'\n"));
1265 #line 268 "../makeshell.c"
1266 puts(_("interprocess pipe"));
1267 #line 172 "../version.c"
1268 puts(_("error: version option argument '%c' invalid. Use:\n"
1269 "\t'v' - version only\n"
1270 "\t'c' - version and copyright\n"
1271 "\t'n' - version and full copyright notice\n"));
1272 #line 59 "../check.c"
1273 puts(_("%s error: the '%s' and '%s' options conflict\n"));
1274 #line 188 "../find.c"
1275 puts(_("%s: The '%s' option has been disabled."));
1276 #line 401 "../find.c"
1277 puts(_("%s: The '%s' option has been disabled."));
1278 #line 38 "../alias.c"
1279 puts(_("-equivalence"));
1280 #line 440 "../find.c"
1281 puts(_("%s: illegal option -- %c\n"));
1282 #line 110 "../reset.c"
1283 puts(_("%s: illegal option -- %c\n"));
1284 #line 242 "../find.c"
1285 puts(_("%s: illegal option -- %s\n"));
1286 #line 741 "../find.c"
1287 puts(_("%s: illegal option -- %s\n"));
1288 #line 118 "../reset.c"
1289 puts(_("%s: illegal option -- %s\n"));
1290 #line 306 "../find.c"
1291 puts(_("%s: unknown vendor extension option -- %s\n"));
1292 #line 135 "../enum.c"
1293 puts(_(" or an integer from %d through %d\n"));
1294 #line 145 "../enum.c"
1295 puts(_(" or an integer from %d through %d\n"));
1296 #line 696 "../usage.c"
1297 puts(_("%s error: invalid option descriptor for %s\n"));
1298 #line 1030 "../usage.c"
1299 puts(_("%s error: invalid option descriptor for %s\n"));
1300 #line 356 "../find.c"
1301 puts(_("%s: invalid option name: %s\n"));
1302 #line 498 "../find.c"
1303 puts(_("%s: The '%s' option requires an argument.\n"));
1304 #line 145 "../autoopts.c"
1305 puts(_("(AutoOpts bug): Equivalenced option '%s' was equivalenced to both\n"
1306 "\t'%s' and '%s'."));
1307 #line 95 "../check.c"
1308 puts(_("%s error: The %s option is required\n"));
1309 #line 603 "../find.c"
1310 puts(_("%s: The '%s' option cannot have an argument.\n"));
1311 #line 152 "../check.c"
1312 puts(_("%s: Command line arguments are not allowed.\n"));
1313 #line 568 "../save.c"
1314 puts(_("error %d (%s) creating %s\n"));
1315 #line 210 "../enum.c"
1316 puts(_("%s error: '%s' does not match any %s keywords.\n"));
1317 #line 93 "../reset.c"
1318 puts(_("%s error: The '%s' option requires an argument.\n"));
1319 #line 122 "../save.c"
1320 puts(_("error %d (%s) stat-ing %s\n"));
1321 #line 175 "../save.c"
1322 puts(_("error %d (%s) stat-ing %s\n"));
1323 #line 143 "../restore.c"
1324 puts(_("%s error: no saved option state\n"));
1325 #line 220 "../autoopts.c"
1326 puts(_("'%s' is not a command line option.\n"));
1327 #line 113 "../time.c"
1328 puts(_("%s error: '%s' is not a recognizable date/time.\n"));
1329 #line 50 "../time.c"
1330 puts(_("%s error: '%s' is not a recognizable time duration.\n"));
1331 #line 93 "../check.c"
1332 puts(_("%s error: The %s option must appear %d times.\n"));
1333 #line 162 "../numeric.c"
1334 puts(_("%s error: '%s' is not a recognizable number.\n"));
1335 #line 176 "../enum.c"
1336 puts(_("%s error: %s exceeds %s keyword count\n"));
1337 #line 279 "../usage.c"
1338 puts(_("Try '%s %s' for more information.\n"));
1339 #line 45 "../alias.c"
1340 puts(_("one %s%s option allowed\n"));
1341 #line 170 "../makeshell.c"
1342 puts(_("standard output"));
1343 #line 905 "../makeshell.c"
1344 puts(_("standard output"));
1345 #line 223 "../usage.c"
1346 puts(_("standard output"));
1347 #line 364 "../usage.c"
1348 puts(_("standard output"));
1349 #line 574 "../usage.c"
1350 puts(_("standard output"));
1351 #line 179 "../version.c"
1352 puts(_("standard output"));
1353 #line 223 "../usage.c"
1354 puts(_("standard error"));
1355 #line 364 "../usage.c"
1356 puts(_("standard error"));
1357 #line 574 "../usage.c"
1358 puts(_("standard error"));
1359 #line 179 "../version.c"
1360 puts(_("standard error"));
1361 #line 170 "../makeshell.c"
1362 puts(_("write"));
1363 #line 905 "../makeshell.c"
1364 puts(_("write"));
1365 #line 222 "../usage.c"
1366 puts(_("write"));
1367 #line 363 "../usage.c"
1368 puts(_("write"));
1369 #line 573 "../usage.c"
1370 puts(_("write"));
1371 #line 178 "../version.c"
1372 puts(_("write"));
1373 #line 60 "../numeric.c"
1374 puts(_("%s error: %s option value %ld is out of range.\n"));
1375 #line 45 "../check.c"
1376 puts(_("%s error: %s option requires the %s option\n"));
1377 #line 121 "../save.c"
1378 puts(_("%s warning: cannot save options - %s not regular file\n"));
1379 #line 174 "../save.c"
1380 puts(_("%s warning: cannot save options - %s not regular file\n"));
1381 #line 193 "../save.c"
1382 puts(_("%s warning: cannot save options - %s not regular file\n"));
1383 #line 567 "../save.c"
1384 puts(_("%s warning: cannot save options - %s not regular file\n"));
1385 /* END-LIBOPTS-MESSAGES */
1386
1387 /* USAGE-TEXT: */
1388 #line 822 "../usage.c"
1389 puts(_("\t\t\t\t- an alternate for '%s'\n"));
1390 #line 1097 "../usage.c"
1391 puts(_("Version, usage and configuration options:"));
1392 #line 873 "../usage.c"
1393 puts(_("\t\t\t\t- default option for unnamed options\n"));
1394 #line 786 "../usage.c"
1395 puts(_("\t\t\t\t- disabled as '--%s'\n"));
1396 #line 1066 "../usage.c"
1397 puts(_(" --- %-14s %s\n"));
1398 #line 1064 "../usage.c"
1399 puts(_("This option has been disabled"));
1400 #line 813 "../usage.c"
1401 puts(_("\t\t\t\t- enabled by default\n"));
1402 #line 40 "../alias.c"
1403 puts(_("%s error: only "));
1404 #line 1143 "../usage.c"
1405 puts(_(" - examining environment variables named %s_*\n"));
1406 #line 168 "../file.c"
1407 puts(_("\t\t\t\t- file must not pre-exist\n"));
1408 #line 172 "../file.c"
1409 puts(_("\t\t\t\t- file must pre-exist\n"));
1410 #line 329 "../usage.c"
1411 puts(_("Options are specified by doubled hyphens and their name or by a single\n"
1412 "hyphen and the flag character.\n"));
1413 #line 882 "../makeshell.c"
1414 puts(_("\n"
1415 "= = = = = = = =\n\n"
1416 "This incarnation of genshell will produce\n"
1417 "a shell script to parse the options for %s:\n\n"));
1418 #line 142 "../enum.c"
1419 puts(_(" or an integer mask with any of the lower %d bits set\n"));
1420 #line 846 "../usage.c"
1421 puts(_("\t\t\t\t- is a set membership option\n"));
1422 #line 867 "../usage.c"
1423 puts(_("\t\t\t\t- must appear between %d and %d times\n"));
1424 #line 331 "../usage.c"
1425 puts(_("Options are specified by single or double hyphens and their name.\n"));
1426 #line 853 "../usage.c"
1427 puts(_("\t\t\t\t- may appear multiple times\n"));
1428 #line 840 "../usage.c"
1429 puts(_("\t\t\t\t- may not be preset\n"));
1430 #line 1258 "../usage.c"
1431 puts(_(" Arg Option-Name Description\n"));
1432 #line 1194 "../usage.c"
1433 puts(_(" Flg Arg Option-Name Description\n"));
1434 #line 1252 "../usage.c"
1435 puts(_(" Flg Arg Option-Name Description\n"));
1436 #line 1253 "../usage.c"
1437 puts(_(" %3s %s"));
1438 #line 1259 "../usage.c"
1439 puts(_(" %3s %s"));
1440 #line 336 "../usage.c"
1441 puts(_("The '-#<number>' option may omit the hash char\n"));
1442 #line 332 "../usage.c"
1443 puts(_("All arguments are named options.\n"));
1444 #line 920 "../usage.c"
1445 puts(_(" - reading file %s"));
1446 #line 358 "../usage.c"
1447 puts(_("\n"
1448 "Please send bug reports to: <%s>\n"));
1449 #line 101 "../version.c"
1450 puts(_("\n"
1451 "Please send bug reports to: <%s>\n"));
1452 #line 130 "../version.c"
1453 puts(_("\n"
1454 "Please send bug reports to: <%s>\n"));
1455 #line 852 "../usage.c"
1456 puts(_("\t\t\t\t- may NOT appear - preset only\n"));
1457 #line 893 "../usage.c"
1458 puts(_("\n"
1459 "The following option preset mechanisms are supported:\n"));
1460 #line 1141 "../usage.c"
1461 puts(_("\n"
1462 "The following option preset mechanisms are supported:\n"));
1463 #line 631 "../usage.c"
1464 puts(_("prohibits these options:\n"));
1465 #line 626 "../usage.c"
1466 puts(_("prohibits the option '%s'\n"));
1467 #line 81 "../numeric.c"
1468 puts(_("%s%ld to %ld"));
1469 #line 79 "../numeric.c"
1470 puts(_("%sgreater than or equal to %ld"));
1471 #line 75 "../numeric.c"
1472 puts(_("%s%ld exactly"));
1473 #line 68 "../numeric.c"
1474 puts(_("%sit must lie in one of the ranges:\n"));
1475 #line 68 "../numeric.c"
1476 puts(_("%sit must be in the range:\n"));
1477 #line 88 "../numeric.c"
1478 puts(_(", or\n"));
1479 #line 66 "../numeric.c"
1480 puts(_("%sis scalable with a suffix: k/K/m/M/g/G/t/T\n"));
1481 #line 77 "../numeric.c"
1482 puts(_("%sless than or equal to %ld"));
1483 #line 339 "../usage.c"
1484 puts(_("Operands and options may be intermixed. They will be reordered.\n"));
1485 #line 601 "../usage.c"
1486 puts(_("requires the option '%s'\n"));
1487 #line 604 "../usage.c"
1488 puts(_("requires these options:\n"));
1489 #line 1270 "../usage.c"
1490 puts(_(" Arg Option-Name Req? Description\n"));
1491 #line 1264 "../usage.c"
1492 puts(_(" Flg Arg Option-Name Req? Description\n"));
1493 #line 143 "../enum.c"
1494 puts(_("or you may use a numeric representation. Preceding these with a '!'\n"
1495 "will clear the bits, specifying 'none' will clear all bits, and 'all'\n"
1496 "will set them all. Multiple entries may be passed as an option\n"
1497 "argument list.\n"));
1498 #line 859 "../usage.c"
1499 puts(_("\t\t\t\t- may appear up to %d times\n"));
1500 #line 52 "../enum.c"
1501 puts(_("The valid \"%s\" option keywords are:\n"));
1502 #line 1101 "../usage.c"
1503 puts(_("The next option supports vendor supported extra options:"));
1504 #line 722 "../usage.c"
1505 puts(_("These additional options are:"));
1506 /* END-USAGE-TEXT */
1507 }
1508 #endif /* uncompilable code */
1509 #ifdef __cplusplus
1510 }
1511 #endif
1512 /* opts.c ends here */
1513 /* sum: opts.def = 25387.13 */