IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 6597


Ignore:
Timestamp:
Mar 15, 2006, 3:00:42 PM (20 years ago)
Author:
Paul Price
Message:

Removing trailing spaces from header values. Trailing spaces aren't
significant, according to the FITS standard.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/rel10_ifa/psLib/src/fits/psFitsHeader.c

    r6354 r6597  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2006-02-08 01:03:34 $
     9 *  @version $Revision: 1.2.4.1 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2006-03-16 01:00:42 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    110110                                        atof(keyValue));
    111111                break;
    112             case 'C':
    113                 // remove the single-quotes at front/end
    114                 if (keyValue[0] == '\'' && keyValue[strlen(keyValue)-1] == '\'') {
    115                     keyValue[strlen(keyValue)-1] = '\0';
     112            case 'C': {
     113                    char *keyValueFixed = keyValue; // Fixed version of the string
     114                    // remove the single-quotes at front/end
     115                    if (keyValueFixed[0] == '\'' && keyValueFixed[strlen(keyValue)-1] == '\'') {
     116                        keyValue[strlen(keyValue)-1] = '\0'; // Remove the trailing quote
     117                        keyValueFixed += 1; // Advance past the leading quote
     118                    }
     119                    // Remove trailing spaces, which are not significant, according to the FITS standard
     120                    // http://archive.stsci.edu/fits/fits_standard/node31.html#SECTION00921000000000000000
     121                    char *lastSpace = NULL; // The last space in the string
     122                    while ((lastSpace = strrchr(keyValueFixed, ' ')) && lastSpace[1] == '\0') {
     123                        // This is a trailing space, not a leading space.
     124                        lastSpace[0] = '\0'; // Truncate the string here
     125                    }
     126
     127                    psTrace("pslib.fits.readHeader", 8, "%s: %s (%s)\n", keyName, keyValueFixed, keyComment);
     128
    116129                    success = psMetadataAdd(out,
    117130                                            PS_LIST_TAIL,
     
    119132                                            PS_DATA_STRING | PS_META_DUPLICATE_OK,
    120133                                            keyComment,
    121                                             keyValue+1);
    122                 } else {
    123                     success = psMetadataAdd(out,
    124                                             PS_LIST_TAIL,
    125                                             keyName,
    126                                             PS_DATA_STRING | PS_META_DUPLICATE_OK,
    127                                             keyComment,
    128                                             keyValue);
     134                                            keyValueFixed);
     135                    break;
    129136                }
    130                 break;
    131137            case 'L':
    132138                tempBool = (keyValue[0] == 'T') ? 1 : 0;
Note: See TracChangeset for help on using the changeset viewer.