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