Mercurial > emacs
comparison lib-src/getopt.h @ 48646:dfb045958eeb
Maybe include ctype.h.
Treat __cplusplus like __STDC__.
(decls): Use __ in arg names.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 04 Dec 2002 11:08:06 +0000 |
parents | 82bf642db65e |
children | 695cf19ef79e |
comparison
equal
deleted
inserted
replaced
48645:541276514fa5 | 48646:dfb045958eeb |
---|---|
1 /* Declarations for getopt. | 1 /* Declarations for getopt. |
2 Copyright (C) 1989,90,91,92,93,94,96,97,98 Free Software Foundation, Inc. | 2 Copyright (C) 1989-1994, 1996-1999, 2001 Free Software Foundation, Inc. |
3 NOTE: The canonical source of this file is maintained with the GNU C Library. | 3 This file is part of the GNU C Library. |
4 Bugs can be reported to bug-glibc@gnu.org. | 4 |
5 This program is free software; you can redistribute it and/or modify it | 5 This program is free software; you can redistribute it and/or modify |
6 under the terms of the GNU General Public License as published by the | 6 it under the terms of the GNU General Public License as published by |
7 Free Software Foundation; either version 2, or (at your option) any | 7 the Free Software Foundation; either version 2, or (at your option) |
8 later version. | 8 any later version. |
9 | 9 |
10 This program is distributed in the hope that it will be useful, | 10 This program is distributed in the hope that it will be useful, |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 GNU General Public License for more details. | 13 GNU General Public License for more details. |
14 | 14 |
15 You should have received a copy of the GNU General Public License | 15 You should have received a copy of the GNU General Public License along |
16 along with this program; if not, write to the Free Software | 16 with this program; if not, write to the Free Software Foundation, |
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | 17 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
18 USA. */ | |
19 | 18 |
20 #ifndef _GETOPT_H | 19 #ifndef _GETOPT_H |
21 | 20 |
22 #ifndef __need_getopt | 21 #ifndef __need_getopt |
23 # define _GETOPT_H 1 | 22 # define _GETOPT_H 1 |
23 #endif | |
24 | |
25 /* If __GNU_LIBRARY__ is not already defined, either we are being used | |
26 standalone, or this is the first header included in the source file. | |
27 If we are being used with glibc, we need to include <features.h>, but | |
28 that does not exist if we are standalone. So: if __GNU_LIBRARY__ is | |
29 not defined, include <ctype.h>, which will pull in <features.h> for us | |
30 if it's from glibc. (Why ctype.h? It's guaranteed to exist and it | |
31 doesn't flood the namespace with stuff the way some other headers do.) */ | |
32 #if !defined __GNU_LIBRARY__ | |
33 # include <ctype.h> | |
24 #endif | 34 #endif |
25 | 35 |
26 #ifdef __cplusplus | 36 #ifdef __cplusplus |
27 extern "C" { | 37 extern "C" { |
28 #endif | 38 #endif |
80 one). For long options that have a zero `flag' field, `getopt' | 90 one). For long options that have a zero `flag' field, `getopt' |
81 returns the contents of the `val' field. */ | 91 returns the contents of the `val' field. */ |
82 | 92 |
83 struct option | 93 struct option |
84 { | 94 { |
85 # if defined __STDC__ && __STDC__ | 95 # if (defined __STDC__ && __STDC__) || defined __cplusplus |
86 const char *name; | 96 const char *name; |
87 # else | 97 # else |
88 char *name; | 98 char *name; |
89 # endif | 99 # endif |
90 /* has_arg can't be an enum because some compilers complain about | 100 /* has_arg can't be an enum because some compilers complain about |
124 | 134 |
125 If OPTS begins with `--', then non-option arguments are treated as | 135 If OPTS begins with `--', then non-option arguments are treated as |
126 arguments to the option '\0'. This behavior is specific to the GNU | 136 arguments to the option '\0'. This behavior is specific to the GNU |
127 `getopt'. */ | 137 `getopt'. */ |
128 | 138 |
129 #if defined __STDC__ && __STDC__ | 139 #if (defined __STDC__ && __STDC__) || defined __cplusplus |
130 # ifdef __GNU_LIBRARY__ | 140 # ifdef __GNU_LIBRARY__ |
131 /* Many other libraries have conflicting prototypes for getopt, with | 141 /* Many other libraries have conflicting prototypes for getopt, with |
132 differences in the consts, in stdlib.h. To avoid compilation | 142 differences in the consts, in stdlib.h. To avoid compilation |
133 errors, only prototype getopt for the GNU C library. */ | 143 errors, only prototype getopt for the GNU C library. */ |
134 extern int getopt (int __argc, char *const *__argv, const char *__shortopts); | 144 extern int getopt (int ___argc, char *const *___argv, const char *__shortopts); |
135 # else /* not __GNU_LIBRARY__ */ | 145 # else /* not __GNU_LIBRARY__ */ |
136 extern int getopt (); | 146 extern int getopt (); |
137 # endif /* __GNU_LIBRARY__ */ | 147 # endif /* __GNU_LIBRARY__ */ |
138 | 148 |
139 # ifndef __need_getopt | 149 # ifndef __need_getopt |
140 extern int getopt_long (int argc, char *const *argv, const char *__shortopts, | 150 extern int getopt_long (int ___argc, char *const *___argv, |
151 const char *__shortopts, | |
141 const struct option *__longopts, int *__longind); | 152 const struct option *__longopts, int *__longind); |
142 extern int getopt_long_only (int argc, char *const *argv, | 153 extern int getopt_long_only (int ___argc, char *const *___argv, |
143 const char *__shortopts, | 154 const char *__shortopts, |
144 const struct option *__longopts, int *__longind); | 155 const struct option *__longopts, int *__longind); |
145 | 156 |
146 /* Internal only. Users should not call this directly. */ | 157 /* Internal only. Users should not call this directly. */ |
147 extern int _getopt_internal (int argc, char *const *argv, | 158 extern int _getopt_internal (int ___argc, char *const *___argv, |
148 const char *__shortopts, | 159 const char *__shortopts, |
149 const struct option *__longopts, int *__longind, | 160 const struct option *__longopts, int *__longind, |
150 int __long_only); | 161 int __long_only); |
151 # endif | 162 # endif |
152 #else /* not __STDC__ */ | 163 #else /* not __STDC__ */ |