1
0
mirror of https://git.zap.org.au/git/trader.git synced 2024-09-15 17:28:07 -04:00

Be a little more diligent when it comes to wchar_t vs. wint_t

The %lc format is actually of type wint_t, according to printf(3), not
wchar_t, even though these are of the same underlying type on most (all?)
platforms.
This commit is contained in:
John Zaitseff 2011-08-29 14:13:29 +10:00
parent df3ccfd583
commit 4ca99815b8
5 changed files with 13 additions and 10 deletions

View File

@ -290,7 +290,7 @@ static int ask_number_players (void)
done = true; done = true;
} else if (wcschr(keycode_contgame, key) != NULL) { } else if (wcschr(keycode_contgame, key) != NULL) {
left(curwin, getcury(curwin), getcurx(curwin), A_BOLD, left(curwin, getcury(curwin), getcurx(curwin), A_BOLD,
0, 0, 1, "%lc", *keycode_contgame); 0, 0, 1, "%lc", (wint_t) *keycode_contgame);
wrefresh(curwin); wrefresh(curwin);
ret = 0; ret = 0;

View File

@ -156,7 +156,7 @@ typedef struct txwin {
enum argument_type { enum argument_type {
TYPE_NONE, // No type yet assigned TYPE_NONE, // No type yet assigned
TYPE_CHAR, // char TYPE_CHAR, // char
TYPE_WCHAR, // wchar_t TYPE_WCHAR, // wint_t
TYPE_INT, // int TYPE_INT, // int
TYPE_LONGINT, // long int TYPE_LONGINT, // long int
TYPE_DOUBLE, // double TYPE_DOUBLE, // double
@ -168,7 +168,7 @@ struct argument {
enum argument_type a_type; enum argument_type a_type;
union a { union a {
char a_char; char a_char;
wchar_t a_wchar; wint_t a_wchar;
int a_int; int a_int;
long int a_longint; long int a_longint;
double a_double; double a_double;
@ -1092,9 +1092,10 @@ int mkchstr_parse (const wchar_t *restrict format,
break; break;
case TYPE_WCHAR: case TYPE_WCHAR:
format_arg->a.a_wchar = (wchar_t) (sizeof(wchar_t) < sizeof(int) ? format_arg->a.a_wchar =
(wint_t) (sizeof(wint_t) < sizeof(int) ?
va_arg(args, int) : va_arg(args, int) :
va_arg(args, wchar_t)); va_arg(args, wint_t));
break; break;
case TYPE_INT: case TYPE_INT:

View File

@ -365,7 +365,7 @@ extern int txdlgbox (int maxlines, int ncols, int begin_y, int begin_x,
%% - Insert the ASCII percent sign (ASCII code U+0025) %% - Insert the ASCII percent sign (ASCII code U+0025)
%c - Insert the next parameter as a character (type char) %c - Insert the next parameter as a character (type char)
%lc - Insert the next parameter as a wide char (type wchar_t) %lc - Insert the next parameter as a wide char (type wint_t)
%s - Insert the next parameter as a string (type char *) %s - Insert the next parameter as a string (type char *)
%ls - Insert the next parameter as a wide string (type wchar_t *) %ls - Insert the next parameter as a wide string (type wchar_t *)
%d - Insert the next parameter as an integer (type int) %d - Insert the next parameter as an integer (type int)

View File

@ -243,7 +243,8 @@ selection_t get_move (void)
right(curwin, 1, getmaxx(curwin) / 2, attr_normal, attr_keycode, right(curwin, 1, getmaxx(curwin) / 2, attr_normal, attr_keycode,
attr_choice, 1, attr_choice, 1,
_("Select move [^[%lc^]-^[%lc^]/^{1^}-^{3^}/^{<CTRL><C>^}]: "), _("Select move [^[%lc^]-^[%lc^]/^{1^}-^{3^}/^{<CTRL><C>^}]: "),
PRINTABLE_GAME_MOVE(0), PRINTABLE_GAME_MOVE(NUMBER_MOVES - 1)); (wint_t) PRINTABLE_GAME_MOVE(0),
(wint_t) PRINTABLE_GAME_MOVE(NUMBER_MOVES - 1));
curs_set(CURS_ON); curs_set(CURS_ON);
wrefresh(curwin); wrefresh(curwin);
@ -274,7 +275,8 @@ selection_t get_move (void)
/* TRANSLATORS: "Move" refers to the choice of /* TRANSLATORS: "Move" refers to the choice of
moves made by the current player (out of a moves made by the current player (out of a
selection of 20 moves). */ selection of 20 moves). */
_("Move ^{%lc^}"), PRINTABLE_GAME_MOVE(i)); _("Move ^{%lc^}"),
(wint_t) PRINTABLE_GAME_MOVE(i));
break; break;
} }

View File

@ -613,7 +613,7 @@ size_t xwcrtomb (char *restrict dest, wchar_t wc, mbstate_t *restrict mbstate)
dest[n] = EILSEQ_REPL; dest[n] = EILSEQ_REPL;
dest[n++] = '\0'; dest[n++] = '\0';
} else { } else {
errno_exit(_("xwcrtomb: `%lc'"), wc); errno_exit(_("xwcrtomb: `%lc'"), (wint_t) wc);
} }
} }