Commit 46dd48fa authored by Emmanuel Bertin's avatar Emmanuel Bertin
Browse files

Fixed byte-swapping flag issue with -fno-common compilation flag.

parent c09d0c93
......@@ -67,9 +67,9 @@ author = u'E. Bertin'
# built documents.
#
# The short X.Y version.
version = '2.24.2'
version = '2.25.1'
# The full version, including alpha/beta/rc tags.
release = '2.24.2'
release = '2.25.1'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
......@@ -81,7 +81,7 @@ language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#
today = 'Fri Dec 29 2017'
today = 'Tue Feb 11 2020'
#
# Else, today_fmt is used as the format for a strftime call.
#
......@@ -144,7 +144,7 @@ html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
# The name for this set of Sphinx documents.
# "<project> v<release> documentation" by default.
#
# html_title = u'SExtractor v2.24.2'
# html_title = u'SExtractor v2.25.1'
# A shorter title for the navigation bar. Default is the same as html_title.
#
......
......@@ -7,7 +7,7 @@
*
* This file part of: AstrOmatic FITS/LDAC library
*
* Copyright: (C) 1995-2013 Emmanuel Bertin -- IAP/CNRS/UPMC
* Copyright: (C) 1995-2010 IAP/CNRS/SorbonneU
*
* License: GNU General Public License
*
......@@ -23,7 +23,7 @@
* along with AstrOmatic software.
* If not, see <http://www.gnu.org/licenses/>.
*
* Last modified: 28/03/2013
* Last modified: 11/02/2020
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
......@@ -304,7 +304,7 @@ INPUT A pointer to the tab structure,
OUTPUT -.
NOTES .
AUTHOR E. Bertin (IAP)
VERSION 28/03/2013
VERSION 11/02/2020
***/
void read_body(tabstruct *tab, PIXTYPE *ptr, size_t size)
{
......@@ -313,18 +313,19 @@ void read_body(tabstruct *tab, PIXTYPE *ptr, size_t size)
unsigned char cuval, cublank;
char *bufdata,
cval, cblank;
unsigned short suval, sublank;
unsigned short suval, sublank, ashort=1;
short val16, sval, sblank;
#ifdef HAVE_LONG_LONG_INT
ULONGLONG lluval, llublank;
SLONGLONG llval, llblank;
#endif
unsigned int iuval, iublank;
int curval, dval, blankflag, ival, iblank;
int curval, dval, blankflag, bswapflag, ival, iblank;
size_t i, bowl, spoonful, npix;
PIXTYPE bs,bz;
/* a NULL cat structure indicates that no data can be read */
if (!(cat = tab->cat))
return;
......@@ -332,6 +333,7 @@ void read_body(tabstruct *tab, PIXTYPE *ptr, size_t size)
bs = (PIXTYPE)tab->bscale;
bz = (PIXTYPE)tab->bzero;
blankflag = tab->blankflag;
bswapflag = *((char *)&ashort); // Byte-swapping flag
switch(tab->compress_type)
{
......@@ -630,20 +632,23 @@ INPUT A pointer to the tab structure,
OUTPUT -.
NOTES .
AUTHOR E. Bertin (IAP)
VERSION 28/03/2013
VERSION 11/02/2020
***/
void read_ibody(tabstruct *tab, FLAGTYPE *ptr, size_t size)
{
catstruct *cat;
static int bufdata0[DATA_BUFSIZE/sizeof(int)];
char *bufdata;
short val16;
int i, bowl, spoonful, npix, curval, dval;
catstruct *cat;
static int bufdata0[DATA_BUFSIZE/sizeof(int)];
char *bufdata;
short val16;
unsigned short ashort = 1;
int i, bowl, spoonful, npix, curval, dval, bswapflag;
/* a NULL cat structure indicates that no data can be read */
if (!(cat = tab->cat))
return;
bswapflag = *((char *)&ashort); // Byte-swapping flag
switch(tab->compress_type)
{
/*-- Uncompressed image */
......@@ -810,15 +815,19 @@ INPUT A pointer to the tab structure,
OUTPUT -.
NOTES .
AUTHOR E. Bertin (IAP)
VERSION 28/03/2013
VERSION 11/02/2020
***/
void write_body(tabstruct *tab, PIXTYPE *ptr, size_t size)
{
static double bufdata0[DATA_BUFSIZE/sizeof(double)];
catstruct *cat;
char *cbufdata0;
size_t i, bowl, spoonful;
PIXTYPE bs,bz;
static double bufdata0[DATA_BUFSIZE/sizeof(double)];
catstruct *cat;
char *cbufdata0;
size_t i, bowl, spoonful;
PIXTYPE bs,bz;
unsigned short ashort = 1;
int bswapflag;
bswapflag = *((char *)&ashort); // Byte-swapping flag
bs = (PIXTYPE)tab->bscale;
bz = (PIXTYPE)tab->bzero;
......@@ -972,7 +981,7 @@ INPUT A pointer to the tab structure,
OUTPUT -.
NOTES .
AUTHOR E. Bertin (IAP)
VERSION 28/03/2013
VERSION 11/02/2020
***/
void write_ibody(tabstruct *tab, FLAGTYPE *ptr, size_t size)
{
......@@ -980,7 +989,11 @@ void write_ibody(tabstruct *tab, FLAGTYPE *ptr, size_t size)
catstruct *cat;
char *cbufdata0;
size_t i, bowl, spoonful;
unsigned short ashort = 1;
double bs,bz;
int bswapflag;
bswapflag = *((char *)&ashort); // Byte-swapping flag
bs = tab->bscale;
bz = tab->bzero;
......
......@@ -7,7 +7,7 @@
*
* This file part of: AstrOmatic FITS/LDAC library
*
* Copyright: (C) 1995-2012 Emmanuel Bertin -- IAP/CNRS/UPMC
* Copyright: (C) 1995-2020 IAP/CNRS/SorbonneU
*
* License: GNU General Public License
*
......@@ -23,7 +23,7 @@
* along with AstrOmatic software.
* If not, see <http://www.gnu.org/licenses/>.
*
* Last modified: 29/08/2012
* Last modified: 11/02/2020
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
......@@ -332,7 +332,4 @@ extern void error(int, char *, char *),
swapbytes(void *ptr, int nb, int n),
warning(char *msg1, char *msg2);
int bswapflag;
#endif
......@@ -7,7 +7,7 @@
*
* This file part of: AstrOmatic FITS/LDAC library
*
* Copyright: (C) 1995-2013 Emmanuel Bertin -- IAP/CNRS/UPMC
* Copyright: (C) 1995-2020 IAP/CNRS/SorbonneU
*
* License: GNU General Public License
*
......@@ -23,7 +23,7 @@
* along with AstrOmatic software.
* If not, see <http://www.gnu.org/licenses/>.
*
* Last modified: 15/02/2013
* Last modified: 11/02/2020
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
......@@ -90,8 +90,6 @@ char gstr[MAXCHAR];
/*----------------------------- External constants --------------------------*/
extern int bswapflag; /* != 0 if bytes are swapped/IEEE */
/*------------------------------- Other Macros -----------------------------*/
#if _LARGEFILE_SOURCE
......
......@@ -7,7 +7,7 @@
*
* This file part of: AstrOmatic FITS/LDAC library
*
* Copyright: (C) 1995-2010 Emmanuel Bertin -- IAP/CNRS/UPMC
* Copyright: (C) 1995-2020 IAP/CNRS/SorbonneU
*
* License: GNU General Public License
*
......@@ -23,7 +23,7 @@
* along with AstrOmatic software.
* If not, see <http://www.gnu.org/licenses/>.
*
* Last modified: 09/10/2010
* Last modified: 11/02/2020
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
......@@ -97,14 +97,15 @@ OUTPUT Checksum.
NOTES Straightforward copy of Seaman & Pence 1995
(ftp://iraf.noao.edu/misc/checksum/).
AUTHOR E. Bertin (IAP)
VERSION 08/05/2001
VERSION 11/02/2020
***/
unsigned int decode_checksum(char *str)
{
char cbuf[16];
unsigned short *sbuf,
los,his;
los,his,
ashort = 1;
unsigned int hi,lo, hicarry,locarry;
int i;
......@@ -113,7 +114,7 @@ unsigned int decode_checksum(char *str)
cbuf[i] = str[(i+1)%16] - 0x30;
sbuf = (unsigned short *)cbuf;
hi = lo = 0;
if (bswapflag)
if (*((char *)&ashort)) // Byte-swapping required
for (i=4; i--;)
{
his = *(sbuf++);
......@@ -153,19 +154,20 @@ NOTES From Seaman & Pence 1995 (ftp://iraf.noao.edu/misc/checksum/). But
depends on the endianity of the machine. The routine below adds
support for ix386-like processors (non-IEEE).
AUTHOR E. Bertin (IAP)
VERSION 08/05/2001
VERSION 11/02/2020
***/
unsigned int compute_blocksum(char *buf, unsigned int sum)
{
unsigned short *sbuf,
his,los;
his,los,
ashort = 1;
unsigned int hi,lo, hicarry,locarry;
int i;
sbuf = (unsigned short *)buf;
hi = (sum >> 16);
lo = (sum << 16) >> 16;
if (bswapflag)
if (*((char *)&ashort)) // Byte-swapping required
for (i=FBSIZE/4; i--;)
{
his = *(sbuf++);
......
......@@ -7,7 +7,7 @@
*
* This file part of: AstrOmatic FITS/LDAC library
*
* Copyright: (C) 1995-2012 Emmanuel Bertin -- IAP/CNRS/UPMC
* Copyright: (C) 1995-2020 IAP/CNRS/SorbonneU
*
* License: GNU General Public License
*
......@@ -23,7 +23,7 @@
* along with AstrOmatic software.
* If not, see <http://www.gnu.org/licenses/>.
*
* Last modified: 13/06/2012
* Last modified: 11/02/2020
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
......@@ -208,18 +208,19 @@ INPUT pointer to the table,
OUTPUT A pointer to the relevant key, or NULL if the desired key is not
found in the table.
NOTES If key->ptr is not NULL, the function doesn't do anything.
AUTHOR E. Bertin (IAP & Leiden observatory)
AUTHOR E. Bertin (IAP)
E.R. Deul (Sterrewacht Leiden) (Added open_cat error checking)
VERSION 18/02/2000
VERSION 11/02/2020
***/
keystruct *read_key(tabstruct *tab, char *keyname)
{
catstruct *cat;
keystruct *key;
char *buf, *ptr, *fptr,*fptr0;
int i,j, larray,narray,size;
int esize;
catstruct *cat;
keystruct *key;
char *buf, *ptr, *fptr,*fptr0;
unsigned short ashort = 1;
int i,j, larray,narray,size,
esize, bswapflag;
if (!(key = name_to_key(tab, keyname)))
return NULL;
......@@ -256,6 +257,7 @@ keystruct *read_key(tabstruct *tab, char *keyname)
/*allocate memory for the array*/
QMALLOC(ptr, char, size*narray);
key->ptr = ptr;
bswapflag = *((char *)&ashort); // Byte-swapping flag
/*read line by line*/
for (i=narray; i--;)
......@@ -289,19 +291,20 @@ NOTES The array of pointers pointed by keys is filled with pointers
A NULL keys pointer can be given (no info returned of course).
A NULL keynames pointer means read ALL keys belonging to the table.
A NULL mask pointer means NO selection for reading.
AUTHOR E. Bertin (IAP & Leiden observatory)
VERSION 18/02/2000
AUTHOR E. Bertin (IAP)
VERSION 11/02/2020
***/
void read_keys(tabstruct *tab, char **keynames, keystruct **keys, int nkeys,
BYTE *mask)
{
catstruct *cat;
keystruct *key, **ckeys;
BYTE *mask2;
char *buf, *ptr, *fptr;
int i,j,k,n, larray,narray, nb, kflag = 0, size;
int esize;
catstruct *cat;
keystruct *key, **ckeys;
BYTE *mask2;
char *buf, *ptr, *fptr;
unsigned short ashort = 1;
int i,j,k,n, larray,narray, nb, kflag = 0, size,
esize, bswapflag;
/*!! It is not necessarily the original table */
tab = tab->key->tab;
......@@ -378,6 +381,7 @@ void read_keys(tabstruct *tab, char **keynames, keystruct **keys, int nkeys,
QFSEEK(cat->file, tab->bodypos , SEEK_SET, cat->filename);
/*read line by line*/
bswapflag = *((char *)&ashort); // Byte-swapping flag
n = 0;
mask2 = mask;
for (i=narray; i--;)
......@@ -587,20 +591,23 @@ NOTES This is approximately the same code as for read_keys.
A NULL keys pointer can be given (no info returned of course).
A NULL keynames pointer means read ALL keys belonging to the table.
A NULL mask pointer means NO selection for reading.
AUTHOR E. Bertin (IAP & Leiden observatory)
VERSION 13/06/2012
AUTHOR E. Bertin (IAP)
VERSION 11/02/2020
***/
void show_keys(tabstruct *tab, char **keynames, keystruct **keys, int nkeys,
BYTE *mask, FILE *stream,
int strflag, int banflag, int leadflag, output_type o_type)
{
catstruct *cat;
keystruct *key, **ckeys;
BYTE *mask2;
char *buf, *rfield, *ptr;
int i,j,k,n,c, larray,narray, nb, kflag, maxnbytes, nelem,
esize, *key_col;
catstruct *cat;
keystruct *key, **ckeys;
BYTE *mask2;
char *buf, *rfield, *ptr;
unsigned short ashort = 1;
int *key_col,
i,j,k,n,c, larray,narray, nb, kflag, maxnbytes, nelem,
esize, bswapflag;
typedef struct structreq_keyname
{
char oldname[80]; /* Name of the original pipeline key */
......@@ -793,6 +800,7 @@ void show_keys(tabstruct *tab, char **keynames, keystruct **keys, int nkeys,
QFSEEK(cat->file, tab->bodypos , SEEK_SET, cat->filename);
/*read line by line*/
bswapflag = *((char *)&ashort); // Byte-swapping flag
n = 0;
mask2 = mask;
for (i=narray; i--;)
......
......@@ -7,7 +7,7 @@
*
* This file part of: AstrOmatic FITS/LDAC library
*
* Copyright: (C) 1995-2010 Emmanuel Bertin -- IAP/CNRS/UPMC
* Copyright: (C) 1995-2020 IAP/CNRS/SorbonneU
*
* License: GNU General Public License
*
......@@ -23,7 +23,7 @@
* along with AstrOmatic software.
* If not, see <http://www.gnu.org/licenses/>.
*
* Last modified: 09/10/2010
* Last modified: 11/02/2020
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
......@@ -162,18 +162,21 @@ INPUT Table which will be accessed from disk (provided by init_readobj()),
pointer to the temporary buffer.
OUTPUT The number of table lines that remain to be read.
NOTES -.
AUTHOR E. Bertin (IAP & Leiden observatory)
VERSION 26/09/2004
AUTHOR E. Bertin (IAP)
VERSION 11/02/2020
***/
int read_obj(tabstruct *keytab, tabstruct *tab, char *buf)
{
keystruct *key;
char *pin, *pout;
int b,k;
int esize;
keystruct *key;
char *pin, *pout;
unsigned short ashort = 1;
int b, k, esize, bswapflag;
QFREAD(buf,keytab->naxisn[0],keytab->cat->file,keytab->cat->filename);
bswapflag = *((char *)&ashort); // Byte-swapping flag
key = tab->key;
for (k=tab->nkey; k--; key = key->nextkey)
if (key->pos>=0)
......@@ -202,22 +205,23 @@ INPUT Table which will be accessed from disk (provided by init_readobj()),
position number in table.
OUTPUT RETURN_OK if the object has been accessed, RETURN_ERROR otherwise.
NOTES -.
AUTHOR E. Bertin (IAP & Leiden observatory)
VERSION 26/09/2004
AUTHOR E. Bertin (IAP)
VERSION 11/02/2020
***/
int read_obj_at(tabstruct *keytab, tabstruct *tab, char *buf, long pos)
{
keystruct *key;
char *pin, *pout;
size_t n;
int b,k;
int esize;
keystruct *key;
char *pin, *pout;
size_t n;
unsigned short ashort = 1;
int b, k, esize, bswapflag;
if ((n=keytab->naxisn[0]*pos) >= keytab->tabsize)
return RETURN_ERROR;
QFSEEK(keytab->cat->file,keytab->bodypos+n, SEEK_SET, keytab->cat->filename);
QFREAD(buf,keytab->naxisn[0],keytab->cat->file,keytab->cat->filename);
bswapflag = *((char *)&ashort); // Byte-swapping flag
key = tab->key;
for (k=tab->nkey; k--; key = key->nextkey)
if (key->pos>=0)
......
......@@ -7,7 +7,7 @@
*
* This file part of: AstrOmatic FITS/LDAC library
*
* Copyright: (C) 1995-2012 Emmanuel Bertin -- IAP/CNRS/UPMC
* Copyright: (C) 1995-2020 IAP/CNRS/SorbonneU
*
* License: GNU General Public License
*
......@@ -23,7 +23,7 @@
* along with AstrOmatic software.
* If not, see <http://www.gnu.org/licenses/>.
*
* Last modified: 27/08/2012
* Last modified: 11/02/2020
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
......@@ -87,22 +87,23 @@ INPUT pointer to the catalog structure,
pointer to the table structure.
OUTPUT -.
NOTES -.
AUTHOR E. Bertin (IAP & Leiden observatory)
VERSION 13/06/2012
AUTHOR E. Bertin (IAP)
VERSION 11/02/2020
***/
void save_tab(catstruct *cat, tabstruct *tab)
{
catstruct *tabcat;
keystruct *key;
tabstruct *keytab;
KINGSIZE_T tabsize;
long size;
int b,j,k,o, nbytes,nkey,nobj,spoonful,
tabflag, larrayin,larrayout;
char *buf, *inbuf, *outbuf, *fptr,*ptr;
int esize;
catstruct *tabcat;
keystruct *key;
tabstruct *keytab;
KINGSIZE_T tabsize;
long size;
char *buf, *inbuf, *outbuf, *fptr,*ptr;
unsigned short ashort = 1;
int b,j,k,o, nbytes,nkey,nobj,spoonful,
tabflag, larrayin,larrayout, esize, bswapflag;
bswapflag = *((char *)&ashort); // Byte-swapping flag
/* The header itself*/
tabflag = save_head(cat, tab)==RETURN_OK?1:0;
/* Allocate memory for the output buffer */
......@@ -314,18 +315,21 @@ INPUT Table structure,
pointer to the temporary buffer.
OUTPUT -.
NOTES key content is destroyed (actually, byte-swapped) on output.
AUTHOR E. Bertin (IAP & Leiden observatory)
VERSION 27/08/2012
AUTHOR E. Bertin (IAP)
VERSION 11/02/2020
***/
int write_obj(tabstruct *tab, char *buf)
{
keystruct *key;
char *pin, *pout, *pout2;
int b,k;
int esize;
catstruct *cat;
keystruct *key;
char *pin, *pout, *pout2;
unsigned short ashort = 1;
int b, k, esize, bswapflag;
bswapflag = *((char *)&ashort); // Byte-swapping flag
key = tab->key;
cat = tab->cat;
pout = buf;
for (k=tab->nkey; k--; key = key->nextkey)
{
......@@ -340,7 +344,7 @@ int write_obj(tabstruct *tab, char *buf)
}
}
QFWRITE(buf, *tab->naxisn, tab->cat->file, tab->cat->filename);
QFWRITE(buf, *tab->naxisn, cat->file, cat->filename);
return ++tab->naxisn[1];
}
......
......@@ -7,7 +7,7 @@
*
* This file part of: SExtractor
*
* Copyright: (C) 2007-2010 Emmanuel Bertin -- IAP/CNRS/UPMC
* Copyright: (C) 2007-2020 IAP/CNRS/SorbonneU
*
* License: GNU General Public License
*
......@@ -22,7 +22,7 @@
* You should have received a copy of the GNU General Public License
* along with SExtractor. If not, see <http://www.gnu.org/licenses/>.
*
* Last modified: 11/10/2010
* Last modified: 11/02/2020
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
......@@ -47,7 +47,6 @@ int main(int argc, char *argv[])
{
catstruct *cat;
tabstruct *tab;
unsigned short ashort=1;
char catname[MAXCHAR];
int a, t, opt,opt2, flag;
......@@ -59,9 +58,6 @@ int main(int argc, char *argv[])
error(EXIT_SUCCESS, "SYNTAX: ", SYNTAX);
}
/* Test if byteswapping will be needed */
bswapflag = *((char *)&ashort);
/* Default parameters */
for (a=1; a<argc; a++)
{
......
......@@ -7,7 +7,7 @@
*
* This file part of: SExtractor
*
* Copyright: (C) 1993-2013 Emmanuel Bertin -- IAP/CNRS/UPMC
* Copyright: (C) 1993-2020 IAP/CNRS/SorbonneU
*
* License: GNU General Public License
*
......@@ -22,7 +22,7 @@
* You should have received a copy of the GNU General Public License
* along with SExtractor. If not, see <http://www.gnu.org/licenses/>.
*
* Last modified: 18/06/2012
* Last modified: 11/02/2020
*
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
......@@ -404,14 +404,10 @@ void preprefs()
{
char str[80];
unsigned short ashort=1;
#ifdef USE_THREADS
int nproc;
#endif
/* Test if byteswapping will be needed */
bswapflag = *((char *)&ashort);
/* Multithreading */
#ifdef USE_THREADS
if (prefs.nthreads <= 0)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment