mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-06 18:04:21 +00:00
wrc: Avoid using getopt_long().
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
7420715b99
commit
3b0540edd0
137
tools/wrc/wrc.c
137
tools/wrc/wrc.c
|
@ -31,9 +31,6 @@
|
|||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <signal.h>
|
||||
#ifdef HAVE_GETOPT_H
|
||||
# include <getopt.h>
|
||||
#endif
|
||||
|
||||
#include "../tools.h"
|
||||
#include "wrc.h"
|
||||
|
@ -154,9 +151,14 @@ static int pointer_size = sizeof(void *);
|
|||
static int verify_translations_mode;
|
||||
|
||||
static char *output_name; /* The name given by the -o option */
|
||||
char *input_name = NULL; /* The name given on the command-line */
|
||||
const char *input_name = NULL; /* The name given on the command-line */
|
||||
static char *temp_name = NULL; /* Temporary file for preprocess pipe */
|
||||
static struct strarray input_files;
|
||||
|
||||
static int stdinc = 1;
|
||||
static int po_mode;
|
||||
static const char *po_dir;
|
||||
static const char *sysroot = "";
|
||||
static const char *includedir;
|
||||
const char *nlsdirs[3] = { NULL, NLSDIR, NULL };
|
||||
|
||||
|
@ -188,32 +190,32 @@ enum long_options_values
|
|||
|
||||
static const char short_options[] =
|
||||
"b:D:Ef:F:hi:I:J:l:m:o:O:ruU:v";
|
||||
static const struct option long_options[] = {
|
||||
{ "debug", 1, NULL, LONG_OPT_DEBUG },
|
||||
{ "define", 1, NULL, 'D' },
|
||||
{ "endianness", 1, NULL, LONG_OPT_ENDIANNESS },
|
||||
{ "help", 0, NULL, 'h' },
|
||||
{ "include-dir", 1, NULL, 'I' },
|
||||
{ "input", 1, NULL, 'i' },
|
||||
{ "input-format", 1, NULL, 'J' },
|
||||
{ "language", 1, NULL, 'l' },
|
||||
{ "nls-dir", 1, NULL, LONG_OPT_NLS_DIR },
|
||||
{ "no-use-temp-file", 0, NULL, LONG_OPT_NOTMPFILE },
|
||||
{ "nostdinc", 0, NULL, LONG_OPT_NOSTDINC },
|
||||
{ "output", 1, NULL, 'o' },
|
||||
{ "output-format", 1, NULL, 'O' },
|
||||
{ "pedantic", 0, NULL, LONG_OPT_PEDANTIC },
|
||||
{ "po-dir", 1, NULL, LONG_OPT_PO_DIR },
|
||||
{ "preprocessor", 1, NULL, LONG_OPT_PREPROCESSOR },
|
||||
{ "sysroot", 1, NULL, LONG_OPT_SYSROOT },
|
||||
{ "target", 1, NULL, 'F' },
|
||||
{ "utf8", 0, NULL, 'u' },
|
||||
{ "undefine", 1, NULL, 'U' },
|
||||
{ "use-temp-file", 0, NULL, LONG_OPT_TMPFILE },
|
||||
{ "verbose", 0, NULL, 'v' },
|
||||
{ "verify-translations", 0, NULL, LONG_OPT_VERIFY_TRANSL },
|
||||
{ "version", 0, NULL, LONG_OPT_VERSION },
|
||||
{ NULL, 0, NULL, 0 }
|
||||
static const struct long_option long_options[] = {
|
||||
{ "debug", 1, LONG_OPT_DEBUG },
|
||||
{ "define", 1, 'D' },
|
||||
{ "endianness", 1, LONG_OPT_ENDIANNESS },
|
||||
{ "help", 0, 'h' },
|
||||
{ "include-dir", 1, 'I' },
|
||||
{ "input", 1, 'i' },
|
||||
{ "input-format", 1, 'J' },
|
||||
{ "language", 1, 'l' },
|
||||
{ "nls-dir", 1, LONG_OPT_NLS_DIR },
|
||||
{ "no-use-temp-file", 0, LONG_OPT_NOTMPFILE },
|
||||
{ "nostdinc", 0, LONG_OPT_NOSTDINC },
|
||||
{ "output", 1, 'o' },
|
||||
{ "output-format", 1, 'O' },
|
||||
{ "pedantic", 0, LONG_OPT_PEDANTIC },
|
||||
{ "po-dir", 1, LONG_OPT_PO_DIR },
|
||||
{ "preprocessor", 1, LONG_OPT_PREPROCESSOR },
|
||||
{ "sysroot", 1, LONG_OPT_SYSROOT },
|
||||
{ "target", 1, 'F' },
|
||||
{ "utf8", 0, 'u' },
|
||||
{ "undefine", 1, 'U' },
|
||||
{ "use-temp-file", 0, LONG_OPT_TMPFILE },
|
||||
{ "verbose", 0, 'v' },
|
||||
{ "verify-translations", 0, LONG_OPT_VERIFY_TRANSL },
|
||||
{ "version", 0, LONG_OPT_VERSION },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static void set_version_defines(void)
|
||||
|
@ -350,34 +352,7 @@ static void init_argv0_dir( const char *argv0 )
|
|||
#endif
|
||||
}
|
||||
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
int optc;
|
||||
int opti = 0;
|
||||
int stdinc = 1;
|
||||
int lose = 0;
|
||||
int nb_files = 0;
|
||||
int i;
|
||||
int po_mode = 0;
|
||||
char *po_dir = NULL;
|
||||
const char *sysroot = "";
|
||||
char **files = xmalloc( argc * sizeof(*files) );
|
||||
|
||||
signal(SIGSEGV, segvhandler);
|
||||
signal( SIGTERM, exit_on_signal );
|
||||
signal( SIGINT, exit_on_signal );
|
||||
#ifdef SIGHUP
|
||||
signal( SIGHUP, exit_on_signal );
|
||||
#endif
|
||||
init_argv0_dir( argv[0] );
|
||||
|
||||
/* Set the default defined stuff */
|
||||
set_version_defines();
|
||||
wpp_add_cmdline_define("RC_INVOKED=1");
|
||||
/* Microsoft RC always searches current directory */
|
||||
wpp_add_include_path(".");
|
||||
|
||||
while((optc = getopt_long(argc, argv, short_options, long_options, &opti)) != EOF)
|
||||
static void option_callback( int optc, char *optarg )
|
||||
{
|
||||
switch(optc)
|
||||
{
|
||||
|
@ -426,8 +401,7 @@ int main(int argc,char *argv[])
|
|||
byteorder = WRC_BO_BIG;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Byte ordering must be n[ative], l[ittle] or b[ig]\n");
|
||||
lose++;
|
||||
error("Byte ordering must be n[ative], l[ittle] or b[ig]\n");
|
||||
}
|
||||
break;
|
||||
case LONG_OPT_PEDANTIC:
|
||||
|
@ -450,7 +424,7 @@ int main(int argc,char *argv[])
|
|||
printf(usage);
|
||||
exit(0);
|
||||
case 'i':
|
||||
files[nb_files++] = optarg;
|
||||
strarray_add( &input_files, optarg );
|
||||
break;
|
||||
case 'I':
|
||||
wpp_add_include_path(optarg);
|
||||
|
@ -499,17 +473,32 @@ int main(int argc,char *argv[])
|
|||
case 'v':
|
||||
debuglevel = DEBUGLEVEL_CHAT;
|
||||
break;
|
||||
default:
|
||||
lose++;
|
||||
break;
|
||||
case '?':
|
||||
fprintf(stderr, "wrc: %s\n\n%s", optarg, usage);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if(lose)
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
fprintf(stderr, usage);
|
||||
return 1;
|
||||
}
|
||||
int i;
|
||||
|
||||
signal(SIGSEGV, segvhandler);
|
||||
signal( SIGTERM, exit_on_signal );
|
||||
signal( SIGINT, exit_on_signal );
|
||||
#ifdef SIGHUP
|
||||
signal( SIGHUP, exit_on_signal );
|
||||
#endif
|
||||
init_argv0_dir( argv[0] );
|
||||
|
||||
/* Set the default defined stuff */
|
||||
set_version_defines();
|
||||
wpp_add_cmdline_define("RC_INVOKED=1");
|
||||
/* Microsoft RC always searches current directory */
|
||||
wpp_add_include_path(".");
|
||||
|
||||
strarray_addall( &input_files,
|
||||
parse_options( argc, argv, short_options, long_options, 0, option_callback ));
|
||||
|
||||
if (win32)
|
||||
{
|
||||
|
@ -555,15 +544,13 @@ int main(int argc,char *argv[])
|
|||
|
||||
atexit(cleanup_files);
|
||||
|
||||
while (optind < argc) files[nb_files++] = argv[optind++];
|
||||
|
||||
for (i = 0; i < nb_files; i++)
|
||||
for (i = 0; i < input_files.count; i++)
|
||||
{
|
||||
input_name = files[i];
|
||||
input_name = input_files.str[i];
|
||||
if (load_file( input_name, output_name )) exit(1);
|
||||
}
|
||||
/* stdin special case. NULL means "stdin" for wpp. */
|
||||
if (nb_files == 0 && load_file( NULL, output_name )) exit(1);
|
||||
if (input_files.count == 0 && load_file( NULL, output_name )) exit(1);
|
||||
|
||||
if(debuglevel & DEBUGLEVEL_DUMP)
|
||||
dump_resources(resource_top);
|
||||
|
@ -585,7 +572,7 @@ int main(int argc,char *argv[])
|
|||
{
|
||||
if (!output_name)
|
||||
{
|
||||
const char *name = nb_files ? get_basename(files[0]) : "wrc.tab";
|
||||
const char *name = input_files.count ? get_basename(input_files.str[0]) : "wrc.tab";
|
||||
output_name = replace_extension( name, ".rc", ".pot" );
|
||||
}
|
||||
write_pot_file( output_name );
|
||||
|
@ -602,7 +589,7 @@ int main(int argc,char *argv[])
|
|||
chat("Writing .res-file\n");
|
||||
if (!output_name)
|
||||
{
|
||||
const char *name = nb_files ? get_basename(files[0]) : "wrc.tab";
|
||||
const char *name = input_files.count ? get_basename(input_files.str[0]) : "wrc.tab";
|
||||
output_name = replace_extension( name, ".rc", ".res" );
|
||||
}
|
||||
write_resfile(output_name, resource_top);
|
||||
|
|
|
@ -41,8 +41,7 @@ extern int no_preprocess;
|
|||
extern int utf8_input;
|
||||
extern int check_utf8;
|
||||
|
||||
extern char *input_name;
|
||||
|
||||
extern const char *input_name;
|
||||
extern const char *nlsdirs[];
|
||||
|
||||
extern int line_number;
|
||||
|
|
Loading…
Reference in a new issue