Ignore:
Timestamp:
Feb 5, 2015, 11:52:07 AM (5 years ago)
Author:
cameron
Message:

Set normalize line breaks option;default off

File:
1 edited

Legend:

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

    r4440 r4460  
    8181        line_start++;
    8282    }
    83     if (buffer[line_end] == 0xA) {
    84         // Normal Unix line end; just write the line.
     83    unsigned char end_byte = (unsigned char) buffer[line_end];
     84    if (mNormalizeLineBreaksOption) {
     85        if (end_byte <= 0xD) {
     86            // Line terminated with LF, VT, FF or CR. 
     87            std::cout.write(&buffer[line_start], line_end - line_start);
     88            std::cout << std::endl;
     89        }
     90        else if (end_byte == 0x85) {
     91            // Line terminated with NEL, on the second byte. 
     92            std::cout.write(&buffer[line_start], line_end - line_start - 1);
     93            std::cout << std::endl;
     94        }
     95        else  {
     96            // Line terminated with PS or LS, on the third byte.
     97            std::cout.write(&buffer[line_start], line_end - line_start - 2);
     98            std::cout << std::endl;
     99        }
     100    }
     101    else {
     102        // TODO:  Adjust for CRLF
    85103        std::cout.write(&buffer[line_start], line_end - line_start + 1);
    86104    }
    87     else if (buffer[line_end] <= 0xD) {
    88         // Line terminated with VT, FF or CR. 
    89         std::cout.write(&buffer[line_start], line_end - line_start);
    90         std::cout << std::endl;
    91     }
    92     else if (((unsigned char) buffer[line_end]) == 0x85) {
    93         // Line terminated with NEL, on the second byte. 
    94         std::cout.write(&buffer[line_start], line_end - line_start - 1);
    95         std::cout << std::endl;
    96     }
    97     else  {
    98         // Line terminated with PS or LS, on the third byte.
    99         std::cout.write(&buffer[line_start], line_end - line_start -2);
    100         std::cout << std::endl;
    101     }
    102      
    103105
    104106    line_start = line_end + 1;
     
    161163        return;
    162164    }
    163    
     165    currentFileSize = infile_sb.st_size;
    164166    char * buffer_ptr;
    165167    int segment = 0;
Note: See TracChangeset for help on using the changeset viewer.