From: <li...@mi...> - 2007-06-30 15:17:13
|
Hi Mike, this is the usage() function of the mycopy3 example as it is now: void usage(char *executable) { printf("\ usage: %s [ -iohv ] file\n\ [ -i ] [ --iterations ] (type=INTEGER, range=0..., default=1)\n\ Number of times to output <file>.\n\ File should be text format!\n\ [ -o ] [ --outfile ] (type=STRING)\n\ Output file.\n\ [ -h ] [ --help ] (type=FLAG)\n\ Display help information.\n\ [ -v ] [ --version ] (type=FLAG)\n\ Output version.\n", executable); exit(1); } I propose to change it like this: void usage(int status, char *executable) { if (status != EXIT_SUCCESS) fprintf(stderr, "Try `%s --help' for more information.\n", executable); else { printf("\ usage: %s [ -iohv ] file\n\ [ -i ] [ --iterations ] (type=INTEGER, range=0..., default=1)\n\ Number of times to output <file>.\n\ File should be text format!\n\ [ -o ] [ --outfile ] (type=STRING)\n\ Output file.\n\ [ -h ] [ --help ] (type=FLAG)\n\ Display help information.\n\ [ -v ] [ --version ] (type=FLAG)\n\ Output version.\n", executable); } exit(status); } Another proposal is to add a new command line switch -i / --internationalization and put the internationalization macro _() around strings in the usage() function. Invoking Genparse with -i set would result in the following usage() function: void usage(int status, char *executable) { if (status != EXIT_SUCCESS) fprintf(stderr, _("Try `%s --help' for more information.\n"), executable); else { printf(_("\ usage: %s [ -iohv ] file\n\ [ -i ] [ --iterations ] (type=INTEGER, range=0..., default=1)\n\ Number of times to output <file>.\n\ File should be text format!\n\ [ -o ] [ --outfile ] (type=STRING)\n\ Output file.\n\ [ -h ] [ --help ] (type=FLAG)\n\ Display help information.\n\ [ -v ] [ --version ] (type=FLAG)\n\ Output version.\n"), executable); } exit(status); } Michael |