diff --git a/tools/wmc/wmc.c b/tools/wmc/wmc.c index c9ad9c4aa3e65690c3e6e9823e983b48b004ecf3..a08d733b0ed59ad268dc4c07d666c98b2e50e786 100644 --- a/tools/wmc/wmc.c +++ b/tools/wmc/wmc.c @@ -25,6 +25,9 @@ #include <stdlib.h> #include <string.h> #include <signal.h> +#ifdef HAVE_GETOPT_H +# include <getopt.h> +#endif #include "wmc.h" #include "utils.h" @@ -33,28 +36,28 @@ static const char usage[] = "Usage: wmc [options...] [inputfile.mc]\n" - " -B x Set output byte-order x={n[ative], l[ittle], b[ig]}\n" - " (default is n[ative] which equals " + " -B x Set output byte-order x={n[ative], l[ittle], b[ig]}\n" + " (default is n[ative] which equals " #ifdef WORDS_BIGENDIAN "big" #else "little" #endif "-endian)\n" - " -c Set 'custom-bit' in values\n" - " -d Use decimal values in output\n" - " -D Set debug flag\n" - " -h This message\n" - " -H file Write headerfile to file (default is inputfile.h)\n" - " -i Inline messagetable(s)\n" - " -o file Output to file (default is inputfile.rc)\n" - " -O fmt Set output format (rc, res, pot)\n" - " -P dir Directory where to find po files\n" - " -u Inputfile is in unicode\n" - " -U Output unicode messagetable(s)\n" - " -v Show supported codepages and languages\n" - " -V Print version end exit\n" - " -W Enable pedantic warnings\n" + " -c Set 'custom-bit' in values\n" + " -d Use decimal values in output\n" + " -D Set debug flag\n" + " -h, --help Print this message\n" + " -H FILE Write header file to FILE (default is inputfile.h)\n" + " -i Inline messagetable(s)\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" + " -u Input file is in unicode\n" + " -U Output unicode messagetable(s)\n" + " -v Show supported codepages and languages\n" + " -V, --version Print version end exit\n" + " -W, --pedantic Enable pedantic warnings\n" "Input is taken from stdin if no inputfile is specified.\n" "Byteorder of unicode input is based upon the first couple of\n" "bytes read, which should be 0x0000..0x00ff.\n" @@ -128,7 +131,17 @@ static enum FORMAT_POT } output_format; -int getopt (int argc, char *const *argv, const char *optstring); +static const char short_options[] = "B:cdDhH:io:O:P:uUvVW"; +static const struct option long_options[] = +{ + { "help", 0, NULL, 'h' }, + { "output", 1, NULL, 'o' }, + { "output-format", 1, NULL, 'O' }, + { "pedantic", 0, NULL, 'W' }, + { "po-dir", 1, NULL, 'P' }, + { "version", 0, NULL, 'v' } +}; + static void segvhandler(int sig); static void cleanup_files(void) @@ -147,6 +160,7 @@ int main(int argc,char *argv[]) extern char* optarg; extern int optind; int optc; + int opti = 0; int lose = 0; int ret; int i; @@ -176,7 +190,7 @@ int main(int argc,char *argv[]) strcat(cmdline, " "); } - while((optc = getopt(argc, argv, "B:cdDhH:io:O:P:uUvVW")) != EOF) + while((optc = getopt_long(argc, argv, short_options, long_options, &opti)) != EOF) { switch(optc) { @@ -325,7 +339,7 @@ int main(int argc,char *argv[]) write_bin_files(); break; case FORMAT_RES: - if (po_dir) add_translations( po_dir ); + add_translations( po_dir ); write_res_file( output_name ); break; case FORMAT_POT: diff --git a/tools/wmc/wmc.man.in b/tools/wmc/wmc.man.in index 890f71690fd2d4fc7f1f2d915aaa11b949021830..39356d6074e0da879acfea8a7dda1b9a00c89e3d 100644 --- a/tools/wmc/wmc.man.in +++ b/tools/wmc/wmc.man.in @@ -34,8 +34,8 @@ NON-FUNCTIONAL; Use decimal values in output .B \-D Set debug flag. This results is a parser trace and a lot of extra messages. .TP -.B \-h -Print an informative usage message. +.BR \-h ,\ \-\-help +Print an informative usage message and exits. .TP .BI \-H\ file Write headerfile to \fIfile\fR. Default is \fIinputfile.h\fR. @@ -45,14 +45,14 @@ 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 \-o\ file +.BR \-o ,\ \-\-output =\fIfile Output to \fIfile\fR. Default is \fIinputfile.rc\fR. .TP -.BI \-O\ format +.BR \-O ,\ \-\-output\-format =\fIformat Set the output format. Supported formats are \fBrc\fR (the default), \fBres\fR, and \fBpot\fR. .TP -.BI \-P\ directory +.BR \-P ,\ \-\-po-dir =\fIdirectory Enable the generation of resource translations based on po files loaded from the specified directory. That directory must follow the gettext convention, in particular in must contain one \fI.po\fR file for @@ -67,10 +67,10 @@ Write resource output in unicode formatted messagetable(s). .B \-v Show all supported codepages and languages. .TP -.B \-V +.BR \-V ,\ \-\-version Print version end exit. .TP -.B \-W +.BR \-W ,\ \-\-pedantic Enable pedantic warnings. .SH EXTENSIONS The original syntax is extended to support codepages more smoothly. Normally,