Remove OOM error handling code after calls to transstr()

transstr() doesn't return NULL anymore.
This commit is contained in:
Felipe Oliveira Carvalho 2014-04-04 15:35:33 -03:00 committed by Thiago de Arruda
parent b8bda77e39
commit b4545740fd
3 changed files with 37 additions and 41 deletions

View File

@ -330,7 +330,7 @@ void trans_characters(char_u *buf, int bufsize)
/// ///
/// @param s /// @param s
/// ///
/// @return translated string or NULL if out of memory. /// @return translated string
char_u *transstr(char_u *s) char_u *transstr(char_u *s)
{ {
char_u *res; char_u *res;
@ -371,26 +371,25 @@ char_u *transstr(char_u *s)
res = alloc((unsigned)(vim_strsize(s) + 1)); res = alloc((unsigned)(vim_strsize(s) + 1));
} }
if (res != NULL) { *res = NUL;
*res = NUL; p = s;
p = s;
while (*p != NUL) { while (*p != NUL) {
if (has_mbyte && ((l = (*mb_ptr2len)(p)) > 1)) { if (has_mbyte && ((l = (*mb_ptr2len)(p)) > 1)) {
c = (*mb_ptr2char)(p); c = (*mb_ptr2char)(p);
if (vim_isprintc(c)) { if (vim_isprintc(c)) {
// append printable multi-byte char // append printable multi-byte char
STRNCAT(res, p, l); STRNCAT(res, p, l);
} else {
transchar_hex(res + STRLEN(res), c);
}
p += l;
} else { } else {
STRCAT(res, transchar_byte(*p++)); transchar_hex(res + STRLEN(res), c);
} }
p += l;
} else {
STRCAT(res, transchar_byte(*p++));
} }
} }
return res; return res;
} }

View File

@ -344,35 +344,34 @@ void pum_redraw(void)
*p = saved; *p = saved;
if (curwin->w_p_rl) { if (curwin->w_p_rl) {
if (st != NULL) { char_u *rt = reverse_text(st);
char_u *rt = reverse_text(st);
if (rt != NULL) { if (rt != NULL) {
char_u *rt_start = rt; char_u *rt_start = rt;
int size; int size;
size = vim_strsize(rt); size = vim_strsize(rt);
if (size > pum_width) { if (size > pum_width) {
do { do {
size -= has_mbyte ? (*mb_ptr2cells)(rt) : 1; size -= has_mbyte ? (*mb_ptr2cells)(rt) : 1;
mb_ptr_adv(rt); mb_ptr_adv(rt);
} while (size > pum_width); } while (size > pum_width);
if (size < pum_width) { if (size < pum_width) {
// Most left character requires 2-cells but only 1 cell // Most left character requires 2-cells but only 1 cell
// is available on screen. Put a '<' on the left of the // is available on screen. Put a '<' on the left of the
// pum item // pum item
*(--rt) = '<'; *(--rt) = '<';
size++; 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; col -= width;
} else { } else {
if (st != NULL) { if (st != NULL) {

View File

@ -5163,10 +5163,8 @@ win_redr_custom (
/* Make all characters printable. */ /* Make all characters printable. */
p = transstr(buf); p = transstr(buf);
if (p != NULL) { vim_strncpy(buf, p, sizeof(buf) - 1);
vim_strncpy(buf, p, sizeof(buf) - 1); vim_free(p);
vim_free(p);
}
/* fill up with "fillchar" */ /* fill up with "fillchar" */
len = (int)STRLEN(buf); len = (int)STRLEN(buf);