diff options
author | pgen <p.gen.progs@gmail.com> | 2018-01-19 23:06:47 +0100 |
---|---|---|
committer | pgen <p.gen.progs@gmail.com> | 2018-01-19 23:32:40 +0100 |
commit | 2a2ab209e09dc5efa5f257d01bd448700c951bf7 (patch) | |
tree | 932417a793eca9d1be68f16823e02634bde32c67 | |
parent | 6c29c817e48ba476aafe81164a26c99829193e92 (diff) |
Make sure that non-printable chars in words are expanded
-rw-r--r-- | smenu.c | 24 |
1 files changed, 16 insertions, 8 deletions
@@ -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]) |