2.5 filebrowser
authorAndrea Weikert <elubie@gmx.net>
Tue, 26 May 2009 21:34:20 +0000 (21:34 +0000)
committerAndrea Weikert <elubie@gmx.net>
Tue, 26 May 2009 21:34:20 +0000 (21:34 +0000)
- some cleanup of ugly conditional.

source/blender/editors/space_file/file_draw.c

index 1db950c8f972f8000fd443bcb86121e0f6a912f2..bbe8245a3f7b4eed27e27ee77524638eae56556d 100644 (file)
@@ -182,12 +182,17 @@ static float shorten_string(char* string, float w, int flag)
        float sw = 0;
        float pad = 0;
 
+       if (w <= 0) {
+               *string = '\0';
+               return 0.0;
+       }
+
        sw = file_string_width(string);
        if (flag == FILE_SHORTEN_FRONT) {
                char *s = string;
                BLI_strncpy(temp, "...", 4);
                pad = file_string_width(temp);
-               while (s && *s && (w > 0) && (sw+pad>w)) {
+               while ((*s) && (sw+pad>w)) {
                        s++;
                        sw = file_string_width(s);
                        shortened = 1;
@@ -200,14 +205,13 @@ static float shorten_string(char* string, float w, int flag)
                }
        } else {
                char *s = string;
-               if (w>0) {
-                       while (sw>w) {
-                               int slen = strlen(string);
-                               string[slen-1] = '\0';
-                               sw = file_string_width(s);
-                               shortened = 1;
-                       }
+               while (sw>w) {
+                       int slen = strlen(string);
+                       string[slen-1] = '\0';
+                       sw = file_string_width(s);
+                       shortened = 1;
                }
+
                if (shortened) {
                        int slen = strlen(string);
                        if (slen > 3) {