mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-06 17:31:14 -03:00
Provide fallback version of getopt_long instead of checking for it's presense every time it is used
darcs-hash:20060828114305-ac50b-f4aad19e936fa42bbe84e51e72aa32445a469527.gz
This commit is contained in:
15
fallback.c
15
fallback.c
@@ -1076,3 +1076,18 @@ int killpg( int pgr, int sig )
|
|||||||
return kill( -pgr, sig );
|
return kill( -pgr, sig );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_WORKING_GETOPT_LONG
|
||||||
|
|
||||||
|
int getopt_long(int argc,
|
||||||
|
char * const argv[],
|
||||||
|
const char *optstring,
|
||||||
|
const struct option *longopts,
|
||||||
|
int *longindex)
|
||||||
|
{
|
||||||
|
return getopt( argc, argv, optstring );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|||||||
32
fallback.h
32
fallback.h
@@ -385,5 +385,37 @@ extern int _nl_msg_cat_cntr;
|
|||||||
int killpg( int pgr, int sig );
|
int killpg( int pgr, int sig );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef HAVE_WORKING_GETOPT_LONG
|
||||||
|
|
||||||
|
struct option
|
||||||
|
{
|
||||||
|
const char *name;
|
||||||
|
int has_arg;
|
||||||
|
int *flag;
|
||||||
|
int val;
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
|
#ifndef no_argument
|
||||||
|
#define no_argument 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef required_argument
|
||||||
|
#define required_argument 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef optional_argument
|
||||||
|
#define optional_argument 2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int getopt_long(int argc,
|
||||||
|
char * const argv[],
|
||||||
|
const char *optstring,
|
||||||
|
const struct option *longopts,
|
||||||
|
int *longindex);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
6
fishd.c
6
fishd.c
@@ -494,7 +494,6 @@ int main( int argc, char ** argv )
|
|||||||
*/
|
*/
|
||||||
while( 1 )
|
while( 1 )
|
||||||
{
|
{
|
||||||
#ifdef HAVE_WORKING_GETOPT_LONG
|
|
||||||
static struct option
|
static struct option
|
||||||
long_options[] =
|
long_options[] =
|
||||||
{
|
{
|
||||||
@@ -520,11 +519,6 @@ int main( int argc, char ** argv )
|
|||||||
long_options,
|
long_options,
|
||||||
&opt_index );
|
&opt_index );
|
||||||
|
|
||||||
#else
|
|
||||||
int opt = getopt( argc,
|
|
||||||
argv,
|
|
||||||
GETOPT_STRING );
|
|
||||||
#endif
|
|
||||||
if( opt == -1 )
|
if( opt == -1 )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
6
main.c
6
main.c
@@ -123,7 +123,6 @@ int main( int argc, char **argv )
|
|||||||
|
|
||||||
while( 1 )
|
while( 1 )
|
||||||
{
|
{
|
||||||
#ifdef HAVE_WORKING_GETOPT_LONG
|
|
||||||
static struct option
|
static struct option
|
||||||
long_options[] =
|
long_options[] =
|
||||||
{
|
{
|
||||||
@@ -173,11 +172,6 @@ int main( int argc, char **argv )
|
|||||||
long_options,
|
long_options,
|
||||||
&opt_index );
|
&opt_index );
|
||||||
|
|
||||||
#else
|
|
||||||
int opt = getopt( argc,
|
|
||||||
argv,
|
|
||||||
GETOPT_STRING );
|
|
||||||
#endif
|
|
||||||
if( opt == -1 )
|
if( opt == -1 )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
6
mimedb.c
6
mimedb.c
@@ -1168,7 +1168,6 @@ int main (int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
while( 1 )
|
while( 1 )
|
||||||
{
|
{
|
||||||
#ifdef HAVE_WORKING_GETOPT_LONG
|
|
||||||
static struct option
|
static struct option
|
||||||
long_options[] =
|
long_options[] =
|
||||||
{
|
{
|
||||||
@@ -1222,11 +1221,6 @@ int main (int argc, char *argv[])
|
|||||||
long_options,
|
long_options,
|
||||||
&opt_index );
|
&opt_index );
|
||||||
|
|
||||||
#else
|
|
||||||
int opt = getopt( argc,
|
|
||||||
argv,
|
|
||||||
GETOPT_STRING );
|
|
||||||
#endif
|
|
||||||
if( opt == -1 )
|
if( opt == -1 )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -153,7 +153,6 @@ int main( int argc, char **argv )
|
|||||||
|
|
||||||
while( 1 )
|
while( 1 )
|
||||||
{
|
{
|
||||||
#ifdef HAVE_WORKING_GETOPT_LONG
|
|
||||||
static struct option
|
static struct option
|
||||||
long_options[] =
|
long_options[] =
|
||||||
{
|
{
|
||||||
@@ -194,11 +193,7 @@ int main( int argc, char **argv )
|
|||||||
GETOPT_STRING,
|
GETOPT_STRING,
|
||||||
long_options,
|
long_options,
|
||||||
&opt_index );
|
&opt_index );
|
||||||
#else
|
|
||||||
int opt = getopt( argc,
|
|
||||||
argv,
|
|
||||||
GETOPT_STRING );
|
|
||||||
#endif
|
|
||||||
if( opt == -1 )
|
if( opt == -1 )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user