gnuastro-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnuastro-commits] master 6d3aca7b: Library (fits.h): Columns of empty F


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 6d3aca7b: Library (fits.h): Columns of empty FITS tables reversed to fit input
Date: Tue, 19 Dec 2023 19:02:07 -0500 (EST)

branch: master
commit 6d3aca7bbd23b8cf53a60709ba76535a064b7f3c
Author: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>

    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.
---
 NEWS       | 1 +
 lib/fits.c | 5 +++++
 2 files changed, 6 insertions(+)

diff --git a/NEWS b/NEWS
index 1db324ad..e439b7f2 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 df377294..87ea4e8e 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. */



reply via email to

[Prev in Thread] Current Thread [Next in Thread]