mirror of
https://git.zap.org.au/git/trader.git
synced 2025-01-03 14:57:41 -05:00
Refactor preliminary initialisation code into init_program_prelim()
This commit is contained in:
parent
f1501a4004
commit
c525bc266f
47
src/trader.c
47
src/trader.c
@ -117,6 +117,19 @@ static void show_version (void) __attribute__((noreturn));
|
|||||||
static void show_usage (int status) __attribute__((noreturn));
|
static void show_usage (int status) __attribute__((noreturn));
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Function: init_program_prelim - Initialise program preliminaries
|
||||||
|
Parameters: argc - Same as passed to main()
|
||||||
|
argv - Same as passed to main()
|
||||||
|
Returns: (nothing)
|
||||||
|
|
||||||
|
This function initialises the program name, locale and message
|
||||||
|
catalogs. It must be called before command line arguments are
|
||||||
|
processed.
|
||||||
|
*/
|
||||||
|
static void init_program_prelim (int argc, char *argv[]);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Function: init_program - Initialise program-wide functions
|
Function: init_program - Initialise program-wide functions
|
||||||
Parameters: (none)
|
Parameters: (none)
|
||||||
@ -146,18 +159,8 @@ static void end_program (void);
|
|||||||
|
|
||||||
int main (int argc, char *argv[])
|
int main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
// Strip off leading pathname components from program name
|
// Initialise program name, locale and message catalogs
|
||||||
init_program_name(argv[0]);
|
init_program_prelim(argc, argv);
|
||||||
|
|
||||||
// Initialise the locale
|
|
||||||
if (setlocale(LC_ALL, "") == NULL) {
|
|
||||||
err_exit("could not set locale "
|
|
||||||
"(check LANG, LC_ALL and LANGUAGE in environment)");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use correct message catalogs for the locale
|
|
||||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
|
||||||
textdomain(PACKAGE);
|
|
||||||
|
|
||||||
// Process command line arguments
|
// Process command line arguments
|
||||||
process_cmdline(argc, argv);
|
process_cmdline(argc, argv);
|
||||||
@ -361,6 +364,26 @@ playing that game. If GAME is not specified, start a new game.\n\n\
|
|||||||
// These functions are documented at the start of this file
|
// These functions are documented at the start of this file
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
// init_program_prelim: Initialise program preliminaries
|
||||||
|
|
||||||
|
void init_program_prelim (int argc, char *argv[])
|
||||||
|
{
|
||||||
|
// Strip off leading pathname components from program name
|
||||||
|
init_program_name(argv[0]);
|
||||||
|
|
||||||
|
// Initialise the locale and message catalogs
|
||||||
|
if (setlocale(LC_ALL, "") == NULL) {
|
||||||
|
err_exit("could not set locale "
|
||||||
|
"(check LANG, LC_ALL and LANGUAGE in environment)");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use correct message catalogs for the locale
|
||||||
|
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||||
|
textdomain(PACKAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
// init_program: Initialise program-wide functions
|
// init_program: Initialise program-wide functions
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user