- chips
Signed-off-by: Stefan Tauner stefan.tauner@student.tuwien.ac.at --- print_wiki.c | 26 ++++++++++++++++---------- 1 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/print_wiki.c b/print_wiki.c index e80b7f3..28d5722 100644 --- a/print_wiki.c +++ b/print_wiki.c @@ -224,6 +224,7 @@ static void print_supported_chips_wiki(int cols) { int i = 0, c = 1, chipcount = 0; const struct flashchip *f, *old = NULL; + unsigned int lines_per_col; uint32_t t; char *s; char vmax[6]; @@ -238,9 +239,12 @@ static void print_supported_chips_wiki(int cols) chipcount++; }
+ /* +1 to force the resulting number of columns to be < cols */ + lines_per_col = chipcount / cols + ((chipcount%cols) > 0 ? 1 : 0); + printf("\n== Supported chips ==\n\nTotal amount of supported " - "chips: '''%d'''\n\n{| border="0" valign="top"\n" - "| valign="top"|\n\n%s", chipcount, chip_th); + "chips: '''%d'''\n\n{| border="0" valign="top"\n", + chipcount);
for (f = flashchips; f->name != NULL; f++, i++) { /* Don't print generic entries. */ @@ -249,10 +253,14 @@ static void print_supported_chips_wiki(int cols) !strncmp(f->name, "unknown", 7)) continue;
+ if ((i % lines_per_col) == 0) + printf("| valign="top"|\n\n%s", chip_th); + /* Alternate colors if the vendor changes. */ if (old != NULL && strcmp(old->vendor, f->vendor)) c = !c;
+ old = f; t = f->tested; s = flashbuses_to_text(f->bustype); sprintf(vmin, "%0.03f", f->voltage.min / (double)1000); @@ -276,16 +284,14 @@ static void print_supported_chips_wiki(int cols) f->voltage.min ? vmax : "N/A"); free(s);
- /* Split table into 'cols' columns. */ - if (i >= (chipcount / cols + 1)) { - printf("\n|}\n\n| valign="top"|\n\n%s", chip_th); - i = 0; - } - - old = f; + if (((i % lines_per_col) + 1) == lines_per_col) + printf("\n|}\n\n"); }
- printf("\n|}\n\n|}\n"); + /* end inner table if it did not fill the last column fully */ + if (((i % lines_per_col)) > 0) + printf("\n|}\n\n"); + printf("\n\n|}\n"); }
/* Not needed for CONFIG_INTERNAL, but for all other PCI-based programmers. */