From: pk910 Date: Sun, 2 Oct 2011 17:05:10 +0000 (+0200) Subject: fixed Tables maxwidth array (needs to have as many fields as columns not as many... X-Git-Tag: v5.3~345 X-Git-Url: http://git.pk910.de/?p=NeonServV5.git;a=commitdiff_plain;h=b45e9cc33dbb379a170da4a4b810d3f5208c8e97 fixed Tables maxwidth array (needs to have as many fields as columns not as many as rows) and some other bugs --- diff --git a/src/tools.c b/src/tools.c index 43f27cd..fa187b6 100644 --- a/src/tools.c +++ b/src/tools.c @@ -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++) {