Changeset 13778

Show
Ignore:
Timestamp:
02/13/08 18:04:13 (3 months ago)
Author:
warmerdam
Message:

fix array overrun from last change, reformat code (#2224)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/gdal/frmts/gsg/gsagdataset.cpp

    r13776 r13778  
    311311    if( panLineOffset[nBlockYOff] == 0 ) 
    312312    { 
    313                // Discover the last read block 
    314                for ( int iFoundLine = nLastReadLine - 1; iFoundLine > nBlockYOff; iFoundLine--) 
    315                
    316                        IReadBlock( nBlockXOff, iFoundLine, NULL); 
    317                
     313        // Discover the last read block 
     314        for ( int iFoundLine = nLastReadLine - 1; iFoundLine > nBlockYOff; iFoundLine--) 
     315       
     316            IReadBlock( nBlockXOff, iFoundLine, NULL); 
     317       
    318318    } 
    319319 
     
    323323    { 
    324324        CPLError( CE_Failure, CPLE_FileIO, 
    325               "Can't seek to offset %ld to read grid row %d.", 
    326               panLineOffset[nBlockYOff], nBlockYOff ); 
     325                  "Can't seek to offset %ld to read grid row %d.", 
     326                  panLineOffset[nBlockYOff], nBlockYOff ); 
    327327        return CE_Failure; 
    328328    } 
     
    337337        assert(panLineOffset[nBlockYOff-1] > panLineOffset[nBlockYOff]); 
    338338        nLineBufSize = panLineOffset[nBlockYOff-1] 
    339                              - panLineOffset[nBlockYOff] + 1; 
     339            - panLineOffset[nBlockYOff] + 1; 
    340340    } 
    341341    else 
     
    421421 
    422422                while( *szStart == '\0' && 
    423                        static_cast<size_t>(szStart - szLineBuf) < nCharsRead ) 
     423                       static_cast<size_t>(szStart - szLineBuf) < nCharsRead ) 
    424424                    szStart++; 
    425425 
     
    443443        } 
    444444        else if( *szEnd == '\0' 
    445                || (*szEnd == '.' && *(szEnd+1) == '\0') 
    446                || (*szEnd == '-' && *(szEnd+1) == '\0') 
    447                || (*szEnd == '+' && *(szEnd+1) == '\0') 
    448                || (*szEnd == 'E' && *(szEnd+1) == '\0') 
    449                || (*szEnd == 'E' && *(szEnd+1) == '-' && *(szEnd+2) == '\0') 
    450                || (*szEnd == 'E' && *(szEnd+1) == '+' && *(szEnd+2) == '\0') 
    451                || (*szEnd == 'e' && *(szEnd+1) == '\0') 
    452                || (*szEnd == 'e' && *(szEnd+1) == '-' && *(szEnd+2) == '\0') 
    453                || (*szEnd == 'e' && *(szEnd+1) == '+' && *(szEnd+2) == '\0')) 
     445                 || (*szEnd == '.' && *(szEnd+1) == '\0') 
     446                 || (*szEnd == '-' && *(szEnd+1) == '\0') 
     447                 || (*szEnd == '+' && *(szEnd+1) == '\0') 
     448                 || (*szEnd == 'E' && *(szEnd+1) == '\0') 
     449                 || (*szEnd == 'E' && *(szEnd+1) == '-' && *(szEnd+2) == '\0') 
     450                 || (*szEnd == 'E' && *(szEnd+1) == '+' && *(szEnd+2) == '\0') 
     451                 || (*szEnd == 'e' && *(szEnd+1) == '\0') 
     452                 || (*szEnd == 'e' && *(szEnd+1) == '-' && *(szEnd+2) == '\0') 
     453                 || (*szEnd == 'e' && *(szEnd+1) == '+' && *(szEnd+2) == '\0')) 
    454454        { 
    455455            /* Number was interrupted by a nul character */ 
     
    518518    if( *szEnd != '\0' && *szEnd != poGDS->szEOL[0] ) 
    519519        CPLDebug( "GSAG", "Grid row %d does not end with a newline.  " 
    520                         "Possible skew.\n", nBlockYOff ); 
     520                  "Possible skew.\n", nBlockYOff ); 
    521521 
    522522    while( isspace( *szEnd ) ) 
     
    528528        nMaxLineSize = nCharsExamined + 1; 
    529529 
    530     panLineOffset[nBlockYOff - 1] = panLineOffset[nBlockYOff] + nCharsExamined; 
    531         nLastReadLine = nBlockYOff; 
     530    if( nBlockYOff > 0 ) 
     531        panLineOffset[nBlockYOff - 1] =  
     532            panLineOffset[nBlockYOff] + nCharsExamined; 
     533 
     534    nLastReadLine = nBlockYOff; 
    532535 
    533536    VSIFree( szLineBuf );