aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/charset.c29
-rw-r--r--src/popupmnu.c51
-rw-r--r--src/screen.c6
3 files changed, 41 insertions, 45 deletions
diff --git a/src/charset.c b/src/charset.c
index 65f3621ee8..e85f369c61 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -330,7 +330,7 @@ void trans_characters(char_u *buf, int bufsize)
///
/// @param s
///
-/// @return translated string or NULL if out of memory.
+/// @return translated string
char_u *transstr(char_u *s)
{
char_u *res;
@@ -371,26 +371,25 @@ char_u *transstr(char_u *s)
res = alloc((unsigned)(vim_strsize(s) + 1));
}
- if (res != NULL) {
- *res = NUL;
- p = s;
+ *res = NUL;
+ p = s;
- while (*p != NUL) {
- if (has_mbyte && ((l = (*mb_ptr2len)(p)) > 1)) {
- c = (*mb_ptr2char)(p);
+ while (*p != NUL) {
+ if (has_mbyte && ((l = (*mb_ptr2len)(p)) > 1)) {
+ c = (*mb_ptr2char)(p);
- if (vim_isprintc(c)) {
- // append printable multi-byte char
- STRNCAT(res, p, l);
- } else {
- transchar_hex(res + STRLEN(res), c);
- }
- p += l;
+ if (vim_isprintc(c)) {
+ // append printable multi-byte char
+ STRNCAT(res, p, l);
} else {
- STRCAT(res, transchar_byte(*p++));
+ transchar_hex(res + STRLEN(res), c);
}
+ p += l;
+ } else {
+ STRCAT(res, transchar_byte(*p++));
}
}
+
return res;
}
diff --git a/src/popupmnu.c b/src/popupmnu.c
index 9b20ee0c5b..bfb6b693e1 100644
--- a/src/popupmnu.c
+++ b/src/popupmnu.c
@@ -344,35 +344,34 @@ void pum_redraw(void)
*p = saved;
if (curwin->w_p_rl) {
- if (st != NULL) {
- char_u *rt = reverse_text(st);
-
- if (rt != NULL) {
- char_u *rt_start = rt;
- int size;
-
- size = vim_strsize(rt);
-
- if (size > pum_width) {
- do {
- size -= has_mbyte ? (*mb_ptr2cells)(rt) : 1;
- mb_ptr_adv(rt);
- } while (size > pum_width);
-
- if (size < pum_width) {
- // Most left character requires 2-cells but only 1 cell
- // is available on screen. Put a '<' on the left of the
- // pum item
- *(--rt) = '<';
- size++;
- }
+ char_u *rt = reverse_text(st);
+
+ if (rt != NULL) {
+ char_u *rt_start = rt;
+ int size;
+
+ size = vim_strsize(rt);
+
+ if (size > pum_width) {
+ do {
+ size -= has_mbyte ? (*mb_ptr2cells)(rt) : 1;
+ mb_ptr_adv(rt);
+ } while (size > pum_width);
+
+ if (size < pum_width) {
+ // Most left character requires 2-cells but only 1 cell
+ // is available on screen. Put a '<' on the left of the
+ // pum item
+ *(--rt) = '<';
+ size++;
}
- screen_puts_len(rt, (int)STRLEN(rt), row, col - size + 1,
- attr);
- vim_free(rt_start);
}
- vim_free(st);
+ screen_puts_len(rt, (int)STRLEN(rt), row, col - size + 1,
+ attr);
+ vim_free(rt_start);
}
+ vim_free(st);
+
col -= width;
} else {
if (st != NULL) {
diff --git a/src/screen.c b/src/screen.c
index b6e3c46002..68a1f05e9c 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -5163,10 +5163,8 @@ win_redr_custom (
/* Make all characters printable. */
p = transstr(buf);
- if (p != NULL) {
- vim_strncpy(buf, p, sizeof(buf) - 1);
- vim_free(p);
- }
+ vim_strncpy(buf, p, sizeof(buf) - 1);
+ vim_free(p);
/* fill up with "fillchar" */
len = (int)STRLEN(buf);