Ignore:
Timestamp:
Dec 29, 2016, 12:03:21 AM (3 years ago)
Author:
nmedfort
Message:

Potential fix for '\p{script=/.*hir.*/}'

File:
1 edited

Legend:

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

    r5240 r5241  
    3838#include <util/aligned_allocator.h>
    3939
     40using namespace parabix;
     41
    4042static cl::OptionCategory bGrepOutputOptions("Output Options",
    4143                                             "These options control the output.");
     
    5961std::string IRFilename = "icgrep.ll";
    6062std::string PTXFilename = "icgrep.ptx";
     63
     64static re::CC * parsedCodePointSet = nullptr;
     65static std::vector<std::string> parsedPropertyValues;
    6166
    6267void GrepEngine::doGrep(const std::string & fileName, const int fileIdx, bool CountOnly, std::vector<size_t> & total_CountOnly, bool UTF_16) {
     
    117122    }
    118123}
    119 
    120 using namespace parabix;
    121124
    122125Function * generateGPUKernel(Module * m, IDISA::IDISA_Builder * iBuilder, bool CountOnly){
     
    423426}
    424427
    425 re::CC *  GrepEngine::grepCodepoints() {
    426 
    427     setParsedCodePointSet();
     428re::CC * GrepEngine::grepCodepoints() {
     429    parsedCodePointSet = re::makeCC();
    428430    char * mFileBuffer = getUnicodeNameDataPtr();
    429431    size_t mFileSize = getUnicodeNameDataSize();
    430 
    431432    mGrepFunction(mFileBuffer, mFileSize, 0);
    432 
    433     return getParsedCodePointSet();
     433    return parsedCodePointSet;
    434434}
    435435
    436436const std::vector<std::string> & GrepEngine::grepPropertyValues(const std::string& propertyName) {
    437437    AlignedAllocator<char, 32> alloc;
    438     setParsedPropertyValues();
     438    parsedPropertyValues.clear();
    439439    const std::string & str = UCD::getPropertyValueGrepString(propertyName);
    440     char * aligned = alloc.allocate(str.length() + 1, 0);
    441     std::memcpy(aligned, str.data(), str.length());
    442     aligned[str.length()] = '\0';
    443     mGrepFunction(aligned, str.length(), 0);
     440    const auto n = str.length();
     441    char * aligned = alloc.allocate(n + 32, 0);
     442    std::memcpy(aligned, str.data(), n);
     443    std::memset(aligned + n, 0, 32);
     444    mGrepFunction(aligned, n, 0);
    444445    alloc.deallocate(aligned, 0);
    445     return getParsedPropertyValues();
     446    return parsedPropertyValues;
    446447}
    447448
     
    546547}
    547548
    548 re::CC * parsedCodePointSet;
    549 
    550549extern "C" {
    551550    void insert_codepoints(size_t lineNum, size_t line_start, size_t line_end, const char * buffer) {
     
    566565}
    567566
    568 void setParsedCodePointSet(){
    569     parsedCodePointSet = re::makeCC();
    570 }
    571 
    572 re::CC * getParsedCodePointSet(){
    573     return parsedCodePointSet;
    574 }
    575 
    576 
    577 static std::vector<std::string> parsedPropertyValues;
    578 
    579567extern "C" {
    580568    void insert_property_values(size_t lineNum, size_t line_start, size_t line_end, const char * buffer) {
    581         auto result = std::string(buffer + line_start, buffer + line_end);
    582         parsedPropertyValues.push_back(result);
    583     }
    584 }
    585 
    586 inline void setParsedPropertyValues() {
    587     parsedPropertyValues.clear();
    588 }
    589 
    590 inline const std::vector<std::string>& getParsedPropertyValues() {
    591     return parsedPropertyValues;
    592 }
    593 
     569//      When the error occurs, this is somehow getting an extra match:
     570//        33: (261,269)
     571//        138: (1235,1253)
     572//        172: (1419,1423)
     573//        278: (1949,2040) *****
     574//        script : .*hir.*        (Alt[Name "hiragana" ,Name "katakanaorhiragana" ,Name "hira" ,Name "hiraganQ0ᅵᅵᅵᅵK" ])
     575        parsedPropertyValues.emplace_back(buffer + line_start, buffer + line_end);
     576    }
     577}
    594578
    595579void icgrep_Linking(Module * m, ExecutionEngine * e) {
Note: See TracChangeset for help on using the changeset viewer.