mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
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:
parent
71364f88c3
commit
f24dd62dc2
32
lib/util.c
32
lib/util.c
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 */
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user