tUse string character length where appropriate - vaccinewars - be a doctor and … | |
git clone git://src.adamsgaard.dk/vaccinewars | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit d789fa510de3ce5bd2103cdb5e496e5ce6f2d0ba | |
parent e2c471ccf83d4958b6c7df7700bb4de35d52e535 | |
Author: Ben Webb <[email protected]> | |
Date: Wed, 9 Dec 2020 16:54:34 -0800 | |
Use string character length where appropriate | |
Use length of the string in characters, not bytes, | |
where this makes more sense. | |
Diffstat: | |
M src/curses_client/curses_client.c | 14 +++++++------- | |
1 file changed, 7 insertions(+), 7 deletions(-) | |
--- | |
diff --git a/src/curses_client/curses_client.c b/src/curses_client/curses_clien… | |
t@@ -279,7 +279,7 @@ static void mvaddcentstr(const int row, const gchar *str) | |
static void mvaddfixwidstr(const int row, const int col, const int wid, | |
const gchar *str, const int attrs) | |
{ | |
- int strwid = str ? strcharlen(str) : 0; | |
+ int strwid = str ? strlen(str) : 0; | |
int strind; | |
strwid = MIN(strwid, wid); | |
t@@ -935,7 +935,7 @@ static void DealDrugs(Player *Play, gboolean Buy) | |
CanAfford, CanCarry); | |
mvaddstr(get_prompt_line() + 1, 2, text); | |
input = nice_input(_("How many do you buy? "), get_prompt_line() + 1, | |
- 2 + strlen(text), TRUE, NULL, '\0'); | |
+ 2 + strcharlen(text), TRUE, NULL, '\0'); | |
c = atoi(input); | |
g_free(input); | |
g_free(text); | |
t@@ -951,7 +951,7 @@ static void DealDrugs(Player *Play, gboolean Buy) | |
Play->Drugs[DrugNum].Carried); | |
mvaddstr(get_prompt_line() + 1, 2, text); | |
input = nice_input(_("How many do you sell? "), get_prompt_line() + 1, | |
- 2 + strlen(text), TRUE, NULL, '\0'); | |
+ 2 + strcharlen(text), TRUE, NULL, '\0'); | |
c = atoi(input); | |
g_free(input); | |
g_free(text); | |
t@@ -1276,7 +1276,7 @@ void PrepareHighScoreScreen(void) | |
clear_screen(); | |
attrset(TitleAttr); | |
text = _("H I G H S C O R E S"); | |
- mvaddstr(0, (Width - strlen(text)) / 2, text); | |
+ mvaddstr(0, (Width - strcharlen(text)) / 2, text); | |
attrset(TextAttr); | |
} | |
t@@ -2040,7 +2040,7 @@ void print_status(Player *Play, gboolean DispDrug) | |
is ignored, so you don't need to translate it; see doc/i18n.html) | |
*/ | |
dpg_string_printf(text, _("%/Stats: Drugs/%Tde"), Names.Drugs); | |
- mvaddstr(1, Width * 3 / 4 - strlen(text->str) / 2, text->str); | |
+ mvaddstr(1, Width * 3 / 4 - strcharlen(text->str) / 2, text->str); | |
} | |
for (i = 0; i < NumDrug; i++) { | |
if (Play->Drugs[i].Carried > 0) { | |
t@@ -2065,7 +2065,7 @@ void print_status(Player *Play, gboolean DispDrug) | |
/* Title of the "guns" window (the only important bit in this string | |
is the "%Tde" which is "Guns" by default) */ | |
dpg_string_printf(text, _("%/Stats: Guns/%Tde"), Names.Guns); | |
- mvaddstr(1, Width * 3 / 4 - strlen(text->str) / 2, text->str); | |
+ mvaddstr(1, Width * 3 / 4 - strcharlen(text->str) / 2, text->str); | |
for (i = 0; i < NumGun; i++) { | |
if (Play->Guns[i].Carried > 0) { | |
/* Display of carried guns (%tde="Baretta", etc. by default) */ | |
t@@ -2218,7 +2218,7 @@ char *nice_input(char *prompt, int sy, int sx, gboolean … | |
if (prompt) { | |
attrset(PromptAttr); | |
addstr(prompt); | |
- x += strlen(prompt); | |
+ x += strcharlen(prompt); | |
} | |
attrset(TextAttr); | |
if (displaystr) { |