summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad Akhlaghi <mohammad@akhlaghi.org>2023-12-20 00:57:05 +0100
committerMohammad Akhlaghi <mohammad@akhlaghi.org>2023-12-20 00:59:40 +0100
commit6d3aca7bbd23b8cf53a60709ba76535a064b7f3c (patch)
tree624c99b8431ec001d51dc24ebe5f9306e678fd4a
parentf406f6512e3b0066cc5d42c7e07fbaeb70353126 (diff)
downloadgnuastro-6d3aca7b.tar.gz
Library (fits.h): Columns of empty FITS tables reversed to fit input
Until now, when an input FITS table contained 0 rows (was empty of data), the columns (their metadata) was read in reverse! This happened because we would simply add an empty dataset with the given input's metadata, but using the 'gal_list_data_add_alloc' function which is first-in-first-out (hense reversing the order!). With this commit, after all the columns are read, the allocated table is reversed to be the same as the input. This fixes bug #65055.
-rw-r--r--NEWS1
-rw-r--r--lib/fits.c5
2 files changed, 6 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 1db324a..e439b7f 100644
--- a/NEWS
+++ b/NEWS
@@ -149,6 +149,7 @@ See the end of the file for license conditions.
by Ignacio Ruiz Cejudo.
- bug #65050: Use --libtool option in the TEMPLATE usage; found and fixed
by Faezeh Bidjarchian.
+ - bug #65055: Columns of empty FITS tables (with no rows) read in reverse.
diff --git a/lib/fits.c b/lib/fits.c
index df37729..87ea4e8 100644
--- a/lib/fits.c
+++ b/lib/fits.c
@@ -3840,6 +3840,11 @@ gal_fits_tab_read(char *filename, char *hdu, size_t numrows,
out->dsize[0]=0;
free(out->array);
}
+
+ /* Reverse the output (because 'gal_list_data_add_alloc' adds each
+ column in a first-in-first-out order which is the reverse order of
+ the input). */
+ gal_list_data_reverse(&out);
}
/* Return the output. */