mirror of
https://github.com/kdave/btrfs-progs
synced 2025-01-11 16:29:42 +00:00
btrfs-progs: string table: cleanup, rename single letter variables
Exception for indexing variables. Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
7a91592775
commit
850ad2ce35
@ -26,19 +26,19 @@
|
||||
*/
|
||||
struct string_table *table_create(int columns, int rows)
|
||||
{
|
||||
struct string_table *p;
|
||||
struct string_table *tab;
|
||||
int size;
|
||||
|
||||
size = sizeof(struct string_table) + rows * columns * sizeof(char*);
|
||||
p = calloc(1, size);
|
||||
tab = calloc(1, size);
|
||||
|
||||
if (!p)
|
||||
if (!tab)
|
||||
return NULL;
|
||||
|
||||
p->ncols = columns;
|
||||
p->nrows = rows;
|
||||
tab->ncols = columns;
|
||||
tab->nrows = rows;
|
||||
|
||||
return p;
|
||||
return tab;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -95,36 +95,36 @@ void table_dump(struct string_table *tab)
|
||||
sizes[i] = 0;
|
||||
for (j = 0; j < tab->nrows; j++) {
|
||||
int idx = i + j * tab->ncols;
|
||||
int s;
|
||||
int len;
|
||||
|
||||
if (!tab->cells[idx])
|
||||
continue;
|
||||
|
||||
s = strlen(tab->cells[idx]) - 1;
|
||||
if (s < 1 || tab->cells[idx][0] == '=')
|
||||
len = strlen(tab->cells[idx]) - 1;
|
||||
if (len < 1 || tab->cells[idx][0] == '=')
|
||||
continue;
|
||||
|
||||
if (s > sizes[i])
|
||||
sizes[i] = s;
|
||||
if (len > sizes[i])
|
||||
sizes[i] = len;
|
||||
}
|
||||
}
|
||||
|
||||
for (j = 0; j < tab->nrows; j++) {
|
||||
for (i = 0; i < tab->ncols; i++) {
|
||||
int idx = i + j * tab->ncols;
|
||||
char *s = tab->cells[idx];
|
||||
char *cell = tab->cells[idx];
|
||||
|
||||
if (!s || !strlen(s)) {
|
||||
if (!cell || !strlen(cell)) {
|
||||
printf("%*s", sizes[i], "");
|
||||
} else if (s && s[0] == '=') {
|
||||
} else if (cell && cell[0] == '=') {
|
||||
int k = sizes[i];
|
||||
|
||||
while (k--)
|
||||
putchar('=');
|
||||
} else {
|
||||
printf("%*s",
|
||||
s[0] == '<' ? -sizes[i] : sizes[i],
|
||||
s + 1);
|
||||
cell[0] == '<' ? -sizes[i] : sizes[i],
|
||||
cell + 1);
|
||||
}
|
||||
if (i != (tab->ncols - 1))
|
||||
putchar(' ');
|
||||
|
Loading…
Reference in New Issue
Block a user