...
 
Commits (4)
iraf-fitsutil (2018.07.06-3) unstable; urgency=low
* Fix executable (source) path for x_fitsutil tasks
* Fix slines handling in fgwrite.c
* Add CI tests
-- Ole Streicher <olebole@debian.org> Mon, 20 Aug 2018 15:15:17 +0200
iraf-fitsutil (2018.07.06-2) unstable; urgency=low
* Exclude .pc (quilt) files from being installed
......
......@@ -2,25 +2,16 @@ From: Ole Streicher <ole@aip.de>
Date: Wed, 28 Feb 2018 13:48:58 +0100
Subject: Adjust executable paths
cfitsion utilities are taken from /usr/bin/, and the fitsutil task is
in fitsutilbin$.
cfitsion utilities are taken from /usr/bin/
---
fitsutil.cl | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
fitsutil.cl | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fitsutil.cl b/fitsutil.cl
index cde226e..80442ea 100644
index cde226e..b3ab782 100644
--- a/fitsutil.cl
+++ b/fitsutil.cl
@@ -16,15 +16,15 @@ task fxheader,
fxsplit,
fxconvert,
fxplf,
- fxcopy = "fitsutil$src/x_fitsutil.e"
+ fxcopy = "fitsutilbin$x_fitsutil.e"
task ricepack = "fitsutil$src/ricepack.cl"
task fpack = "fitsutil$src/fpack.cl"
@@ -23,8 +23,8 @@ task fpack = "fitsutil$src/fpack.cl"
task funpack = "fitsutil$src/funpack.cl"
task sum32 = "fitsutil$src/sum32.cl"
......
From: Ole Streicher <olebole@debian.org>
Date: Fri, 17 Aug 2018 11:18:18 +0200
Subject: Fix slines handling in fgwrite.c
Don't increment slines after allocation, only reallocate it. Also fix the
realloc() calling parameters.
This brings fgwrite back to work when a reallocation of slines was
needed (the TOC contained more than 70 entries).
---
src/fgwrite.c | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/src/fgwrite.c b/src/fgwrite.c
index 74d594f..9e5bbd9 100644
--- a/src/fgwrite.c
+++ b/src/fgwrite.c
@@ -269,7 +269,6 @@ char *argv[];
/* Create Table Of Contents */
if (toc == YES) {
slines = (char *) calloc (MAX_TOC, TOCLEN);
- ip = slines;
maxcount = MAX_TOC;
hdr_off = 2880;
level = 1;
@@ -302,7 +301,7 @@ char *argv[];
/* Now add the Table of Content to this PHU */
if (toc == YES) {
list_toc (kwdb);
- free (ip);
+ free (slines);
}
ncards = kwdb_WriteFITS (kwdb, out);
@@ -1458,13 +1457,13 @@ int usize; /* FITS unit size */
fsize = (fh->size+2879)/2880;
c = level <= 9 ? level+'0' : level-10+'a';
- sprintf (slines, " %-4d %4d %4d %s %c %s",
- ++count, hdr_off/2880, fsize, type, c, gname(fh->name));
- slines = slines + TOCLEN;
+ ++count;
+ sprintf (slines+TOCLEN*(count-1), " %-4d %4d %4d %s %c %s",
+ count, hdr_off/2880, fsize, type, c, gname(fh->name));
if (count >= maxcount) {
maxcount += MAX_TOC;
- slines= (char *)realloc (maxcount, TOCLEN);
+ slines= (char *)realloc (slines, TOCLEN*maxcount);
}
if (ftype == FITS_MEF || ftype == FITS) {
@@ -1511,13 +1510,13 @@ pointer kwdb; /* Output db */
if (count % 36 > 21) nb++; /* add one more if necessary */
if (nb == 0) {
- for (s=slines-TOCLEN*count, k=count; k > 0; s+=TOCLEN,k--) {
+ for (s=slines, k=count; k > 0; s+=TOCLEN,k--) {
kwdb_AddEntry (kwdb, " ", s, "T","");
if (verbose)
printf("%s\n",s);
}
} else {
- for (s=slines-TOCLEN*count, k=count; k > 0; s+=TOCLEN,k--) {
+ for (s=slines, k=count; k > 0; s+=TOCLEN,k--) {
sscanf (s, "%d %d", &i, &hoff);
hoff = hoff + nb;
sprintf (line, " %-4d %4d%s", i, hoff, s+11);
@@ -1578,15 +1577,14 @@ int usize; /* size of MEF PHDU */
datasize = pix_block (kwdb);
ncards = ((ncards + 35)/36)*36;
-
- sprintf(slines," %-4d %4d %7.7c",++count,
+ ++count;
+ sprintf(slines+TOCLEN*(count-1)," %-4d %4d %7.7c",count,
(hdr_off+foff)/2880, ft);
foff = foff + datasize * FBLOCK + ncards * CARDLEN;
if (count >= maxcount) {
maxcount += MAX_TOC;
- slines= (char *)realloc (maxcount, TOCLEN);
+ slines = (char *)realloc (slines, TOCLEN*maxcount);
}
- slines = slines + TOCLEN;
stat = lseek (fd, foff, SEEK_SET);
if (stat < 0) {
From: Ole Streicher <olebole@debian.org>
Date: Fri, 17 Aug 2018 11:33:06 +0200
Subject: Include used standard header
---
src/fgread.c | 31 ++++++-------------------------
src/fgwrite.c | 2 ++
src/kwdb.c | 11 ++++++-----
3 files changed, 14 insertions(+), 30 deletions(-)
diff --git a/src/fgread.c b/src/fgread.c
index c93f64c..cb849e8 100644
--- a/src/fgread.c
+++ b/src/fgread.c
@@ -1,25 +1,19 @@
/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
*/
+#define _XOPEN_SOURCE
#include <stdio.h>
#include <unistd.h>
+#include <stdlib.h>
#include <ctype.h>
+#include <sys/stat.h>
#include <sys/types.h>
+#include <fcntl.h>
#include <string.h>
#include <pwd.h>
#include <utime.h>
-/* #include <time.h> */
-
-#ifdef SYSV
#include <time.h>
-#else
-#include <sys/time.h>
-#include <sys/timeb.h>
-#endif
-#if defined(MACOSX) || defined(__linux)
-#include <time.h>
-#endif
#include "kwdb.h"
static long get_timezone();
@@ -245,7 +239,7 @@ char *argv[];
fprintf (stderr, "missing filename argument\n");
exit (1);
}
- in = open (*argp, 0);
+ in = open (*argp, O_RDONLY);
if (in == ERR) {
fprintf (stderr, "cannot open `%s'\n", *argp);
exit (1);
@@ -613,7 +607,7 @@ char *type; /* Foreign extension type, (bin, text..) */
tp = ctime (&fh->mtime);
- fprintf (out, "%-4d %-10.10s %9d %-12.12s %-4.4s %s",
+ fprintf (out, "%-4d %-10.10s %9ld %-12.12s %-4.4s %s",
count,type, fh->size, tp + 4, tp + 20, fh->name);
if (fh->linkflag && *fh->linkname) {
fprintf (out, " -> %s ", fh->linkname);
@@ -889,21 +883,8 @@ int ftype;
static long
get_timezone()
{
-#ifdef SYSV
extern long timezone;
tzset();
return (timezone);
-#else
-#ifdef MACOSX
- struct tm *tm;
- time_t clock = time(NULL);
- tm = localtime (&clock);
- return (-(tm->tm_gmtoff));
-#else
- struct timeb time_info;
- ftime (&time_info);
- return (time_info.timezone * 60);
-#endif
-#endif
}
diff --git a/src/fgwrite.c b/src/fgwrite.c
index 9e5bbd9..78a46ce 100644
--- a/src/fgwrite.c
+++ b/src/fgwrite.c
@@ -3,6 +3,8 @@
#include <stdio.h>
#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
#include <fcntl.h>
#include <time.h>
#include <strings.h>
diff --git a/src/kwdb.c b/src/kwdb.c
index aaeeefa..2355ec1 100644
--- a/src/kwdb.c
+++ b/src/kwdb.c
@@ -1,5 +1,9 @@
#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
#include <fcntl.h>
+#include <ctype.h>
#include "kwdb.h"
/*
@@ -146,14 +150,11 @@ struct kwdb {
Item *itab; /* pointer to itab array */
char *sbuf; /* pointer to string buffer */
int hashtbl[NTHREADS]; /* hash table */
- int (*read)(); /* private file read function */
- int (*write)(); /* private file write function */
+ ssize_t (*read)(); /* private file read function */
+ ssize_t (*write)(); /* private file write function */
};
typedef struct kwdb KWDB;
-extern char *mkstemp();
-extern int read(), write();
-
static int hash();
static int addstr();
static int streq();
Set-bin-directory.patch
Adjust-executable-paths.patch
Propagate-CFLAGS-etc.patch
Fix-slines-handling-in-fgwrite.c.patch
Include-used-standard-header.patch
Test-Command: ./debian/tests/run_tests debian/tests/*.md
Depends: @
# FITSUTIL external package
`fgwrite` encapsulates arbitrary files into wrapper FITS extensions
called FOREIGN.
## fgread, fgwrite
```
cl> fitsutil
This is the initial release of the IRAF FITSUTIL package
to include support for FITS tile compression via 'fpack'.
Please send comments and questions to seaman@noao.edu.
cl> copy dev$pix.pix pix.pix
cl> copy dev$pix.imh pix.imh
cl> fgwrite "pix.pix pix.imh" pix.fits verb-
cl> mkdir out
cl> cd out
cl> fgread ../pix.fits "" "" verb-
cl> sum32 *
2024286706 5288 pix.imh
1504446139 526336 pix.pix
```
## fxcopy, fxinsert, fxheader
The functions in the `x_fitsutil.e` executable handle multi-extension
FITS files.
```
cl> fitsutil
This is the initial release of the IRAF FITSUTIL package
to include support for FITS tile compression via 'fpack'.
Please send comments and questions to seaman@noao.edu.
cl> imcopy dev$pix spix
dev$pix -> spix
cl> fxcopy spix mpix.fits 0
spix[0] -> mpix.fits
cl> fxinsert spix mpix.fits[1] 0
spix[0] -> mpix.fits
cl> fxheader mpix.fits
EXT# EXTTYPE EXTNAME EXTVE DIMENS BITPI INH OBJECT
0 mpix.fits 512x512 16 m51 B 600s
1 IMAGE 512x512 16 m51 B 600s
```
## ricepack/funpack
The RICEPACK task will compress a list of images. The input may be
FITS or MEF FITS, may be gzip compressed copies of either type of FITS
files, or may be IRAF ".imh" images. The output file names will be
compressed FITS with ".fits.fz" appended. This task is a wrapper
script for the CFITSIO fpack command
```
cl> fitsutil
This is the initial release of the IRAF FITSUTIL package
to include support for FITS tile compression via 'fpack'.
Please send comments and questions to seaman@noao.edu.
cl> copy spix.fits spix0.fits
cl> ricepack spix.fits verb-
cl> funpack spix.fits.fz verb-
cl> imstat spix*.fits
# IMAGE NPIX MEAN STDDEV MIN MAX
spix.fits 262144 108.3 131.3 -1. 19936.
spix0.fits 262144 108.3 131.3 -1. 19936.
```
#!/bin/sh
# Doctest-alike IRAF test script. This will take text files with
# MarkDown syntax, extract all code lines (enclosed with ```), execute
# the lines that start with cl> or similar and compare the other lines
# with the output of the IRAF shells (cl, ecl, vocl).
#
# Copyright: 2017 Ole Streicher
# License: as IRAF
#
if [ -z "$iraf" ] ; then
export iraf=/usr/lib/iraf/
fi
export LANG=C
export src=$(cd $(dirname $0)/..; pwd)/
export IRAFBIN=${iraf}bin/
TEST_FILES=""
IRAF_SHELLS=""
verbose=0
while getopts "h?vc:" opt; do
case "$opt" in
h|\?)
echo 'Run the IRAF test suite. See iraf$test/README.md for details.'
echo
echo 'Usage:'
echo ' run_tests [-h] [-v] [-c CL.e]... [TEST.md]...'
echo
echo 'Arguments:'
echo ' -h this help'
echo ' -v verbose output'
echo ' -c CL.e use CL.e as IRAF shell (may be given several times)'
echo ' TEST.md run test script TEST.md (may be given several times)'
echo
echo 'If no IRAF shell is specified, ecl.e is used.'
echo 'If no test scripts are specified, all test scripts under iraf$test'
echo 'are executed.'
exit 0
;;
v) verbose=1
;;
c) IRAF_SHELLS="$IRAF_SHELLS $OPTARG"
;;
esac
done
shift $((OPTIND-1))
[ "$1" = "--" ] && shift
# IRAF shells to be tested
if [ -z "$IRAF_SHELLS" ] ; then
IRAF_SHELLS="ecl.e"
fi
# Test scripts
for f in $@ ; do
if [ $(echo $f | cut -c1) != "/" ] ; then
f=$(pwd)/$f
fi
TEST_FILES="$TEST_FILES $f"
done
if [ -z "$TEST_FILES" ] ; then
TEST_FILES=${iraf}test/*.md
fi
base_dir=$(mktemp -d -t iraftest.XXXXXXXXX)
failure_file=${base_dir}/failures.txt
summary_file=${base_dir}/summary.txt
# Run one test. If a failure happens, the full message will be appended to
# the $failure_file.
#
# Parameters:
#
# - Executable of IRAF shell
# - Commands to be executed
# - Expected result string
# - Test script reference (file name and line number)
#
run_test () {
local CL="$1"
local command="$2"
local result="$3"
local src="$4"
local options="$5"
local skip=$(echo "$options" | tr \ \\n | grep ^skip)
local xfail=$(echo "$options" | tr \ \\n | grep ^xfail)
local archs=$(echo "$options" | tr \ \\n | grep ^arch= | cut -d= -f2)
local decimals=$(echo "$options" | tr \ \\n | grep ^decimals= | cut -d= -f2)
if [ "$skip" ] ; then
echo "skipped" >> "$summary_file"
printf "s"
return
fi
if [ "$archs" -a -z "$(echo $archs | tr , \\n | grep ^$IRAFARCH\$)" ] ; then
echo "skipped" >> "$summary_file"
printf "a"
return
fi
local cmd_file="${base_dir}/cmd"
printf "%b\nlogout\n" "$command" > "$cmd_file"
res_file="${base_dir}/expected"
printf "%b\n" "$result" > "$res_file"
clres_file="${base_dir}/output"
"${CL}" -f "$cmd_file" 2>&1 > "$clres_file" < /dev/null
diff_file="${base_dir}/diff"
diff_floatingpoint "$res_file" "$clres_file" "$decimals" > "$diff_file"
if [ -s $diff_file ] ; then
if [ "$xfail" ] ; then
printf "x"
echo "xfailed" >> "$summary_file"
return
else
cat >> $failure_file <<EOF
=================== Failure in $src with $(basename $CL) ===================
Expected
========
$(cat $res_file)
Output
======
$(cat $clres_file)
Diff
====
$(cat $diff_file | tail -n +3)
EOF
echo "failed" >> "$summary_file"
printf "F"
return
fi
else
echo "passed" >> "$summary_file"
printf "."
return
fi
rm -f $cmd_file $res_file $clres_file $diff_file
}
# Diff two files, with an optionally given floating point precision
# (in relevant decimals)
#
# Parameters:
#
# - first file
# - second file
# - relevant decimals (optional)
#
diff_floatingpoint () {
local file1="$1"
local file2="$2"
local decimals="$3"
if [ -z "$decimals" ] ; then
diff -uw "$file1" "$file2"
else
perl -pe 's/(-?\d+\.\d*)(E-?\d+)?/sprintf("%.'${decimals}'f%s", $1, $2)/ge;s/\-(0+\.0*)/$1/ge' < "$file1" > "$file1".fp
perl -pe 's/(-?\d+\.\d*)(E-?\d+)?/sprintf("%.'${decimals}'f%s", $1, $2)/ge;s/\-(0+\.0*)/$1/ge' < "$file2" > "$file2".fp
diff -uw "$file1".fp "$file2".fp
rm -f "$file1".fp "$file2".fp
fi
}
# Run all tests for a given IRAF shell and test script
#
# Parameters:
#
# - Executable of IRAF shell
# - File name for test script
#
run_tests () {
local CL="$1"
FILE="$2"
in_code=0 # detect whether we are in a code section
command='' # collected commands
result='' # collected expected results
filename='' # File name to read in
options='' # Test options
lineno=0 # line counter
cat "$FILE" | while read -r line ; do
lineno=$(expr $lineno + 1)
if [ "$in_code" = 1 ] ; then
if echo "$line" | grep -q '^```$' ; then
# we are at the end of a code section,
# so let's execute the test if there was one
if [ "$command" ] ; then
if [ "$verbose" = 1 -a -n "$headline" ] ; then
printf "\n %s: " "$headline"
headline=""
fi
run_test "$CL" "$command" "$result" "$(basename ${FILE}):${l_start}" "$options"
fi
command=''
result=''
filename=''
options=''
in_code=0
elif [ "$filename" ] ; then
# We are in a code line that is to be stored in a file
printf "%s\n" "$line" >> "$filename"
elif echo "$line" | egrep -q '^[a-z>]+> ' ; then
# We are in a code line that contains a command.
# First add a command to print the full line so that
# it appears in the output. Then add the command itself
# And add the command to to the expected results.
cmd=$(echo "$line" | sed 's/^[a-z>]*> //')
if [ "$command" ] ; then
command="${command}\nprint '${line}'"
result="${result}\n${line}"
else
command="print '${line}'"
result="${line}"
fi
command="${command}\n${cmd}"
else
# We are in a code line that contains the response from IRAF.
# Just add it to the expected results.
result="${result}\n${line}"
fi
elif echo "$line" | grep -q '^```$' ; then
# A new code section started. Store the next line number for
# reference
l_start=$(expr $lineno + 1)
in_code=1
elif echo "$line" | egrep -q '^File: `.+`$' ; then
# There is some file content printed out in the next block.
# Just prepare to save it.
filename="$(echo $line | cut '-d`' -f2)"
elif echo "$line" | egrep -q '^Test options: `.+`$' ; then
# Special test options
options="$(echo $line | cut '-d`' -f2)"
elif echo "$line" | egrep -q '^#' ; then
# Head line
headline="$(echo $line | sed s/^#*\ //)"
else
filename=""
options=""
fi
done
printf "\n"
}
for CL in $IRAF_SHELLS ; do
if [ -x "${IRAFBIN}${CL}" ] ; then
for t in $TEST_FILES ; do
test_dir="${base_dir}/testroot"
mkdir -p "${test_dir}"
printf "%b: %b " "${CL}" "$(basename ${t})"
cd "$test_dir" ; run_tests "${IRAFBIN}${CL}" "${t}"
rm -rf "${test_dir}"
done
else
echo "IRAF shell $CL not found"
stat "${IRAFBIN}${CL}" >> "$failure_file" 2>&1
fi
done
if [ -s "$summary_file" ] ; then
printf "Test summary:$(sort $summary_file | uniq -c | sed ':a;N;$!ba;s/\n */, /g')\n"
fi
if [ -s "$failure_file" ] ; then
cat "$failure_file"
rm -rf "${base_dir}"
exit 1
fi
rm -rf "${base_dir}"
exit 0