1
0
mirror of https://git.zap.org.au/git/trader.git synced 2025-02-02 15:08:13 -05:00

Replace the global variable localeconv_info with lconvinfo

In general, verbosity is not really to be encouraged...
This commit is contained in:
John Zaitseff 2011-07-22 10:23:58 +10:00
parent 9ef1181c05
commit 4b4efd7851
6 changed files with 35 additions and 38 deletions

View File

@ -96,8 +96,7 @@ void exchange_stock (void)
}
// Handle the locale's currency symbol
snprintf(buf, BUFSIZE, "share (%s)",
localeconv_info.currency_symbol);
snprintf(buf, BUFSIZE, "share (%s)", lconvinfo.currency_symbol);
wattrset(curwin, ATTR_SUBTITLE);
mvwprintw(curwin, 4, 2, " %-22s %12s %10s %10s %10s ",
@ -341,17 +340,17 @@ void visit_bank (void)
mvwprintw(curwin, 3, 10, "How much do you wish to borrow? ");
wattron(curwin, A_BOLD);
if (localeconv_info.p_cs_precedes == 1) {
wprintw(curwin, "%s%s", localeconv_info.currency_symbol,
(localeconv_info.p_sep_by_space == 1) ? " " : "");
if (lconvinfo.p_cs_precedes == 1) {
wprintw(curwin, "%s%s", lconvinfo.currency_symbol,
(lconvinfo.p_sep_by_space == 1) ? " " : "");
n = 10;
} else {
getyx(curwin, y, x);
n = strlen(localeconv_info.currency_symbol) + 10
+ (localeconv_info.p_sep_by_space == 1);
n = strlen(lconvinfo.currency_symbol) + 10
+ (lconvinfo.p_sep_by_space == 1);
mvwprintw(curwin, y, getmaxx(curwin) - n, "%s%s",
(localeconv_info.p_sep_by_space == 1) ? " " : "",
localeconv_info.currency_symbol);
(lconvinfo.p_sep_by_space == 1) ? " " : "",
lconvinfo.currency_symbol);
wmove(curwin, y, x);
}
wattroff(curwin, A_BOLD);
@ -400,17 +399,17 @@ void visit_bank (void)
mvwprintw(curwin, 3, 10, "How much do you wish to repay? ");
wattron(curwin, A_BOLD);
if (localeconv_info.p_cs_precedes == 1) {
wprintw(curwin, "%s%s", localeconv_info.currency_symbol,
(localeconv_info.p_sep_by_space == 1) ? " " : "");
if (lconvinfo.p_cs_precedes == 1) {
wprintw(curwin, "%s%s", lconvinfo.currency_symbol,
(lconvinfo.p_sep_by_space == 1) ? " " : "");
n = 10;
} else {
getyx(curwin, y, x);
n = strlen(localeconv_info.currency_symbol) + 10
+ (localeconv_info.p_sep_by_space == 1);
n = strlen(lconvinfo.currency_symbol) + 10
+ (lconvinfo.p_sep_by_space == 1);
mvwprintw(curwin, y, getmaxx(curwin) - n, "%s%s",
(localeconv_info.p_sep_by_space == 1) ? " " : "",
localeconv_info.currency_symbol);
(lconvinfo.p_sep_by_space == 1) ? " " : "",
lconvinfo.currency_symbol);
wmove(curwin, y, x);
}
wattroff(curwin, A_BOLD);

View File

@ -456,8 +456,7 @@ void end_game (void)
"with a value of ", "%s", buf);
}
snprintf(buf, BUFSIZE, "Total Value (%s)",
localeconv_info.currency_symbol);
snprintf(buf, BUFSIZE, "Total Value (%s)", lconvinfo.currency_symbol);
int w = getmaxx(curwin) - 33;
wattrset(curwin, ATTR_SUBTITLE);
@ -636,8 +635,7 @@ void show_status (int num)
center(curwin, 8, ATTR_NORMAL, "No companies on the map");
} else {
// Handle the locale's currency symbol
snprintf(buf, BUFSIZE, "share (%s)",
localeconv_info.currency_symbol);
snprintf(buf, BUFSIZE, "share (%s)", lconvinfo.currency_symbol);
wattrset(curwin, ATTR_SUBTITLE);
mvwprintw(curwin, 4, 2, " %-22s %12s %10s %10s %10s ",

View File

@ -1146,7 +1146,7 @@ int gettxstr (WINDOW *win, char **bufptr, bool *restrict modified,
void txinput_fixup (char *restrict dest, char *restrict src, bool isfloat)
{
struct lconv *lc = &localeconv_info;
struct lconv *lc = &lconvinfo;
char *p;
@ -1200,7 +1200,7 @@ int gettxdouble (WINDOW *win, double *restrict result, double min,
double max, double emptyval, double defaultval,
int y, int x, int width, chtype attr)
{
struct lconv *lc = &localeconv_info;
struct lconv *lc = &lconvinfo;
char *buf, *bufcopy;
char *allowed, *emptystr, *defaultstr;
@ -1273,7 +1273,7 @@ int gettxlong (WINDOW *win, long int *restrict result, long int min,
long int max, long int emptyval, long int defaultval,
int y, int x, int width, chtype attr)
{
struct lconv *lc = &localeconv_info;
struct lconv *lc = &lconvinfo;
char *buf, *bufcopy;
char *allowed, *emptystr, *defaultstr;

View File

@ -779,7 +779,7 @@ void merge_companies (map_val_t a, map_val_t b)
"%-20s", company[aa].name);
// Handle the locale's currency symbol
snprintf(buf, BUFSIZE, "Bonus (%s)", localeconv_info.currency_symbol);
snprintf(buf, BUFSIZE, "Bonus (%s)", lconvinfo.currency_symbol);
int w = getmaxx(curwin) - 52;
wattrset(curwin, ATTR_SUBTITLE);

View File

@ -36,7 +36,7 @@
************************************************************************/
// Global copy, suitably modified, of localeconv() information
struct lconv localeconv_info;
struct lconv lconvinfo;
/************************************************************************
@ -315,7 +315,7 @@ void init_locale (void)
assert(current_mon_locale != NULL);
assert(lc != NULL);
localeconv_info = *lc;
lconvinfo = *lc;
/* Are we in the POSIX locale? This test may not be portable as the
string returned by setlocale() is supposed to be opaque. */
@ -324,10 +324,10 @@ void init_locale (void)
|| strcmp(current_mon_locale, "C") == 0) {
add_currency_symbol = true;
localeconv_info.currency_symbol = MOD_POSIX_CURRENCY_SYMBOL;
localeconv_info.frac_digits = MOD_POSIX_FRAC_DIGITS;
localeconv_info.p_cs_precedes = MOD_POSIX_P_CS_PRECEDES;
localeconv_info.p_sep_by_space = MOD_POSIX_P_SEP_BY_SPACE;
lconvinfo.currency_symbol = MOD_POSIX_CURRENCY_SYMBOL;
lconvinfo.frac_digits = MOD_POSIX_FRAC_DIGITS;
lconvinfo.p_cs_precedes = MOD_POSIX_P_CS_PRECEDES;
lconvinfo.p_sep_by_space = MOD_POSIX_P_SEP_BY_SPACE;
}
}
@ -349,12 +349,12 @@ ssize_t l_strfmon (char *restrict s, size_t maxsize,
if (ret > 0 && add_currency_symbol) {
if (strstr(format, "!") == NULL) {
/* Insert localeconv_info.currency_symbol to s.
/* Insert lconvinfo.currency_symbol to s.
NB: add_currecy_symbol == true assumes POSIX locale:
single-byte strings are in effect, so strlen(), etc, work
correctly. */
const char *sym = localeconv_info.currency_symbol;
const char *sym = lconvinfo.currency_symbol;
int symlen = strlen(sym);
char *p;
int spc;

View File

@ -47,7 +47,7 @@
************************************************************************/
// Global copy, suitably modified, of localeconv() information
extern struct lconv localeconv_info;
extern struct lconv lconvinfo;
/************************************************************************
@ -226,11 +226,11 @@ extern int randi (int limit);
Parameters: (none)
Returns: (nothing)
This function initialises the global variable localeconv_info with
values suitable for this program. In particular, if the POSIX or C
locale is in effect, the currency_symbol and frac_digits members are
updated to be something reasonable. This function must be called
before using localeconf_info.
This function initialises the global variable lconvinfo with values
suitable for this program. In particular, if the POSIX or C locale is
in effect, the currency_symbol and frac_digits members are updated to
be something reasonable. This function must be called before using
localeconf_info.
*/
extern void init_locale (void);