fixed Tables maxwidth array (needs to have as many fields as columns not as many...
authorpk910 <philipp@zoelle1.de>
Sun, 2 Oct 2011 17:05:10 +0000 (19:05 +0200)
committerpk910 <philipp@zoelle1.de>
Sun, 2 Oct 2011 17:27:48 +0000 (19:27 +0200)
src/tools.c

index 43f27cd35ac052148a7c39247aaeea4dbf78a0b2..fa187b614826ae68c00b58831545ad382e9d5140 100644 (file)
@@ -106,9 +106,9 @@ struct Table *table_init(int width, int length, int flags) {
     table->length = length;
     table->width = width;
     table->flags = flags;
-    table->col_flags = calloc(length, sizeof(int));
+    table->col_flags = calloc(width, sizeof(int));
     table->entrys = 0;
-    table->maxwidth = calloc(length, sizeof(int));
+    table->maxwidth = calloc(width, sizeof(int));
     table->table_lines = NULL;
     return table;
 }
@@ -179,16 +179,11 @@ char **table_end(struct Table *table) {
             if(!(table->col_flags[col] & TABLE_FLAG_COL_CONTENTS)) continue;
             if(table->col_flags[col] & TABLE_FLAG_COL_BOLD)
                 table->table_lines[row][pos++] = '\002';
+            i = 0;
             if(table->contents[row][col]) {
-                for(i = 0; i < strlen(table->contents[row][col]); i++) {
+                for(; i < strlen(table->contents[row][col]); i++) {
                     table->table_lines[row][pos++] = table->contents[row][col][i];
                 }
-            } else {
-                i = 4;
-                table->table_lines[row][pos++] = 'N';
-                table->table_lines[row][pos++] = 'U';
-                table->table_lines[row][pos++] = 'L';
-                table->table_lines[row][pos++] = 'L';
             }
             if(col < table->width-1) {
                 for(;i < table->maxwidth[col]; i++) {