Commit a4fc84bd authored by Alexandre Julliard's avatar Alexandre Julliard

wmc: Add --nls-dir option.

parent 64ff68c8
......@@ -11,6 +11,10 @@ C_SRCS = \
BISON_SRCS = mcy.y
wmc_EXTRADEFS = \
-DNLSDIR="\"${nlsdir}\"" \
-DBIN_TO_NLSDIR=\"`$(MAKEDEP) -R ${bindir} ${nlsdir}`\"
EXTRALIBS = $(GETTEXTPO_LIBS)
INSTALL_DEV = $(PROGRAMS)
......@@ -50,6 +50,7 @@ static const char usage[] =
" -h, --help Print this message\n"
" -H FILE Write header file to FILE (default is inputfile.h)\n"
" -i Inline messagetable(s)\n"
" --nls-dir=DIR Directory containing the NLS codepage mappings\n"
" -o, --output=FILE Output to FILE (default is infile.rc)\n"
" -O, --output-format=FORMAT The output format (`rc', `res', or `pot')\n"
" -P, --po-dir=DIR Directory containing po files for translations\n"
......@@ -109,6 +110,8 @@ char *output_name = NULL; /* The name given by the -o option */
char *input_name = NULL; /* The name given on the command-line */
char *header_name = NULL; /* The name given by the -H option */
const char *nlsdirs[3] = { NULL, NLSDIR, NULL };
int line_number = 1; /* The current line */
int char_number = 1; /* The current char pos within the line */
......@@ -127,10 +130,16 @@ static enum
FORMAT_POT
} output_format;
enum long_options_values
{
LONG_OPT_NLS_DIR = 1,
};
static const char short_options[] = "B:cdDhH:io:O:P:uUvVW";
static const struct option long_options[] =
{
{ "help", 0, NULL, 'h' },
{ "nls-dir", 1, NULL, LONG_OPT_NLS_DIR },
{ "output", 1, NULL, 'o' },
{ "output-format", 1, NULL, 'O' },
{ "pedantic", 0, NULL, 'W' },
......@@ -151,6 +160,28 @@ static void exit_on_signal( int sig )
exit(1); /* this will call the atexit functions */
}
static void init_argv0_dir( const char *argv0 )
{
#ifndef _WIN32
char *p, *dir;
#if defined(__linux__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
dir = realpath( "/proc/self/exe", NULL );
#elif defined (__FreeBSD__) || defined(__DragonFly__)
dir = realpath( "/proc/curproc/file", NULL );
#else
dir = realpath( argv0, NULL );
#endif
if (!dir) return;
if (!(p = strrchr( dir, '/' ))) return;
if (p == dir) p++;
*p = 0;
if (strendswith( dir, "/tools/wmc" )) nlsdirs[0] = strmake( "%s/../../nls", dir );
else nlsdirs[0] = strmake( "%s/%s", dir, BIN_TO_NLSDIR );
free( dir );
#endif
}
int main(int argc,char *argv[])
{
int optc;
......@@ -167,6 +198,7 @@ int main(int argc,char *argv[])
#ifdef SIGHUP
signal( SIGHUP, exit_on_signal );
#endif
init_argv0_dir( argv[0] );
/* First rebuild the commandline to put in destination */
/* Could be done through env[], but not all OS-es support it */
......@@ -257,6 +289,9 @@ int main(int argc,char *argv[])
case 'W':
pedantic = 1;
break;
case LONG_OPT_NLS_DIR:
nlsdirs[0] = xstrdup( optarg );
break;
default:
lose++;
break;
......
......@@ -49,6 +49,8 @@ extern char *input_name;
extern char *header_name;
extern char *cmdline;
extern const char *nlsdirs[];
extern int line_number;
extern int char_number;
......
......@@ -45,6 +45,10 @@ Inline messagetable(s). This option skips the generation of all \fI.bin\fR files
and writes all output into the \fI.rc\fR file. This encoding is parsable with
wrc(1).
.TP
.BI \-\-nls-dir= directory
Specify the directory to search for the NLS files containing the
codepage mapping tables.
.TP
.BR \-o ,\ \-\-output =\fIfile
Output to \fIfile\fR. Default is \fIinputfile.rc\fR.
.TP
......@@ -94,9 +98,6 @@ The message compiler should be able to have multiple input files and combine
them into one output file. This would enable the splitting of languages into
separate files.
.PP
Unicode detection of the input is suboptimal, to say the least. It should
recognize byte order marks (BOM) and decide what to do.
.PP
Decimal output is completely lacking. Don't know whether it should be
implemented because it is a, well, non-informative format change. It is
recognized on the commandline for some form of compatibility.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment