[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master 0c770f6 2/3: Check if any input tokens given t
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master 0c770f6 2/3: Check if any input tokens given to Arithmetic |
Date: |
Thu, 16 Nov 2017 20:45:39 -0500 (EST) |
branch: master
commit 0c770f6c61bd4405bccd0bf7fcf54053bde72085
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>
Check if any input tokens given to Arithmetic
Until now, unlike the other programs, the Arithmetic program wouldn't
complain if no tokens was given. Therefore, the first time that it was
necessary to read the tokens, there was nothing to read and Arithmetic
would abort with a segmentation fault. With this commit, a check has been
added to let the user know in this case.
This bug was reported by Lee Spitler.
This fixes bug #52422.
---
NEWS | 2 ++
THANKS | 1 +
bin/arithmetic/ui.c | 9 +++++++++
3 files changed, 12 insertions(+)
diff --git a/NEWS b/NEWS
index 269a79a..85a9301 100644
--- a/NEWS
+++ b/NEWS
@@ -152,6 +152,8 @@ GNU Astronomy Utilities NEWS -*-
outline -*-
NoiseChisel leaving unlabeled regions after clump growth (bug #52327).
+ Arithmetic crash with no input tokens (bug #52422).
+
diff --git a/THANKS b/THANKS
index b9ead74..22e3124 100644
--- a/THANKS
+++ b/THANKS
@@ -37,6 +37,7 @@ support in Gnuastro. The list is ordered alphabetically (by
family name).
William Pence address@hidden
Yahya Sefidbakht address@hidden
Alejandro Serrano Borlaff address@hidden
+ Lee Spitler address@hidden
Richard Stallman address@hidden
Ole Streicher address@hidden
Ignacio Trujillo address@hidden
diff --git a/bin/arithmetic/ui.c b/bin/arithmetic/ui.c
index 8e591df..6edf638 100644
--- a/bin/arithmetic/ui.c
+++ b/bin/arithmetic/ui.c
@@ -232,6 +232,15 @@ ui_check_options_and_arguments(struct arithmeticparams *p)
size_t numfits=0, numhdus=0;
gal_list_str_t *token, *hdu;
+ /* First, make sure that any tokens are actually given. */
+ if(p->tokens==NULL)
+ error(EXIT_FAILURE, 0, "no input tokens. Please specify a filename or "
+ "number (as operands) along with operator(s) as input. Please run "
+ "any of the following commands for more information.\n\n"
+ " $ astarithmetic --help # Short info.\n"
+ " $ info astarithmetic # Full invocation "
+ "documentation.\n");
+
/* The input tokens are put in a lastin-firstout (simple) linked list, so
change them to the correct order so the order we pop a token is the
same order that the user input a value. Note that for the options this