]> Creatis software - gdcm.git/blobdiff - src/gdcmDocument.cxx
STYLE: minor
[gdcm.git] / src / gdcmDocument.cxx
index e91b158c544c4d31ba3ed1b7bd589a0bccaa4c9c..53b39e752917d3fcaa7e893166d28674bdc940a8 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocument.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/07/19 05:59:12 $
-  Version:   $Revision: 1.54 $
+  Date:      $Date: 2004/07/28 21:13:03 $
+  Version:   $Revision: 1.58 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -301,7 +301,7 @@ bool gdcmDocument::IsReadable()
  * @param   SyntaxToCheck The transfert syntax we need to check against.
  * @return  True when SyntaxToCheck corresponds to the Transfer Syntax of
  *          the current document. False either when the document contains
- *          no Transfer Syntax, or when the Tranfer Syntaxes don't match.
+ *          no Transfer Syntax, or when the Tranfer Syntaxes doesn't match.
  */
 bool gdcmDocument::IsGivenTransferSyntax(std::string const & syntaxToCheck)
 {
@@ -312,24 +312,23 @@ bool gdcmDocument::IsGivenTransferSyntax(std::string const & syntaxToCheck)
    }
 
    // The entry might be present but not loaded (parsing and loading
-   // happen at differente stages): try loading and proceed with check...
+   // happen at different stages): try loading and proceed with check...
    LoadDocEntrySafe(entry);
    if (gdcmValEntry* valEntry = dynamic_cast< gdcmValEntry* >(entry) )
    {
       std::string transfer = valEntry->GetValue();
-
       // The actual transfer (as read from disk) might be padded. We
       // first need to remove the potential padding. We can make the
       // weak assumption that padding was not executed with digits...
+      if  ( transfer.length() == 0 ) { // for brain damaged headers
+         return false;
+      }
       while ( ! isdigit(transfer[transfer.length()-1]) )
       {
          transfer.erase(transfer.length()-1, 1);
       }
       if ( transfer == syntaxToCheck )
-      //if( transfer.find( syntaxToCheck ) )   //should be faster
       {
-         int k = 
-         abort()
          return true;
       }
    }
@@ -880,10 +879,10 @@ bool gdcmDocument::SetEntryByNumber(std::string content,
                      " ValEntry (try promotion first).");
       return false;
    }
-   // Non even content must be padded with a space (020H).
+   // Non even content must be padded with a space (020H)...
    if( content.length() % 2 )
    {
-      content += '\0';
+      content += '\0';  // ... therefore we padd with (000H) .!?!
    }      
    valEntry->SetValue(content);
    
@@ -926,7 +925,7 @@ bool gdcmDocument::SetEntryByNumber(void *content,
       return false;
    }
 
-/* Hope Binaray field length is *never* wrong    
+/* Hope Binary field length is *never* wrong    
    if(lgth%2) // Non even length are padded with a space (020H).
    {  
       lgth++;
@@ -1778,7 +1777,7 @@ void gdcmDocument::FindDocEntryVR( gdcmDocEntry *entry )
    // is in explicit VR and try to fix things if it happens not to be
    // the case.
    
-   fread (&vr, (size_t)2,(size_t)1, Fp);
+   fread (vr, (size_t)2,(size_t)1, Fp);
    vr[2] = 0;
 
    if( !CheckDocEntryVR(entry, vr) )
@@ -2707,7 +2706,8 @@ void gdcmDocument::Parse7FE0 ()
          s << "   Read one length: ";
          s << std::hex << individualLength << std::endl;
          dbg.Verbose(0, "gdcmDocument::Parse7FE0: ", s.str().c_str());
-      }              
+      }
+      delete[] basicOffsetTableItemValue;
    }
 
    if ( ! IsRLELossLessTransferSyntax() )