[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master 637c31b 2/2: Corrected ordering of table colum
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master 637c31b 2/2: Corrected ordering of table columns in Table |
Date: |
Wed, 10 May 2017 08:55:37 -0400 (EDT) |
branch: master
commit 637c31b7a34a571899fd3986a6ef202171b41fc7
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>
Corrected ordering of table columns in Table
When the user wants a special set of the full list of columns, Table should
print them in the same order the user asked. However, since table was
implemented before the new option reading features, it would reverse the
list of input columns before read them. When the more recent version was
implemented, the option management tools in `option.c' do the reversing of
list input internally. So the programs don't need to worry about that.
So the final reversal (when columns were specified) was no longer needed
and would cause the final printed columns to be the opposite of the user's
request.
---
bin/table/ui.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/bin/table/ui.c b/bin/table/ui.c
index 1658c06..13e3d93 100644
--- a/bin/table/ui.c
+++ b/bin/table/ui.c
@@ -314,18 +314,19 @@ ui_preparations(struct tableparams *p)
exit(EXIT_SUCCESS);
}
else
- for(i=1;i<=numcols;++i)
+ /* The user wants to read the column values, so put all the column
+ numbers into the list (as strings). Note that we will write the
+ column numbers into the list in reverse order. This way, they
+ are read/popped in the proper order. Recall that this is a
+ last-in-first-out list. */
+ for(i=numcols;i>0;--i)
{
asprintf(&tmp, "%zu", i);
gal_list_str_add(&p->columns, tmp, 0);
}
}
- /* Reverse the list of column search criteria that we are looking for
- (since this is a last-in-first-out linked list, the order that
- elements were added to the list is the reverse of the order that they
- will be popped). */
- gal_list_str_reverse(&p->columns);
+ /* Read in the table columns. */
p->table=gal_table_read(p->filename, cp->hdu, p->columns, cp->searchin,
cp->ignorecase, cp->minmapsize);