[Top][All Lists]

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

[gnuastro-commits] master 58d7f6f 1/3: Match: warning printed when redun

From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 58d7f6f 1/3: Match: warning printed when redundant --ccol2 is given with --coord
Date: Thu, 29 Apr 2021 19:46:10 -0400 (EDT)

branch: master
commit 58d7f6f32f6d239584b92860e7af9cabf5a5fa38
Author: Mohammad Akhlaghi <>
Commit: Mohammad Akhlaghi <>

    Match: warning printed when redundant --ccol2 is given with --coord
    Until now, when the '--coord' option was called with '--ccol2', Match would
    crash with an ugly segmentation fault. The reason for this was that When
    Match is called with '--coord', the table input is assumed to be the first
    catalog, therefore there is no need for '--ccol2'. So I was free-ing its
    value pre-maturely (while it is needed to print with something like '-P' or
    in the FITS headers).
    With this commit, instead of freeing the allocated space (and causing a lot
    of complications), a warning will be printed for the user to tell them that
    '--ccol2' is redundant.
 NEWS           |  1 +
 bin/match/ui.c | 14 +++++++++++---
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/NEWS b/NEWS
index 47b81ac..897b1c5 100644
--- a/NEWS
+++ b/NEWS
@@ -244,6 +244,7 @@ See the end of the file for license conditions.
   bug #60082: Arithmetic library crash for integer operators like modulo
   bug #60121: Arithmetic segfault when multi-operand output given to set-
   bug #60368: CosmicCalculator fails --setdirconf when redshift isn't given
+  bug #60484: Match crashes when called with --coord and --ccol2 (together)
diff --git a/bin/match/ui.c b/bin/match/ui.c
index c0815f1..40c57a9 100644
--- a/bin/match/ui.c
+++ b/bin/match/ui.c
@@ -239,9 +239,17 @@ ui_check_options_and_arguments(struct matchparams *p)
         error(EXIT_FAILURE, 0, "only one argument can be given with the "
               "'--coord' option");
-      /* No need for 'p->input2name' or 'p->ccol2'. */
-      gal_data_free(p->ccol2);
-      p->ccol2=NULL;
+      /* In case '--ccol2' is given. */
+      if(p->ccol2 && p->cp.quiet==0)
+        {
+          /* Print a warning to let the user know the option will not be
+             used (the user had probably confused things if they have given
+             it). */
+          error(EXIT_SUCCESS, 0, "WARNING: with '--coord' you only need "
+                "to set '--ccol1' (for the table), '--ccol2' (for the "
+                "'--coord') is not needed because you are directly "
+                "giving the coordinates in any order you want");
+        }
   /* '--coord' is not given. */

reply via email to

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