[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master fd51c80 050/113: Imported recent work from mas
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master fd51c80 050/113: Imported recent work from master, no conflicts |
Date: |
Fri, 16 Apr 2021 10:33:43 -0400 (EDT) |
branch: master
commit fd51c806553ce9865ec6535e73528c650606118f
Merge: 45bd003 2ccd136
Author: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Imported recent work from master, no conflicts
The recent bug fixes in the master branch are now incorported here also.
---
NEWS | 4 +
doc/gnuastro.fr.html | 34 +++++++++
lib/gnuastro-internal/commonopts.h | 10 +--
lib/gnuastro-internal/options.h | 1 +
lib/options.c | 150 +++++++++++++++++++++++--------------
5 files changed, 139 insertions(+), 60 deletions(-)
diff --git a/NEWS b/NEWS
index f0c4a7b..7f3782f 100644
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,10 @@ GNU Astronomy Utilities NEWS -*-
outline -*-
Configure time CPPFLAGS and LDFLAGS don't pass to BuildProgram (bug #53122).
+ Crash when printing values with the `--onlyversion' option (bug #53142).
+
+ NULL value of onlyversion option causing a crash (bug #53147).
+
diff --git a/doc/gnuastro.fr.html b/doc/gnuastro.fr.html
index 93750b0..26b7785 100644
--- a/doc/gnuastro.fr.html
+++ b/doc/gnuastro.fr.html
@@ -45,6 +45,7 @@ h3 { clear: both; }
<li><a href="#mail">Listes de diffusion</a></li>
<li><a href="#bug">Signalement de bogues</a></li>
<li><a href="#contribute">Participer</a></li>
+ <li><a href="#cite">Citations</a></li>
<li><a href="#license">Licence</a></li>
</ul>
<hr class="no-display"/>
@@ -325,6 +326,39 @@ git clone http://git.sv.gnu.org/r/gnuastro.git</pre>
</dl>
+<h3 id="cite">Citations</h3>
+
+<p>Les citations sont vitales pour la continuité du travail sur Gnuastro. Tous
+ les programmes ont une option commune, <code>--cite</code>, qui vous
+ indiquera comment citer et reconnaître correctement le travail qu'a nécessité
+ la création et la maintenance de chacun d'entre eux ainsi que, plus
+ généralement, celles de Gnuastro. Si vous vous servez dans votre recherche
+ de l'un des programmes ou de l'une des bibliothèques proposées par Gnuastro,
+ merci d'utiliser ce qu'affiche cette option pour citer le programme et
+ Gnuastro dans votre publication. Notez que les différents programmes peuvent
+ demander des références à différents articles qui leur sont plus
+ particulièrement consacrés.</p>
+
+<p>Gnuastro est encore jeune, sa présentation et la description de ses
+ fonctionnalités n'ont pas encore fait l'objet d'un article complet. Tant que
+ cet article n'est pas paru, la référence à donner pour Gnuastro dans son
+ ensemble est la présentation de NoiseChisel (<a
+ href="http://adsabs.harvard.edu/abs/2015ApJS..220....1A">ApJS 220, 1</a>). Il
+ s'agit de la première publication utilisant Gnuastro. Lorsque ce dernier aura
+ atteint une maturité suffisante, une publication lui sera entièrement dédiée.
+ Voir <a
+
href="https://www.gnu.org/software/gnuastro/manual/html_node/GNU-Astronomy-Utilities-1_002e0.html">
+ GNU Astronomy Utilities 1.0</a>.</p>
+
+<p>Gnuastro est également répertorié dans la Bibliothèque de code source pour
+ l'astrophysique (<a href="http://ascl.net">ASCL</a> — <cite>Astrophysics
+ Source Code Library</cite>) sous le numéro <a
+ href="http://ascl.net/1801.009">ascl.net/1801.009</a>. Veuillez utiliser cet
+ identifiant quelque part dans votre article (par exemple dans les
+ remerciements ou lorsque vous mentionnerez Gnuastro pour la première fois).
+ Dans la bibliographie ou la liste de références en fin d'article, utilisez
+ seulement les publications affichées par l'option <code>--cite</code>.</p>
+
<h3 id="license">Licence</h3>
<p><cite>GNU Astronomy Utilities</cite> (Gnuastro) est un logiciel
diff --git a/lib/gnuastro-internal/commonopts.h
b/lib/gnuastro-internal/commonopts.h
index 06421e4..1e41a03 100644
--- a/lib/gnuastro-internal/commonopts.h
+++ b/lib/gnuastro-internal/commonopts.h
@@ -227,10 +227,10 @@ struct argp_option gal_commonopts_options[] =
0,
"Type of output: e.g., int16, float32, etc...",
GAL_OPTIONS_GROUP_OUTPUT,
- &cp->type,
- GAL_TYPE_STRING,
- GAL_OPTIONS_RANGE_GT_0,
- GAL_OPTIONS_NOT_MANDATORY,
+ &cp->type, /* Internally, `cp->type' is actually an */
+ GAL_TYPE_STRING, /* `uint8_t', but the user gives a string. */
+ GAL_OPTIONS_RANGE_GT_0, /* So for the sanity checks to pass, we */
+ GAL_OPTIONS_NOT_MANDATORY,/* use `GAL_TYPE_STRING' for this option. */
GAL_OPTIONS_NOT_SET,
gal_options_read_type
},
@@ -427,7 +427,7 @@ struct argp_option gal_commonopts_options[] =
0,
"Only run if the program version is STR.",
GAL_OPTIONS_GROUP_OPERATING_MODE,
- NULL,
+ &cp->onlyversion,
GAL_TYPE_STRING,
GAL_OPTIONS_RANGE_0_OR_1,
GAL_OPTIONS_NOT_MANDATORY,
diff --git a/lib/gnuastro-internal/options.h b/lib/gnuastro-internal/options.h
index a3f8ea3..599702b 100644
--- a/lib/gnuastro-internal/options.h
+++ b/lib/gnuastro-internal/options.h
@@ -196,6 +196,7 @@ struct gal_options_common_params
size_t numthreads; /* Number of threads to use. */
size_t minmapsize; /* Minimum bytes necessary to use mmap. */
uint8_t log; /* Make a log file. */
+ char *onlyversion; /* Redundant, kept/set for generality. */
/* Configuration files. */
uint8_t printparams; /* To print the full list of parameters. */
diff --git a/lib/options.c b/lib/options.c
index 8b2f89e..c1df2fb 100644
--- a/lib/options.c
+++ b/lib/options.c
@@ -179,35 +179,60 @@ void *
gal_options_check_version(struct argp_option *option, char *arg,
char *filename, size_t lineno, void *junk)
{
+ char *str;
+
+ /* First see if we are reading or writing. */
+ if(lineno==-1)
+ {
+ /* `PACKAGE_VERSION' is a static/literal string, but the pointer
+ returned by this function will be freed, so we must allocate space
+ for it.
+
+ We didn't allocate and give this option a value when we read it
+ because it is redundant and much more likely for the option to
+ just be present (for a check in a reproduction pipeline for
+ example) than for it to be printed. So we don't want to waste
+ resources in allocating a redundant value. */
+ gal_checkset_allocate_copy(PACKAGE_VERSION, &str);
+ return str;
+ }
+
/* Check if the given value is different from this version. */
- if( strcmp(arg, PACKAGE_VERSION) )
+ else
{
- /* Print an error message and abort. */
- error_at_line(EXIT_FAILURE, 0, filename, lineno, "version mis-match: "
- "you are running GNU Astronomy Utilities (Gnuastro) "
- "version `%s'. However, the `onlyversion' option is set "
- "to version `%s'.\n\n"
- "This was probably done for reproducibility. Therefore, "
- "manually removing, or changing, the option value might "
- "produce errors or unexpected results. It is thus "
- "strongly advised to build Gnuastro %s and re-run this "
- "command/script.\n\n"
- "You can download previously released tar-balls from the "
- "following URLs respectively:\n\n"
- " Stable (version format: X.Y): "
- "http://ftpmirror.gnu.org/gnuastro\n"
- " Alpha (version format: X.Y.A-B): "
- "http://alpha.gnu.org/gnu/gnuastro\n\n"
- "Alternatively, you can clone Gnuastro, checkout the "
- "respective commit (from the version number), then "
- "bootstrap and build it. Please run the following "
- "command for more information:\n\n"
- " $ info gnuastro \"Version controlled source\"\n",
- PACKAGE_VERSION, arg, arg);
-
- /* Just to avoid compiler warnings for unused variables. The program
- will never reach this point! */
- arg=filename=NULL; lineno=0; option=NULL; junk=NULL;
+ if(arg==NULL)
+ error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at %s to fix "
+ "the problem. The value to `arg' is NULL", __func__,
+ PACKAGE_BUGREPORT);
+ else if( strcmp(arg, PACKAGE_VERSION) )
+ {
+ /* Print an error message and abort. */
+ error_at_line(EXIT_FAILURE, 0, filename, lineno, "version "
+ "mis-match: you are running GNU Astronomy Utilities "
+ "(Gnuastro) version `%s'. However, the `onlyversion' "
+ "option is set to version `%s'.\n\n"
+ "This was probably done for reproducibility. "
+ "Therefore, manually removing, or changing, the "
+ "option value might produce errors or unexpected "
+ "results. It is thus strongly advised to build "
+ "Gnuastro %s and re-run this command/script.\n\n"
+ "You can download previously released tar-balls "
+ "from the following URLs respectively:\n\n"
+ " Stable (version format: X.Y): "
+ "http://ftpmirror.gnu.org/gnuastro\n"
+ " Alpha (version format: X.Y.A-B): "
+ "http://alpha.gnu.org/gnu/gnuastro\n\n"
+ "Alternatively, you can clone Gnuastro, checkout the "
+ "respective commit (from the version number), then "
+ "bootstrap and build it. Please run the following "
+ "command for more information:\n\n"
+ " $ info gnuastro \"Version controlled source\"\n",
+ PACKAGE_VERSION, arg, arg);
+
+ /* Just to avoid compiler warnings for unused variables. The program
+ will never reach this point! */
+ arg=filename=NULL; lineno=0; option=NULL; junk=NULL;
+ }
}
return NULL;
}
@@ -2118,37 +2143,52 @@ gal_options_print_state(struct
gal_options_common_params *cp)
case GAL_OPTIONS_KEY_PRINTPARAMS:
case GAL_OPTIONS_KEY_SETDIRCONF:
case GAL_OPTIONS_KEY_SETUSRCONF:
+
+ /* Note that these options can have a value of 1 (enabled) or 0
+ (explicitly disabled). Therefore the printing should only be
+ done if they have a value of 1. This is why we have defined
+ the `OPTIONS_UINT8VAL' macro above. */
sum += OPTIONS_UINT8VAL;
}
- if(sum>1)
- error(EXIT_FAILURE, 0, "only one of the `printparams', `setdirconf' "
- "and `setusrconf' options can be called in each run");
- /* Print the required configuration files. Note that simply having a
- non-NULL value is not enough. They can have a value of 1 or 0, and the
- respective file should only be created if we have a value of 1. */
- for(i=0; !gal_options_is_last(&cp->coptions[i]); ++i)
- if(cp->coptions[i].set && OPTIONS_UINT8VAL)
- switch(cp->coptions[i].key)
- {
- case GAL_OPTIONS_KEY_PRINTPARAMS:
- options_print_all(cp, NULL, NULL);
- break;
-
- case GAL_OPTIONS_KEY_SETDIRCONF:
- if( asprintf(&dirname, ".%s", PACKAGE)<0 )
- error(EXIT_FAILURE, 0, "%s: asprintf allocation", __func__);
- options_print_all(cp, dirname, cp->coptions[i].name);
- free(dirname);
- break;
+ /* See if the values should be printed and if so, where. */
+ switch(sum)
+ {
+ /* No printing option has been called, so just return. */
+ case 0: return;
+
+ /* (Only) one of the printing options has been called, so we'll need to
+ print the values in the proper place. */
+ case 1:
+ for(i=0; !gal_options_is_last(&cp->coptions[i]); ++i)
+ if(cp->coptions[i].set && OPTIONS_UINT8VAL)
+ switch(cp->coptions[i].key)
+ {
+ case GAL_OPTIONS_KEY_PRINTPARAMS:
+ options_print_all(cp, NULL, NULL);
+ break;
+
+ case GAL_OPTIONS_KEY_SETDIRCONF:
+ if( asprintf(&dirname, ".%s", PACKAGE)<0 )
+ error(EXIT_FAILURE, 0, "%s: asprintf allocation", __func__);
+ options_print_all(cp, dirname, cp->coptions[i].name);
+ free(dirname);
+ break;
+
+ case GAL_OPTIONS_KEY_SETUSRCONF:
+ home=options_get_home();
+ if( asprintf(&dirname, "%s/%s", home, USERCONFIG_DIR)<0 )
+ error(EXIT_FAILURE, 0, "%s: asprintf allocation", __func__);
+ options_print_all(cp, dirname, cp->coptions[i].name);
+ free(dirname);
+ break;
+ }
+ break;
- case GAL_OPTIONS_KEY_SETUSRCONF:
- home=options_get_home();
- if( asprintf(&dirname, "%s/%s", home, USERCONFIG_DIR)<0 )
- error(EXIT_FAILURE, 0, "%s: asprintf allocation", __func__);
- options_print_all(cp, dirname, cp->coptions[i].name);
- free(dirname);
- break;
- }
+ /* More than one of the printing options has been called. */
+ default:
+ error(EXIT_FAILURE, 0, "only one of the `printparams', `setdirconf' "
+ "and `setusrconf' options can be called in each run");
+ }
}
- [gnuastro-commits] master ace4160 017/113: New --mcolisbrightness option for MakeProfiles, (continued)
- [gnuastro-commits] master ace4160 017/113: New --mcolisbrightness option for MakeProfiles, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master f06acc5 018/113: Merged recent work from master, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 61aec7b 019/113: Convolve name and dimensionality checks, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 4627ddf 021/113: NoiseChisel segmentation working in 3D, test added, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 1560a54 022/113: Default NoiseChisel kernel in 3D changed to 1.5 pixels, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 4d2508f 028/113: Fixed NoiseChisel opening and dilation and merged with master, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 4223e60 025/113: Suggestions on viewing/inspecting NoiseChisel's output, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 6086579 031/113: Merged recent work in master (corrected conflicts), Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master b0d5fab 034/113: Merged recent work from master, no conflicts, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 06798a5 035/113: Crop's --checkcenter works on 3D dataset, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master fd51c80 050/113: Imported recent work from master, no conflicts,
Mohammad Akhlaghi <=
- [gnuastro-commits] master a4dbaba 055/113: Recent work in master imported, minor conflict fixed, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 0597cea 058/113: Imported work in master, no conflicts, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master e11098d 053/113: Recent work in master imported, minor conflicts fixed, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 0a8324f 059/113: MakeProfiles kernel option can be elongated in 3rd-dimension, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master ec3c102 056/113: Single to conditionally open ds9 for multi-HDU 2D or 3D, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 2491c91 064/113: Imported work in master, minor conflict in book fixed, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 9dda05c 040/113: Merged recent work from the master branch with corrections, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 218a7db 041/113: Brought in recent work from master, corrections made, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 6f4e484 032/113: Merged with recent updates in master, Mohammad Akhlaghi, 2021/04/16
- [gnuastro-commits] master 4fedb9d 038/113: Merged with master, conflicts fixed, Mohammad Akhlaghi, 2021/04/16