[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master 55e3617: No extra space after Statistics singl
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master 55e3617: No extra space after Statistics single valued measurements |
Date: |
Wed, 26 Dec 2018 08:59:20 -0500 (EST) |
branch: master
commit 55e36179b347a629f9b50525692322322d5921c9
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>
No extra space after Statistics single valued measurements
Until now, when printing the sigle-valued measurements of Statistics, we
would simply print it with an empty space afterwards. This would allow
easily printing any number of measurements after each other.
However, in some situations (in scripts), this white space can cause
problems when storing the output. So with this commit, a counter is added
to the printing function and a white space is printed before each new
measurement if it isn't the first one.
---
bin/statistics/statistics.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/bin/statistics/statistics.c b/bin/statistics/statistics.c
index 9871220..f54dea5 100644
--- a/bin/statistics/statistics.c
+++ b/bin/statistics/statistics.c
@@ -92,9 +92,9 @@ statistics_print_one_row(struct statisticsparams *p)
{
int mustfree;
char *toprint;
- size_t dsize=1;
double arg, *d;
gal_list_i32_t *tmp;
+ size_t dsize=1, counter;
gal_data_t *tmpv, *out=NULL, *num=NULL, *min=NULL, *max=NULL;
gal_data_t *sum=NULL, *med=NULL, *meanstd=NULL, *modearr=NULL;
@@ -145,6 +145,7 @@ statistics_print_one_row(struct statisticsparams *p)
/* Print every requested number. */
+ counter=0;
for(tmp=p->singlevalue; tmp!=NULL; tmp=tmp->next)
{
/* By default don't free anything. */
@@ -188,12 +189,16 @@ statistics_print_one_row(struct statisticsparams *p)
break;
}
- /* Print the number. */
+ /* Print the number. Note that we don't want any extra white space
+ characters before or after the printed outputs. So we have defined
+ `counter' to add a single white space character before any element
+ except the first one. */
toprint=gal_type_to_string(out->array, out->type, 0);
- printf("%s ", toprint);
+ printf("%s%s", counter ? " " : "", toprint);
free(toprint);
/* Clean up (if necessary). */
+ ++counter;
if(mustfree) gal_data_free(out);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnuastro-commits] master 55e3617: No extra space after Statistics single valued measurements,
Mohammad Akhlaghi <=