From f24dd62dc224c36bfaee971345f345f3649569ec Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Sat, 13 Nov 2010 21:33:26 +0300 Subject: [PATCH] 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 --- lib/util.c | 32 -------------------------------- lib/util.h | 1 - lib/widget/wtools.c | 5 +++-- src/hotlist.c | 12 +++++++----- 4 files changed, 10 insertions(+), 40 deletions(-) diff --git a/lib/util.c b/lib/util.c index 38b088f28..19d34be59 100644 --- a/lib/util.c +++ b/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 diff --git a/lib/util.h b/lib/util.h index 3a30453a3..ffac72396 100644 --- a/lib/util.h +++ b/lib/util.h @@ -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 diff --git a/lib/widget/wtools.c b/lib/widget/wtools.c index 7c57f876a..e8c6a3fda 100644 --- a/lib/widget/wtools.c +++ b/lib/widget/wtools.c @@ -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 */ diff --git a/src/hotlist.c b/src/hotlist.c index 71464687e..81b4d9d20 100644 --- a/src/hotlist.c +++ b/src/hotlist.c @@ -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)