~vcs-imports/gawk/master

« back to all changes in this revision

Viewing changes to getopt1.c

  • Committer: Arnold D. Robbins
  • Date: 2010-07-16 11:47:02 UTC
  • Revision ID: git-v1:315bd501ca696bc3e3c938b4604d8dac7a6f512f
Tags: gawk-3.1.5
Move to gawk 3.1.5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* getopt_long and getopt_long_only entry points for GNU getopt.
2
 
   Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98
 
2
   Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98,2004
3
3
     Free Software Foundation, Inc.
4
4
   This file is part of the GNU C Library.
5
5
 
15
15
 
16
16
   You should have received a copy of the GNU Lesser General Public
17
17
   License along with the GNU C Library; if not, write to the Free
18
 
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19
 
   02111-1307 USA.  */
 
18
   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 
19
   02110-1301 USA.  */
20
20
 
21
21
#ifdef HAVE_CONFIG_H
22
22
#include <config.h>
27
27
#else
28
28
# include "getopt.h"
29
29
#endif
30
 
 
31
 
#if !defined __STDC__ || !__STDC__
32
 
/* This is a separate conditional since some stdc systems
33
 
   reject `defined (const)'.  */
34
 
#ifndef const
35
 
#define const
36
 
#endif
37
 
#endif
 
30
#include "getopt_int.h"
38
31
 
39
32
#include <stdio.h>
40
33
 
68
61
#endif
69
62
 
70
63
int
71
 
getopt_long (argc, argv, options, long_options, opt_index)
72
 
     int argc;
73
 
     char *const *argv;
74
 
     const char *options;
75
 
     const struct option *long_options;
76
 
     int *opt_index;
 
64
getopt_long (int argc, char *const *argv, const char *options,
 
65
             const struct option *long_options, int *opt_index)
77
66
{
78
67
  return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
79
68
}
80
69
 
 
70
int
 
71
_getopt_long_r (int argc, char *const *argv, const char *options,
 
72
                const struct option *long_options, int *opt_index,
 
73
                struct _getopt_data *d)
 
74
{
 
75
  return _getopt_internal_r (argc, argv, options, long_options, opt_index,
 
76
                             0, d);
 
77
}
 
78
 
81
79
/* Like getopt_long, but '-' as well as '--' can indicate a long option.
82
80
   If an option that starts with '-' (not '--') doesn't match a long option,
83
81
   but does match a short option, it is parsed as a short option
84
82
   instead.  */
85
83
 
86
84
int
87
 
getopt_long_only (argc, argv, options, long_options, opt_index)
88
 
     int argc;
89
 
     char *const *argv;
90
 
     const char *options;
91
 
     const struct option *long_options;
92
 
     int *opt_index;
 
85
getopt_long_only (int argc, char *const *argv, const char *options,
 
86
                  const struct option *long_options, int *opt_index)
93
87
{
94
88
  return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
95
89
}
96
90
 
97
 
# ifdef _LIBC
98
 
libc_hidden_def (getopt_long)
99
 
libc_hidden_def (getopt_long_only)
100
 
# endif
 
91
int
 
92
_getopt_long_only_r (int argc, char *const *argv, const char *options,
 
93
                     const struct option *long_options, int *opt_index,
 
94
                     struct _getopt_data *d)
 
95
{
 
96
  return _getopt_internal_r (argc, argv, options, long_options, opt_index,
 
97
                             1, d);
 
98
}
101
99
 
102
100
#endif  /* Not ELIDE_CODE.  */
103
101
 
106
104
#include <stdio.h>
107
105
 
108
106
int
109
 
main (argc, argv)
110
 
     int argc;
111
 
     char **argv;
 
107
main (int argc, char **argv)
112
108
{
113
109
  int c;
114
110
  int digit_optind = 0;