IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 28511 for trunk


Ignore:
Timestamp:
Jun 25, 2010, 2:55:15 PM (16 years ago)
Author:
Paul Price
Message:

Fix logical error. Add check for empty table when getting size.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/fits/psFitsTable.c

    r28510 r28511  
    3939
    4040    int status = 0;                     // CFITSIO status
     41
     42    // Check for empty table, which looks like an image
     43    int hdutype;                        // Type of HDU
     44    fits_get_hdu_type(fits->fd, &hdutype, &status);
     45    if (psFitsError(status, true, "Could not determine the HDU type.")) {
     46        return -1;
     47    }
     48    if (hdutype == IMAGE_HDU) {
     49        // It could be an empty table
     50        int naxis = 0;                  // Dimensions of image
     51        if (fits_get_img_dim(fits->fd, &naxis, &status) != 0) {
     52            psFitsError(status, true, "Unable to determine dimension for table.");
     53            return -1;
     54        }
     55        if (naxis != 0) {
     56            psFitsError(PS_ERR_BAD_FITS, true, "Current FITS HDU is not a table.");
     57            return -1;
     58        }
     59        return 0;
     60    }
     61
    4162    long numRows;                       // Number of rows
    4263    if (fits_get_num_rows(fits->fd, &numRows, &status)) {
     
    4869}
    4970
     71
    5072// Check the FITS file in preparation for reading a table
    5173static bool readTableCheck(const psFits *fits // FITS file
    5274                           )
    5375{
    54     PS_ASSERT_FITS_NON_NULL(fits, NULL);
     76    PS_ASSERT_FITS_NON_NULL(fits, false);
    5577
    5678    if (psFitsGetExtNum(fits) == 0 && !psFitsMoveExtNum(fits, 1, false)) {
     
    5880        return false;
    5981    }
    60 
    6182
    6283    // check that we are positioned on a table HDU
     
    7899            return false;
    79100        }
    80     }
    81     if (hdutype != ASCII_TBL && hdutype != BINARY_TBL) {
     101    } else if (hdutype != ASCII_TBL && hdutype != BINARY_TBL) {
    82102        psError(PS_ERR_BAD_FITS, true, _("Current FITS HDU is not a table."));
    83103        return false;
Note: See TracChangeset for help on using the changeset viewer.