Code

draw_text: reduce indentation level
authorJonas Fonseca <fonseca@diku.dk>
Thu, 20 Mar 2008 00:54:26 +0000 (01:54 +0100)
committerJonas Fonseca <fonseca@diku.dk>
Thu, 20 Mar 2008 11:38:51 +0000 (12:38 +0100)
tig.c

diff --git a/tig.c b/tig.c
index 756ce47429abe83f70ed5ea21d1fd1f0f5721a38..1ae0a1e19c7f3226938d57b287fa327be37fa687 100644 (file)
--- 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;