xapian-core  1.4.27
getopt.cc
Go to the documentation of this file.
1 /* Getopt for GNU.
2  NOTE: getopt is now part of the C library, so if you don't know what
3  "Keep this file name-space clean" means, talk to drepper@gnu.org
4  before changing it!
5 
6  Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000
7  Free Software Foundation, Inc.
8  Copyright (C) 2004,2009,2010,2015 Olly Betts (reworked to allow compilation as C++)
9 
10  The GNU C Library is free software; you can redistribute it and/or
11  modify it under the terms of the GNU Library General Public License as
12  published by the Free Software Foundation; either version 2 of the
13  License, or (at your option) any later version.
14 
15  The GNU C Library is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Library General Public License for more details.
19 
20  You should have received a copy of the GNU Library General Public
21  License along with the GNU C Library; see the file COPYING.LIB. If not,
22  write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23  Boston, MA 02110-1301, USA. */
24 
25 
26 #ifdef HAVE_CONFIG_H
27 # include <config.h>
28 #endif
29 
30 #include "gnu_getopt.h"
31 
32 /* #ifdef out all this code if we are using the GNU C Library. GNU getopt
33  is included in the GNU C Library, and linking in this code is a waste when
34  using the GNU C library (especially if it is a shared library). */
35 
36 #ifndef USE_GLIBC_GNUGETOPT
37 
38 #include <cstdio>
39 
40 using std::fprintf;
41 
42 #ifdef VMS
43 # include <unixlib.h>
44 #endif
45 
46 #ifndef _
47 /* This is for other GNU distributions with internationalized messages. */
48 # if 0 //defined HAVE_LIBINTL_H || defined _LIBC
49 # include <libintl.h>
50 # ifndef _
51 # define _(msgid) gettext (msgid)
52 # endif
53 # else
54 # define _(msgid) (msgid)
55 # endif
56 #endif
57 
58 #ifndef __CYGWIN__
59 /* This version of `getopt' appears to the caller like standard Unix `getopt'
60  but it behaves differently for the user, since it allows the user
61  to intersperse the options with the other arguments.
62 
63  As `getopt' works, it permutes the elements of ARGV so that,
64  when it is done, all the options precede everything else. Thus
65  all application programs are extended to handle flexible argument order.
66 
67  Setting the environment variable POSIXLY_CORRECT disables permutation.
68  Then the behavior is completely standard.
69 
70  GNU application programs can use a third alternative mode in which
71  they can distinguish the relative order of options and other arguments. */
72 
73 /* For communication from `getopt' to the caller.
74  When `getopt' finds an option that takes an argument,
75  the argument value is returned here.
76  Also, when `ordering' is RETURN_IN_ORDER,
77  each non-option ARGV-element is returned here. */
78 
79 char *optarg;
80 
81 /* Index in ARGV of the next element to be scanned.
82  This is used for communication to and from the caller
83  and for communication between successive calls to `getopt'.
84 
85  On entry to `getopt', zero means this is the first call; initialize.
86 
87  When `getopt' returns -1, this is the index of the first of the
88  non-option elements that the caller should itself scan.
89 
90  Otherwise, `optind' communicates from one call to the next
91  how much of ARGV has been scanned so far. */
92 
93 /* 1003.2 says this must be 1 before any call. */
94 int optind = 1;
95 
96 /* Callers store zero here to inhibit the error message
97  for unrecognized options. */
98 
99 int opterr = 1;
100 
101 /* Set to an option character which was unrecognized.
102  This must be initialized on some systems to avoid linking in the
103  system's own getopt implementation. */
104 
105 int optopt = '?';
106 #endif
107 
108 /* Formerly, initialization of getopt depended on optind==0, which
109  causes problems with re-calling getopt as programs generally don't
110  know that. */
111 
113 
114 /* The next char to be scanned in the option-element
115  in which the last option character we returned was found.
116  This allows us to pick up the scan where we left off.
117 
118  If this is zero, or a null string, it means resume the scan
119  by advancing to the next ARGV-element. */
120 
121 static char *nextchar;
122 
123 /* Describe how to deal with options that follow non-option ARGV-elements.
124 
125  If the caller did not specify anything,
126  the default is REQUIRE_ORDER if the environment variable
127  POSIXLY_CORRECT is defined, PERMUTE otherwise.
128 
129  REQUIRE_ORDER means don't recognize them as options;
130  stop option processing when the first non-option is seen.
131  This is what Unix does.
132  This mode of operation is selected by either setting the environment
133  variable POSIXLY_CORRECT, or using `+' as the first character
134  of the list of option characters.
135 
136  PERMUTE is the default. We permute the contents of ARGV as we scan,
137  so that eventually all the non-options are at the end. This allows options
138  to be given in any order, even with programs that were not written to
139  expect this.
140 
141  RETURN_IN_ORDER is an option available to programs that were written
142  to expect options and other ARGV-elements in any order and that care about
143  the ordering of the two. We describe each non-option ARGV-element
144  as if it were the argument of an option with character code 1.
145  Using `-' as the first character of the list of option characters
146  selects this mode of operation.
147 
148  The special argument `--' forces an end of option-scanning regardless
149  of the value of `ordering'. In the case of RETURN_IN_ORDER, only
150  `--' can cause `getopt' to return -1 with `optind' != ARGC. */
151 
152 static enum
153 {
155 } ordering;
156 
157 /* Value of POSIXLY_CORRECT environment variable. */
158 static char *posixly_correct;
159 
160 #include <cstring>
161 using std::strlen;
162 using std::strcmp;
163 using std::strncmp;
164 using std::strchr;
165 
166 #include <cstdlib>
167 using std::getenv;
168 
169 
170 /* Handle permutation of arguments. */
171 
172 /* Describe the part of ARGV that contains non-options that have
173  been skipped. `first_nonopt' is the index in ARGV of the first of them;
174  `last_nonopt' is the index after the last of them. */
175 
176 static int first_nonopt;
177 static int last_nonopt;
178 
179 /* Exchange two adjacent subsequences of ARGV.
180  One subsequence is elements [first_nonopt,last_nonopt)
181  which contains all the non-options that have been skipped so far.
182  The other is elements [last_nonopt,optind), which contains all
183  the options processed since those non-options were skipped.
184 
185  `first_nonopt' and `last_nonopt' are relocated so that they describe
186  the new indices of the non-options in ARGV after they are moved. */
187 
188 static void
189 exchange (char **argv)
190 {
191  int bottom = first_nonopt;
192  int middle = last_nonopt;
193  int top = optind;
194  char *tem;
195 
196  /* Exchange the shorter segment with the far end of the longer segment.
197  That puts the shorter segment into the right place.
198  It leaves the longer segment in the right place overall,
199  but it consists of two parts that need to be swapped next. */
200 
201  while (top > middle && middle > bottom)
202  {
203  if (top - middle > middle - bottom)
204  {
205  /* Bottom segment is the short one. */
206  int len = middle - bottom;
207  int i;
208 
209  /* Swap it with the top part of the top segment. */
210  for (i = 0; i < len; i++)
211  {
212  tem = argv[bottom + i];
213  argv[bottom + i] = argv[top - (middle - bottom) + i];
214  argv[top - (middle - bottom) + i] = tem;
215  }
216  /* Exclude the moved bottom segment from further swapping. */
217  top -= len;
218  }
219  else
220  {
221  /* Top segment is the short one. */
222  int len = top - middle;
223  int i;
224 
225  /* Swap it with the bottom part of the bottom segment. */
226  for (i = 0; i < len; i++)
227  {
228  tem = argv[bottom + i];
229  argv[bottom + i] = argv[middle + i];
230  argv[middle + i] = tem;
231  }
232  /* Exclude the moved top segment from further swapping. */
233  bottom += len;
234  }
235  }
236 
237  /* Update records for the slots the non-options now occupy. */
238 
241 }
242 
243 /* Initialize the internal data when the first call is made. */
244 
245 static const char *
246 getopt_initialize (int argc, char *const *argv, const char *optstring)
247 {
248  /* Suppress possible unused warnings */
249  (void)argc;
250  (void)argv;
251 
252  /* Start processing options with ARGV-element 1 (since ARGV-element 0
253  is the program name); the sequence of previously skipped
254  non-option ARGV-elements is empty. */
255 
257 
258  nextchar = NULL;
259 
260  posixly_correct = getenv ("POSIXLY_CORRECT");
261 
262  /* Determine how to handle the ordering of options and nonoptions. */
263 
264  if (optstring[0] == '-')
265  {
267  ++optstring;
268  }
269  else if (optstring[0] == '+')
270  {
272  ++optstring;
273  }
274  else if (posixly_correct != NULL)
276  else
277  ordering = PERMUTE;
278 
279  return optstring;
280 }
281 
282 /* Scan elements of ARGV (whose length is ARGC) for option characters
283  given in OPTSTRING.
284 
285  If an element of ARGV starts with '-', and is not exactly "-" or "--",
286  then it is an option element. The characters of this element
287  (aside from the initial '-') are option characters. If `getopt'
288  is called repeatedly, it returns successively each of the option characters
289  from each of the option elements.
290 
291  If `getopt' finds another option character, it returns that character,
292  updating `optind' and `nextchar' so that the next call to `getopt' can
293  resume the scan with the following option character or ARGV-element.
294 
295  If there are no more option characters, `getopt' returns -1.
296  Then `optind' is the index in ARGV of the first ARGV-element
297  that is not an option. (The ARGV-elements have been permuted
298  so that those that are not options now come last.)
299 
300  OPTSTRING is a string containing the legitimate option characters.
301  If an option character is seen that is not listed in OPTSTRING,
302  return '?' after printing an error message. If you set `opterr' to
303  zero, the error message is suppressed but we still return '?'.
304 
305  If a char in OPTSTRING is followed by a colon, that means it wants an arg,
306  so the following text in the same ARGV-element, or the text of the following
307  ARGV-element, is returned in `optarg'. Two colons mean an option that
308  wants an optional arg; if there is text in the current ARGV-element,
309  it is returned in `optarg', otherwise `optarg' is set to zero.
310 
311  If OPTSTRING starts with `-' or `+', it requests different methods of
312  handling the non-option ARGV-elements.
313  See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
314 
315  Long-named options begin with `--' instead of `-'.
316  Their names may be abbreviated as long as the abbreviation is unique
317  or is an exact match for some defined option. If they have an
318  argument, it follows the option name in the same ARGV-element, separated
319  from the option name by a `=', or else the in next ARGV-element.
320  When `getopt' finds a long-named option, it returns 0 if that option's
321  `flag' field is nonzero, the value of the option's `val' field
322  if the `flag' field is zero.
323 
324  The elements of ARGV aren't really const, because we permute them.
325  But we pretend they're const in the prototype to be compatible
326  with other systems.
327 
328  LONGOPTS is a vector of `struct option' terminated by an
329  element containing a name which is zero.
330 
331  LONGIND returns the index in LONGOPT of the long-named option found.
332  It is only valid when a long-named option has been found by the most
333  recent call.
334 
335  If LONG_ONLY is nonzero, '-' as well as '--' can introduce
336  long-named options. */
337 
338 int
339 gnu_getopt_internal_(int argc, char *const *argv, const char *optstring, const struct option *longopts, int *longind, int long_only)
340 {
341  int print_errors = opterr;
342  if (optstring[0] == ':')
343  print_errors = 0;
344 
345  if (argc < 1)
346  return -1;
347 
348  optarg = NULL;
349 
350  if (optind == 0 || !getopt_initialized)
351  {
352  if (optind == 0)
353  optind = 1; /* Don't scan ARGV[0], the program name. */
354  optstring = getopt_initialize (argc, argv, optstring);
355  getopt_initialized = 1;
356  }
357 
358  /* Test whether ARGV[optind] points to a non-option argument (i.e. it does
359  not have option syntax). */
360 # define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0')
361 
362  if (nextchar == NULL || *nextchar == '\0')
363  {
364  /* Advance to the next ARGV-element. */
365 
366  /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been
367  moved back by the user (who may also have changed the arguments). */
368  if (last_nonopt > optind)
370  if (first_nonopt > optind)
372 
373  if (ordering == PERMUTE)
374  {
375  /* If we have just processed some options following some non-options,
376  exchange them so that the options come first. */
377 
379  exchange (const_cast<char **>(argv));
380  else if (last_nonopt != optind)
382 
383  /* Skip any additional non-options
384  and extend the range of non-options previously skipped. */
385 
386  while (optind < argc && NONOPTION_P)
387  optind++;
389  }
390 
391  /* The special ARGV-element `--' means premature end of options.
392  Skip it like a null option,
393  then exchange with previous non-options as if it were an option,
394  then skip everything else like a non-option. */
395 
396  if (optind != argc && !strcmp (argv[optind], "--"))
397  {
398  optind++;
399 
400  if (first_nonopt != last_nonopt && last_nonopt != optind)
401  exchange (const_cast<char **>(argv));
402  else if (first_nonopt == last_nonopt)
404  last_nonopt = argc;
405 
406  optind = argc;
407  }
408 
409  /* If we have done all the ARGV-elements, stop the scan
410  and back over any non-options that we skipped and permuted. */
411 
412  if (optind == argc)
413  {
414  /* Set the next-arg-index to point at the non-options
415  that we previously skipped, so the caller will digest them. */
416  if (first_nonopt != last_nonopt)
417  optind = first_nonopt;
418  return -1;
419  }
420 
421  /* If we have come to a non-option and did not permute it,
422  either stop the scan or describe it to the caller and pass it by. */
423 
424  if (NONOPTION_P)
425  {
426  if (ordering == REQUIRE_ORDER)
427  return -1;
428  optarg = argv[optind++];
429  return 1;
430  }
431 
432  /* We have found another option-ARGV-element.
433  Skip the initial punctuation. */
434 
435  nextchar = (argv[optind] + 1
436  + (longopts != NULL && argv[optind][1] == '-'));
437  }
438 
439  /* Decode the current option-ARGV-element. */
440 
441  /* Check whether the ARGV-element is a long option.
442 
443  If long_only and the ARGV-element has the form "-f", where f is
444  a valid short option, don't consider it an abbreviated form of
445  a long option that starts with f. Otherwise there would be no
446  way to give the -f short option.
447 
448  On the other hand, if there's a long option "fubar" and
449  the ARGV-element is "-fu", do consider that an abbreviation of
450  the long option, just like "--fu", and not "-f" with arg "u".
451 
452  This distinction seems to be the most useful approach. */
453 
454  if (longopts != NULL
455  && (argv[optind][1] == '-'
456  || (long_only && (argv[optind][2] || !strchr (optstring, argv[optind][1])))))
457  {
458  char *nameend;
459  const struct option *p;
460  const struct option *pfound = NULL;
461  int exact = 0;
462  int ambig = 0;
463  int indfound = -1;
464  int option_index;
465 
466  for (nameend = nextchar; *nameend && *nameend != '='; nameend++)
467  /* Do nothing. */ ;
468 
469  /* Test all long options for either exact match
470  or abbreviated matches. */
471  for (p = longopts, option_index = 0; p->name; p++, option_index++)
472  if (!strncmp (p->name, nextchar, nameend - nextchar))
473  {
474  if (unsigned(nameend - nextchar) == unsigned(strlen(p->name)))
475  {
476  /* Exact match found. */
477  pfound = p;
478  indfound = option_index;
479  exact = 1;
480  break;
481  }
482  else if (pfound == NULL)
483  {
484  /* First nonexact match found. */
485  pfound = p;
486  indfound = option_index;
487  }
488  else if (long_only
489  || pfound->has_arg != p->has_arg
490  || pfound->flag != p->flag
491  || pfound->val != p->val)
492  /* Second or later nonexact match found. */
493  ambig = 1;
494  }
495 
496  if (ambig && !exact)
497  {
498  if (print_errors)
499  fprintf (stderr, _("%s: option '%s' is ambiguous\n"),
500  argv[0], argv[optind]);
501  nextchar += strlen (nextchar);
502  optind++;
503  optopt = 0;
504  return '?';
505  }
506 
507  if (pfound != NULL)
508  {
509  option_index = indfound;
510  optind++;
511  if (*nameend)
512  {
513  /* Don't test has_arg with >, because some C compilers don't
514  allow it to be used on enums. */
515  if (pfound->has_arg)
516  optarg = nameend + 1;
517  else
518  {
519  if (print_errors)
520  {
521  if (argv[optind - 1][1] == '-')
522  /* --option */
523  fprintf (stderr,
524  _("%s: option '--%s' doesn't allow an argument\n"),
525  argv[0], pfound->name);
526  else
527  /* +option or -option */
528  fprintf (stderr,
529  _("%s: option '%c%s' doesn't allow an argument\n"),
530  argv[0], argv[optind - 1][0], pfound->name);
531  }
532 
533  nextchar += strlen (nextchar);
534 
535  optopt = pfound->val;
536  return '?';
537  }
538  }
539  else if (pfound->has_arg == 1)
540  {
541  if (optind < argc)
542  optarg = argv[optind++];
543  else
544  {
545  if (print_errors)
546  fprintf (stderr,
547  _("%s: option '%s' requires an argument\n"),
548  argv[0], argv[optind - 1]);
549  nextchar += strlen (nextchar);
550  optopt = pfound->val;
551  return optstring[0] == ':' ? ':' : '?';
552  }
553  }
554  nextchar += strlen (nextchar);
555  if (longind != NULL)
556  *longind = option_index;
557  if (pfound->flag)
558  {
559  *(pfound->flag) = pfound->val;
560  return 0;
561  }
562  return pfound->val;
563  }
564 
565  /* Can't find it as a long option. If this is not getopt_long_only,
566  or the option starts with '--' or is not a valid short
567  option, then it's an error.
568  Otherwise interpret it as a short option. */
569  if (!long_only || argv[optind][1] == '-'
570  || strchr (optstring, *nextchar) == NULL)
571  {
572  if (print_errors)
573  {
574  if (argv[optind][1] == '-')
575  /* --option */
576  fprintf (stderr, _("%s: unrecognized option '--%s'\n"),
577  argv[0], nextchar);
578  else
579  /* +option or -option */
580  fprintf (stderr, _("%s: unrecognized option '%c%s'\n"),
581  argv[0], argv[optind][0], nextchar);
582  }
583  nextchar = const_cast<char *>("");
584  optind++;
585  optopt = 0;
586  return '?';
587  }
588  }
589 
590  /* Look at and handle the next short option-character. */
591 
592  {
593  char c = *nextchar++;
594  const char *temp = strchr (optstring, c);
595 
596  /* Increment `optind' when we start to process its last character. */
597  if (*nextchar == '\0')
598  ++optind;
599 
600  if (temp == NULL || c == ':')
601  {
602  if (print_errors)
603  {
604  if (posixly_correct)
605  /* 1003.2 specifies the format of this message. */
606  fprintf (stderr, _("%s: illegal option -- %c\n"),
607  argv[0], c);
608  else
609  fprintf (stderr, _("%s: invalid option -- %c\n"),
610  argv[0], c);
611  }
612  optopt = c;
613  return '?';
614  }
615  /* Convenience. Treat POSIX -W foo same as long option --foo */
616  if (temp[0] == 'W' && temp[1] == ';')
617  {
618  char *nameend;
619  const struct option *p;
620  const struct option *pfound = NULL;
621  int exact = 0;
622  int ambig = 0;
623  int indfound = 0;
624  int option_index;
625 
626  /* This is an option that requires an argument. */
627  if (*nextchar != '\0')
628  {
629  optarg = nextchar;
630  /* If we end this ARGV-element by taking the rest as an arg,
631  we must advance to the next element now. */
632  optind++;
633  }
634  else if (optind == argc)
635  {
636  if (print_errors)
637  {
638  /* 1003.2 specifies the format of this message. */
639  fprintf (stderr, _("%s: option requires an argument -- %c\n"),
640  argv[0], c);
641  }
642  optopt = c;
643  if (optstring[0] == ':')
644  c = ':';
645  else
646  c = '?';
647  return c;
648  }
649  else
650  /* We already incremented `optind' once;
651  increment it again when taking next ARGV-elt as argument. */
652  optarg = argv[optind++];
653 
654  /* optarg is now the argument, see if it's in the
655  table of longopts. */
656 
657  for (nextchar = nameend = optarg; *nameend && *nameend != '='; nameend++)
658  /* Do nothing. */ ;
659 
660  /* Test all long options for either exact match
661  or abbreviated matches. */
662  for (p = longopts, option_index = 0; p->name; p++, option_index++)
663  if (!strncmp (p->name, nextchar, nameend - nextchar))
664  {
665  if (unsigned(nameend - nextchar) == unsigned(strlen(p->name)))
666  {
667  /* Exact match found. */
668  pfound = p;
669  indfound = option_index;
670  exact = 1;
671  break;
672  }
673  else if (pfound == NULL)
674  {
675  /* First nonexact match found. */
676  pfound = p;
677  indfound = option_index;
678  }
679  else
680  /* Second or later nonexact match found. */
681  ambig = 1;
682  }
683  if (ambig && !exact)
684  {
685  if (print_errors)
686  fprintf (stderr, _("%s: option '-W %s' is ambiguous\n"),
687  argv[0], argv[optind]);
688  nextchar += strlen (nextchar);
689  optind++;
690  return '?';
691  }
692  if (pfound != NULL)
693  {
694  option_index = indfound;
695  if (*nameend)
696  {
697  /* Don't test has_arg with >, because some C compilers don't
698  allow it to be used on enums. */
699  if (pfound->has_arg)
700  optarg = nameend + 1;
701  else
702  {
703  if (print_errors)
704  fprintf (stderr, _("\
705 %s: option '-W %s' doesn't allow an argument\n"),
706  argv[0], pfound->name);
707 
708  nextchar += strlen (nextchar);
709  return '?';
710  }
711  }
712  else if (pfound->has_arg == 1)
713  {
714  if (optind < argc)
715  optarg = argv[optind++];
716  else
717  {
718  if (print_errors)
719  fprintf (stderr,
720  _("%s: option '%s' requires an argument\n"),
721  argv[0], argv[optind - 1]);
722  nextchar += strlen (nextchar);
723  return optstring[0] == ':' ? ':' : '?';
724  }
725  }
726  nextchar += strlen (nextchar);
727  if (longind != NULL)
728  *longind = option_index;
729  if (pfound->flag)
730  {
731  *(pfound->flag) = pfound->val;
732  return 0;
733  }
734  return pfound->val;
735  }
736  nextchar = NULL;
737  return 'W'; /* Let the application handle it. */
738  }
739  if (temp[1] == ':')
740  {
741  if (temp[2] == ':')
742  {
743  /* This is an option that accepts an argument optionally. */
744  if (*nextchar != '\0')
745  {
746  optarg = nextchar;
747  optind++;
748  }
749  else
750  optarg = NULL;
751  nextchar = NULL;
752  }
753  else
754  {
755  /* This is an option that requires an argument. */
756  if (*nextchar != '\0')
757  {
758  optarg = nextchar;
759  /* If we end this ARGV-element by taking the rest as an arg,
760  we must advance to the next element now. */
761  optind++;
762  }
763  else if (optind == argc)
764  {
765  if (print_errors)
766  {
767  /* 1003.2 specifies the format of this message. */
768  fprintf (stderr,
769  _("%s: option requires an argument -- %c\n"),
770  argv[0], c);
771  }
772  optopt = c;
773  if (optstring[0] == ':')
774  c = ':';
775  else
776  c = '?';
777  }
778  else
779  /* We already incremented `optind' once;
780  increment it again when taking next ARGV-elt as argument. */
781  optarg = argv[optind++];
782  nextchar = NULL;
783  }
784  }
785  return c;
786  }
787 }
788 
789 #endif /* Not ELIDE_CODE. */
Wrappers to allow GNU getopt to be used cleanly from C++ code.
static int getopt_initialized
Definition: getopt.cc:112
int optind
Definition: getopt.cc:94
static int last_nonopt
Definition: getopt.cc:177
int val
Definition: gnu_getopt.h:76
static int first_nonopt
Definition: getopt.cc:176
int optopt
Definition: getopt.cc:105
#define NONOPTION_P
static void exchange(char **argv)
Definition: getopt.cc:189
const char * name
Definition: gnu_getopt.h:73
char * optarg
Definition: getopt.cc:79
#define _(msgid)
Definition: getopt.cc:54
static enum @6 ordering
static char * nextchar
Definition: getopt.cc:121
static char * posixly_correct
Definition: getopt.cc:158
int * flag
Definition: gnu_getopt.h:75
int gnu_getopt_internal_(int argc, char *const *argv, const char *optstring, const struct option *longopts, int *longind, int long_only)
Definition: getopt.cc:339
int has_arg
Definition: gnu_getopt.h:74
int opterr
Definition: getopt.cc:99
static const char * getopt_initialize(int argc, char *const *argv, const char *optstring)
Definition: getopt.cc:246