5 * Handle options that are aliases for another option.
11 * This routine will forward an option alias to the correct option code.
13 * This file is part of AutoOpts, a companion to AutoGen.
14 * AutoOpts is free software.
15 * AutoOpts is Copyright (C) 1992-2015 by Bruce Korb - all rights reserved
17 * AutoOpts is available under any one of two licenses. The license
18 * in use must be one of these two and the choice is under the control
19 * of the user of the license.
21 * The GNU Lesser General Public License, version 3 or later
22 * See the files "COPYING.lgplv3" and "COPYING.gplv3"
24 * The Modified Berkeley Software Distribution License
25 * See the file "COPYING.mbsd"
27 * These files have the following sha256 sums:
29 * 8584710e9b04216a394078dc156b781d0b47e1729104d666658aecef8ee32e95 COPYING.gplv3
30 * 4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b COPYING.lgplv3
31 * 13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239 COPYING.mbsd
35 too_many_occurrences(tOptions * opts, tOptDesc * od)
37 if ((opts->fOptSet & OPTPROC_ERRSTOP) != 0) {
38 char const * eqv = (od->optEquivIndex != NO_EQUIVALENT) ? zequiv : zNil;
40 fprintf(stderr, ztoo_often_fmt, opts->pzProgName);
43 fprintf(stderr, zat_most, od->optMaxCt, od->pz_Name, eqv);
45 fprintf(stderr, zonly_one, od->pz_Name, eqv);
46 (*opts->pUsageProc)(opts, EXIT_FAILURE);
53 /*=export_func optionAlias
56 * what: relay an option to its alias
57 * arg: + tOptions * + opts + program options descriptor +
58 * arg: + tOptDesc * + old_od + the descriptor for this arg +
59 * arg: + unsigned int + alias + the aliased-to option index +
63 * Handle one option as if it had been specified as another. Exactly.
64 * Returns "-1" if the aliased-to option has appeared too many times.
67 optionAlias(tOptions * opts, tOptDesc * old_od, unsigned int alias)
71 if (opts <= OPTPROC_EMIT_LIMIT)
74 new_od = opts->pOptDesc + alias;
75 if ((unsigned)opts->optCt <= alias) {
76 fputs(zbad_alias_id, stderr);
77 option_exits(EXIT_FAILURE);
81 * Copy over the option instance flags
83 new_od->fOptState &= OPTST_PERSISTENT_MASK;
84 new_od->fOptState |= (old_od->fOptState & ~OPTST_PERSISTENT_MASK);
85 new_od->optArg.argString = old_od->optArg.argString;
88 * Keep track of count only for DEFINED (command line) options.
89 * IF we have too many, build up an error message and bail.
91 if ( (new_od->fOptState & OPTST_DEFINED)
92 && (++new_od->optOccCt > new_od->optMaxCt) )
93 return too_many_occurrences(opts, new_od);
96 * Clear the state bits and counters
98 old_od->fOptState &= OPTST_PERSISTENT_MASK;
102 * If there is a procedure to call, call it
104 if (new_od->pOptProc != NULL)
105 (*new_od->pOptProc)(opts, new_od);
113 * c-file-style: "stroustrup"
114 * indent-tabs-mode: nil
116 * end of autoopts/alias.c */