Use str_msg_term_size() instead of msglen()

... because msglen() is not tolerant to multi-byte encodings.
Remove msglen() because it unused now.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2010-11-13 21:33:26 +03:00
parent 71364f88c3
commit f24dd62dc2
4 changed files with 10 additions and 40 deletions

View File

@ -235,38 +235,6 @@ is_printable (int c)
#endif /* !HAVE_CHARSET */
}
/* --------------------------------------------------------------------------------------------- */
/**
* Calculates the message dimensions (lines and columns)
*
*/
void
msglen (const char *text, int *lines, int *columns)
{
int nlines = 1; /* even the empty string takes one line */
int ncolumns = 0;
int colindex = 0;
for (; *text != '\0'; text++)
{
if (*text == '\n')
{
nlines++;
colindex = 0;
}
else
{
colindex++;
if (colindex > ncolumns)
ncolumns = colindex;
}
}
*lines = nlines;
*columns = ncolumns;
}
/* --------------------------------------------------------------------------------------------- */
/**
* Quote the filename for the purpose of inserting it into the command

View File

@ -53,7 +53,6 @@ extern struct sigaction startup_handler;
/*** declarations of public functions ************************************************************/
int is_printable (int c);
void msglen (const char *text, /*@out@ */ int *lines, /*@out@ */ int *columns);
/* Quote the filename for the purpose of inserting it into the command
* line. If quote_percent is 1, replace "%" with "%%" - the percent is

View File

@ -198,11 +198,12 @@ fg_input_dialog_help (const char *header, const char *text, const char *help,
/* text */
p_text = g_strstrip (g_strdup (text));
msglen (p_text, &lines, &cols);
str_msg_term_size (p_text, &lines, &cols);
quick_widgets[3].u.label.text = p_text;
/* dialog width */
len = max (max (str_term_width1 (header), cols) + 4, 64);
len = str_term_width1 (header);
len = max (max (len, cols) + 4, 64);
len = min (max (len, b_len + 6), COLS);
/* button locations */

View File

@ -1040,9 +1040,10 @@ add_new_entry_input (const char *header, const char *text1, const char *text2,
static gboolean i18n_flag = FALSE;
#endif /* ENABLE_NLS */
msglen (text1, &lines1, &cols1);
msglen (text2, &lines2, &cols2);
len = max (str_term_width1 (header), cols1);
len = str_term_width1 (header);
str_msg_term_size (text1, &lines1, &cols1);
str_msg_term_size (text2, &lines2, &cols2);
len = max (len, cols1);
len = max (max (len, cols2) + 4, 64);
#ifdef ENABLE_NLS
@ -1133,8 +1134,9 @@ add_new_group_input (const char *header, const char *label, char **result)
static gboolean i18n_flag = FALSE;
#endif /* ENABLE_NLS */
msglen (label, &lines, &cols);
len = max (max (str_term_width1 (header), cols) + 4, 64);
len = str_term_width1 (header);
str_msg_term_size (label, &lines, &cols);
len = max (max (len, cols) + 4, 64);
#ifdef ENABLE_NLS
if (!i18n_flag)