Changeset 4795


Ignore:
Timestamp:
Sep 26, 2015, 10:07:14 AM (2 years ago)
Author:
cameron
Message:

Remove assert; handle buffer + line_end == mFileBuffer + mFileSize

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/do_grep.cpp

    r4792 r4795  
    7070            mLineNum++;
    7171        }
    72         assert (buffer + line_end < mFileBuffer + mFileSize);
    7372        if (mShowFileNameOption) {
    7473            out << mFileName << ':';
     
    7877        }
    7978        if ((buffer[line_start] == 0xA) && (line_start != line_end)) {
    80             // The LF of a CRLF.  Really the end of the last line.
     79            // The line "starts" on the LF of a CRLF.  Really the end of the last line.
    8180            line_start++;
     81        }
     82        if (buffer + line_end == mFileBuffer + mFileSize) {
     83            // The match position is at end-of-file.   We have a final unterminated line.
     84            out.write(&buffer[line_start], line_end - line_start);
     85            if (mNormalizeLineBreaksOption) {
     86              out << '\n';  // terminate it
     87            }
     88            return line_end;
    8289        }
    8390        unsigned char end_byte = (unsigned char)buffer[line_end];
     
    94101        }
    95102        else {
    96             if (end_byte == 0x0) {
    97                 // This must be a sentinel byte position at the end of file.
    98                 // Do not write it.
    99                 line_end--;
    100             } else if (end_byte == 0x0D) {
     103            if (end_byte == 0x0D) {
    101104                // Check for line_end on first byte of CRLF;  note that we don't
    102105                // want to access past the end of buffer.
Note: See TracChangeset for help on using the changeset viewer.