Ignore:
Timestamp:
May 10, 2016, 12:12:41 AM (3 years ago)
Author:
nmedfort
Message:

UnicodeSet? bug fix and compile warning clean-up.

File:
1 edited

Legend:

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

    r5033 r5037  
    8484}
    8585
    86 void GrepEngine::doGrep(const std::string & fileName, const int fileIdx, bool CountOnly, std::vector<int> & total_CountOnly) {
    87     const path file(fileName);
     86void GrepEngine::doGrep(const std::string & fileName, const int fileIdx, bool CountOnly, std::vector<uint64_t> & total_CountOnly) {
     87    path file(fileName);
    8888    if (exists(file)) {
    8989        if (is_directory(file)) {
     
    9595    }
    9696
    97     const size_t fileSize = file_size(file);
     97    const auto fileSize = file_size(file);
    9898    if (fileSize > 0) {
    99         mapped_file_source file;
    10099        try {
    101             file.open(fileName);
    102         } catch (std::exception &e) {
     100            mapped_file_source source(fileName, fileSize, 0);
     101            char * fileBuffer = const_cast<char *>(source.data());
     102            if (CountOnly) {
     103                total_CountOnly[fileIdx] = mGrepFunction_CountOnly(fileBuffer, fileSize, fileIdx, finalLineIsUnterminated(fileBuffer, fileSize));
     104            } else {
     105                mGrepFunction(fileBuffer, fileSize, fileIdx, finalLineIsUnterminated(fileBuffer, fileSize));
     106            }
     107            source.close();
     108        } catch (std::exception & e) {
    103109            throw std::runtime_error("Boost mmap error: " + fileName + ": " + e.what());
    104110        }
    105         char * fileBuffer = const_cast<char *>(file.data());
    106         if(CountOnly){
    107             total_CountOnly[fileIdx] = mGrepFunction_CountOnly(fileBuffer, fileSize, fileIdx, finalLineIsUnterminated(fileBuffer, fileSize));
    108         }
    109         else{
    110             mGrepFunction(fileBuffer, fileSize, fileIdx, finalLineIsUnterminated(fileBuffer, fileSize));
    111         }
    112         file.close();
    113     }
    114     else {
    115         if(CountOnly) {
     111    } else {
     112        if(CountOnly) {
    116113            mGrepFunction_CountOnly(nullptr, 0, fileIdx, false);
    117         }
    118         else{
    119             mGrepFunction(nullptr, 0, fileIdx, false);
    120         }
     114        } else {
     115            mGrepFunction(nullptr, 0, fileIdx, false);
     116        }
    121117    }
    122118}
     
    147143    verifyModule(*M, &dbgs());
    148144    #endif
     145
    149146    mEngine->finalizeObject();
    150147    delete idb;
    151148
    152     if(CountOnly){
     149    if (CountOnly) {
    153150        mGrepFunction_CountOnly = reinterpret_cast<GrepFunctionType_CountOnly>(mEngine->getPointerToFunction(grepIR));
    154     }
    155     else{
     151    } else {
    156152        mGrepFunction = reinterpret_cast<GrepFunctionType>(mEngine->getPointerToFunction(grepIR));
    157153    }
     
    193189    resultStrs = new std::stringstream[n];
    194190    total_count = new int[n];
    195     for (int i=0; i<inputFiles.size(); i++){
     191    for (unsigned i = 0; i < inputFiles.size(); ++i){
    196192        total_count[i] = 0;
    197193    }
     
    249245}
    250246
    251 void PrintResult(bool CountOnly, std::vector<int> & total_CountOnly){
     247void PrintResult(bool CountOnly, std::vector<uint64_t> & total_CountOnly){
    252248    if(CountOnly){
    253249        if (!ShowFileNames) {
    254             for (int i=0; i<inputFiles.size(); i++){
     250            for (unsigned i = 0; i < inputFiles.size(); ++i){
    255251                std::cout << total_CountOnly[i] << std::endl;
    256252            }
    257253        }
    258254        else {
    259             for (int i=0; i<inputFiles.size(); i++){
     255            for (unsigned i = 0; i < inputFiles.size(); ++i){
    260256                std::cout << inputFiles[i] << ':' << total_CountOnly[i] << std::endl;
    261257            };
     
    264260    }
    265261   
    266     std::string out;
    267     for (int i=0; i<inputFiles.size(); i++){
     262    for (unsigned i = 0; i < inputFiles.size(); ++i){
    268263        std::cout << resultStrs[i].str();
    269264    }
Note: See TracChangeset for help on using the changeset viewer.