Ignore:
Timestamp:
Sep 27, 2015, 1:32:27 AM (4 years ago)
Author:
nmedfort
Message:

Progress on multi-target UCD compiler.

File:
1 edited

Legend:

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

    r4795 r4797  
    7070            mLineNum++;
    7171        }
     72        assert (buffer + line_end < mFileBuffer + mFileSize);
    7273        if (mShowFileNameOption) {
    7374            out << mFileName << ':';
     
    7778        }
    7879        if ((buffer[line_start] == 0xA) && (line_start != line_end)) {
    79             // The line "starts" on the LF of a CRLF.  Really the end of the last line.
     80            // The LF of a CRLF.  Really the end of the last line.
    8081            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;
    8982        }
    9083        unsigned char end_byte = (unsigned char)buffer[line_end];
     
    10194        }
    10295        else {
    103             if (end_byte == 0x0D) {
     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) {
    104101                // Check for line_end on first byte of CRLF;  note that we don't
    105102                // want to access past the end of buffer.
     
    270267    //Final Partial Block (may be empty, but there could be carries pending).
    271268   
    272    
    273269    const auto EOF_mask = bitblock::srl(simd<1>::constant<1>(), convert(BLOCK_SIZE - remaining));
    274270   
    275     if (remaining == 0) {  // No data, we may be at a page boundary.   Do not access memory.
    276         basis_bits.bit_0 = simd<1>::constant<0>();
    277         basis_bits.bit_1 = simd<1>::constant<0>();
    278         basis_bits.bit_2 = simd<1>::constant<0>();
    279         basis_bits.bit_3 = simd<1>::constant<0>();
    280         basis_bits.bit_4 = simd<1>::constant<0>();
    281         basis_bits.bit_5 = simd<1>::constant<0>();
    282         basis_bits.bit_6 = simd<1>::constant<0>();
    283         basis_bits.bit_7 = simd<1>::constant<0>();
    284     }
    285     else { // At least 1 byte, so we are not at a page boundary yet, safe to access a full block.
    286         s2p_do_final_block(reinterpret_cast<BytePack *>(mFileBuffer + (blk * BLOCK_SIZE) + (segment * SEGMENT_SIZE)), basis_bits, EOF_mask);
    287     }
     271    s2p_do_final_block(reinterpret_cast<BytePack *>(mFileBuffer + (blk * BLOCK_SIZE) + (segment * SEGMENT_SIZE)), basis_bits, EOF_mask);
    288272
    289273    if (finalLineIsUnterminated()) {
Note: See TracChangeset for help on using the changeset viewer.