improved table_end
authorpk910 <philipp@zoelle1.de>
Mon, 22 Aug 2011 21:28:54 +0000 (23:28 +0200)
committerpk910 <philipp@zoelle1.de>
Mon, 22 Aug 2011 21:28:54 +0000 (23:28 +0200)
tools.c

diff --git a/tools.c b/tools.c
index 3bc3374139748594d1a62848c34d0a4d5dfb9bb8..70cfc1e82d3f57a4fb8d84112b2b787a3bf11e70 100644 (file)
--- a/tools.c
+++ b/tools.c
@@ -145,15 +145,16 @@ char **table_end(struct Table *table) {
             for(i = 0; i < strlen(table->contents[row][col]); i++) {
                 table->table_lines[row][pos++] = table->contents[row][col][i];
             }
-            for(;i < table->maxwidth[col]; i++) {
+            if(col < table->width-1) {
+                for(;i < table->maxwidth[col]; i++) {
+                    table->table_lines[row][pos++] = ' ';
+                }
                 table->table_lines[row][pos++] = ' ';
-            }
+            } else
+                table->table_lines[row][pos++] = '\0';
+            
             if(table->col_flags[col] & TABLE_FLAG_COL_BOLD)
                 table->table_lines[row][pos++] = '\002';
-            if(col < table->width-1)
-                table->table_lines[row][pos++] = ' ';
-            else
-                table->table_lines[row][pos++] = '\0';
         }
     }
     return table->table_lines;