Changeset 11017 for trunk/FACT++/src


Ignore:
Timestamp:
06/13/11 22:25:39 (13 years ago)
Author:
tbretz
Message:
Removed the wrong string conversion from ToFits; fixed the sanity check in the loop; added a check to check for only valid types.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/Converter.cc

    r10666 r11017  
    782782        format.second.first = cnt == 0 ? 1 : cnt;
    783783
     784        /*
    784785        if (strict && t[0]=='C' && cnt>0)
    785786        {
    786787            out << kRed << "Dim doesn't support the format C with N>0!" << endl;
    787788            return FormatList();
    788         }
     789        }*/
    789790
    790791        // Check if the format is just C (without a number)
     
    869870   for (Converter::FormatList::const_iterator i=fList.begin(); i!=fList.end(); i++)
    870871   {
    871 //ETIENNE this check fails for very fine cases. Disabled it
    872        // FIXME: This is still not really safe
    873 //       if (charDest-size>=dest)
    874 //       {
    875 //           ostringstream err;
    876 //           err << "Format description [fmt=" << fFormat << "] exceeds available data size (" << size << ")";
    877 //           throw runtime_error(err.str());
    878 //       }
     872       if (charDest-size>dest)
     873       {
     874           ostringstream err;
     875           err << "Format description [fmt=" << fFormat << "] exceeds available data size (" << size << ")";
     876           throw runtime_error(err.str());
     877       }
    879878
    880879       const char type = i->first.first->name()[0];
     880       if (type=='v')
     881           break;
    881882
    882883       // string types
    883        if (type=='S' || type=='O' || type=='W')
    884        {
    885            // copy string until termination
    886            while (*charSrc)
    887                *charDest++ = *charSrc++;
    888 
    889            // Copy \0-termination
    890 //ETIENNE: Do not copy the \0 as it must not be written to fits files. just increment charSrc instead
    891  //          *charDest++ = *charSrc++;
    892                         charSrc++;
    893            continue;
    894        }
     884       if (string("bsilfdx").find_first_of(type)==string::npos)
     885           throw runtime_error(string("Type '")+type+"' not supported converting to FITS.");
    895886
    896887       const int s = i->first.second;      // size of element
     
    917908vector<char> Converter::ToFits(const void *src, size_t size) const
    918909{
    919    vector<char> dest(size);
    920    ToFits(&dest[0], src, size);
    921    return dest;
     910    vector<char> dest(size);
     911    ToFits(dest.data(), src, size);
     912    return dest;
    922913}
    923914
Note: See TracChangeset for help on using the changeset viewer.