make_xftmpl: Avoid using getopt().
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
e0ef12241b
commit
5f921c7f1b
|
@ -25,9 +25,6 @@
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#ifdef HAVE_GETOPT_H
|
|
||||||
# include <getopt.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -91,8 +88,6 @@ static const struct keyword reserved_words[] = {
|
||||||
{"WORD", TOKEN_WORD}
|
{"WORD", TOKEN_WORD}
|
||||||
};
|
};
|
||||||
|
|
||||||
extern int getopt(int argc, char *const *argv, const char *optstring);
|
|
||||||
|
|
||||||
static BOOL option_header;
|
static BOOL option_header;
|
||||||
static char *option_inc_var_name = NULL;
|
static char *option_inc_var_name = NULL;
|
||||||
static char *option_inc_size_name = NULL;
|
static char *option_inc_size_name = NULL;
|
||||||
|
@ -419,12 +414,8 @@ static void usage(void)
|
||||||
program_name);
|
program_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char **parse_options(int argc, char **argv)
|
static void option_callback( int optc, char *optarg )
|
||||||
{
|
{
|
||||||
int optc;
|
|
||||||
|
|
||||||
while ((optc = getopt(argc, argv, "hHi:o:s:")) != -1)
|
|
||||||
{
|
|
||||||
switch (optc)
|
switch (optc)
|
||||||
{
|
{
|
||||||
case 'h':
|
case 'h':
|
||||||
|
@ -443,26 +434,27 @@ static char **parse_options(int argc, char **argv)
|
||||||
case 's':
|
case 's':
|
||||||
option_inc_size_name = xstrdup(optarg);
|
option_inc_size_name = xstrdup(optarg);
|
||||||
break;
|
break;
|
||||||
|
case '?':
|
||||||
|
fprintf( stderr, "%s: %s\n", program_name, optarg );
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return &argv[optind];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
char header[16];
|
char header[16];
|
||||||
char **args;
|
struct strarray args;
|
||||||
char *header_name = NULL;
|
char *header_name = NULL;
|
||||||
|
|
||||||
program_name = argv[0];
|
program_name = argv[0];
|
||||||
|
|
||||||
args = parse_options(argc, argv);
|
args = parse_options(argc, argv, "hHi:o:s:", NULL, 0, option_callback );
|
||||||
infile_name = *args++;
|
if (!args.count)
|
||||||
if (!infile_name || *args)
|
|
||||||
{
|
{
|
||||||
usage();
|
usage();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
infile_name = args.str[0];
|
||||||
|
|
||||||
infile = stdin;
|
infile = stdin;
|
||||||
outfile = NULL;
|
outfile = NULL;
|
||||||
|
|
Loading…
Reference in New Issue