From: parasti Date: Mon, 12 Jun 2006 16:16:01 +0000 (+0000) Subject: Changed usage message from macro to a constant string. X-Git-Tag: fremantle/1.5.5-2~2095 X-Git-Url: http://vcs.maemo.org/git/?a=commitdiff_plain;ds=sidebyside;h=e3b3aff47e2333c7ce695811065e016c04a36ec8;p=neverball Changed usage message from macro to a constant string. git-svn-id: https://s.snth.net/svn/neverball/trunk@450 78b8d119-cf0a-0410-b17c-f493084dd1d7 --- diff --git a/ball/main.c b/ball/main.c index 832dd1c..e2ccc61 100644 --- a/ball/main.c +++ b/ball/main.c @@ -218,6 +218,7 @@ static int loop(void) /*---------------------------------------------------------------------------*/ /* Option values */ + static char *data_path = NULL; static char *replay_path = NULL; static char *level_path = NULL; @@ -225,28 +226,30 @@ static int display_info = 0; /* Option handling */ -#define USAGE _( \ - "Usage: %s [options ...]\n" \ - "-r, --replay file play the replay 'file'.\n" \ - "-l, --level file.sol play the level 'file.sol'.\n" \ - "-i, --info display info about level or replay.\n" \ - " --data dir use 'dir' as game data directory.\n" \ - "-v, --version show version.\n" \ - "-h, -?, --help show this usage message.\n") - static void parse_args(int argc, char **argv) { -#define CASE(x) (strcmp(*argv, (x)) == 0) /* Check current option */ -#define MAND !(missing = (argv[1] == NULL)) /* Argument is mandatory */ char *exec = *(argv++); int missing; /* Argument is missing. */ + const char *usage = _( + "Usage: %s [options ...]\n" + "-r, --replay file play the replay 'file'.\n" + "-l, --level file.sol play the level 'file.sol'.\n" + "-i, --info display info about level or replay.\n" + " --data dir use 'dir' as game data directory.\n" + "-v, --version show version.\n" + "-h, -?, --help show this usage message.\n" + ); + +#define CASE(x) (strcmp(*argv, (x)) == 0) /* Check current option */ +#define MAND !(missing = (argv[1] == NULL)) /* Argument is mandatory */ + while (*argv != NULL) { missing = 0; if (CASE("-h") || CASE("-?") || CASE("--help")) { - printf(USAGE, exec); + printf(usage, exec); exit(0); } else if (CASE("-v") || CASE("--version")) @@ -265,14 +268,14 @@ static void parse_args(int argc, char **argv) else if (!missing) { fprintf(stderr, _("%s: unknown option %s\n"), exec, *argv); - fprintf(stderr, USAGE, exec); + fprintf(stderr, usage, exec); exit(1); } else { fprintf(stderr, _("%s: option %s requires an argument\n"), exec, *argv); - fprintf(stderr, USAGE, exec); + fprintf(stderr, usage, exec); exit(1); } argv++;