From: Jonas Fonseca Date: Thu, 20 Mar 2008 00:54:26 +0000 (+0100) Subject: draw_text: reduce indentation level X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=220265483d86f175a23b09407b6923e5829e800f;p=tig.git draw_text: reduce indentation level --- diff --git a/tig.c b/tig.c index 756ce47..1ae0a1e 100644 --- a/tig.c +++ b/tig.c @@ -1461,29 +1461,30 @@ draw_text(struct view *view, const char *string, int max_len, int col, bool use_tilde, int tilde_attr) { int len = 0; + int trimmed = FALSE; - if (max_len > 0) { - int trimmed = FALSE; + if (max_len <= 0) + return 0; - if (opt_utf8) { - len = utf8_length(string, max_len, &trimmed, use_tilde); - } else { - len = strlen(string); - if (len > max_len) { - if (use_tilde) { - max_len -= 1; - } - len = max_len; - trimmed = TRUE; + if (opt_utf8) { + len = utf8_length(string, max_len, &trimmed, use_tilde); + } else { + len = strlen(string); + if (len > max_len) { + if (use_tilde) { + max_len -= 1; } + len = max_len; + trimmed = TRUE; } - waddnstr(view->win, string, len); - if (trimmed && use_tilde) { - if (tilde_attr != -1) - wattrset(view->win, tilde_attr); - waddch(view->win, '~'); - len++; - } + } + + waddnstr(view->win, string, len); + if (trimmed && use_tilde) { + if (tilde_attr != -1) + wattrset(view->win, tilde_attr); + waddch(view->win, '~'); + len++; } return len;