summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpgen <p.gen.progs@gmail.com>2018-01-19 23:06:47 +0100
committerpgen <p.gen.progs@gmail.com>2018-01-19 23:32:40 +0100
commit2a2ab209e09dc5efa5f257d01bd448700c951bf7 (patch)
tree932417a793eca9d1be68f16823e02634bde32c67
parent6c29c817e48ba476aafe81164a26c99829193e92 (diff)
Make sure that non-printable chars in words are expanded
-rw-r--r--smenu.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/smenu.c b/smenu.c
index a7a8bb2..d3d8feb 100644
--- a/smenu.c
+++ b/smenu.c
@@ -6923,13 +6923,21 @@ main(int argc, char * argv[])
/* Alter the word just read be replacing special chars by their */
/* escaped equivalents. */
/* """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""" */
- expanded_word = xmalloc(5 * strlen(word->str) + 1);
- len = expand(word->str, expanded_word, &langinfo);
- new_expanded_word = xstrdup(expanded_word);
- free(expanded_word);
- expanded_word = new_expanded_word;
+ word_len = strlen(word->str);
+
+ expanded_word = xmalloc(5 * word_len + 1);
+ len = expand(word->str, expanded_word, &langinfo);
+
+ /* Update it if needed */
+ /* ''''''''''''''''''' */
+ if (strcmp(expanded_word, word->str) != 0)
+ {
+ word_len = len;
+ free(word->str);
+ word->str = xstrdup(expanded_word);
+ }
- word_len = len;
+ free(expanded_word);
if (win.col_mode)
{
@@ -6946,8 +6954,8 @@ main(int argc, char * argv[])
cols_real_max_size = s;
}
- s = (int)mbstowcs(NULL, expanded_word, 0);
- s = wcswidth((tmpw = mb_strtowcs(expanded_word)), s);
+ s = (int)mbstowcs(NULL, word->str, 0);
+ s = wcswidth((tmpw = mb_strtowcs(word->str)), s);
free(tmpw);
if (s > col_max_size[col_index])