Ignore:
Timestamp:
Jan 3, 2017, 3:59:33 PM (22 months ago)
Author:
nmedfort
Message:

Work on bracket matching problem

File:
1 edited

Legend:

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

    r5242 r5245  
    239239    mGrepType = grepType;
    240240
    241     Type * const int32ty = iBuilder->getInt32Ty();
    242241    Type * const size_ty = iBuilder->getSizeTy();
    243242    Type * const int8PtrTy = iBuilder->getInt8PtrTy();
    244     Type * const voidTy = iBuilder->getVoidTy();
    245     Type * const voidPtrTy = iBuilder->getVoidPtrTy();
    246243    Type * const inputType = PointerType::get(ArrayType::get(ArrayType::get(iBuilder->getBitBlockType(), (UTF_16 ? 16 : 8)), 1), addrSpace);
    247244    Type * const resultTy = CountOnly ? size_ty : iBuilder->getVoidTy();
     
    414411
    415412const std::vector<std::string> & GrepEngine::grepPropertyValues(const std::string& propertyName) {
    416     AlignedAllocator<char, 32> alloc;
     413    enum { MaxSupportedVectorWidthInBytes = 32 };
     414    AlignedAllocator<char, MaxSupportedVectorWidthInBytes> alloc;
    417415    parsedPropertyValues.clear();
    418416    const std::string & str = UCD::getPropertyValueGrepString(propertyName);
    419417    const auto n = str.length();
    420     char * aligned = alloc.allocate(n + 32, 0);
     418    // NOTE: MaxSupportedVectorWidthInBytes of trailing 0s are needed to prevent the grep function from
     419    // erroneously matching garbage data when loading the final partial block.
     420    char * aligned = alloc.allocate(n + MaxSupportedVectorWidthInBytes, 0);
    421421    std::memcpy(aligned, str.data(), n);
    422     std::memset(aligned + n, 0, 32);
     422    std::memset(aligned + n, 0, MaxSupportedVectorWidthInBytes);
    423423    mGrepFunction(aligned, n, 0);
    424424    alloc.deallocate(aligned, 0);
     
    484484            resultStrs[idx].write(&buffer[line_start * index], (line_end - line_start) * index);
    485485            resultStrs[idx] << '\n';
    486         }
    487         else {   
     486        } else {
    488487            if ((!isUTF_16 && end_byte == 0x0D) || (isUTF_16 && (end_byte == 0x0D && penult_byte == 0x0))) {
    489488                // Check for line_end on first byte of CRLF;  note that we don't
     
    546545extern "C" {
    547546    void insert_property_values(size_t lineNum, size_t line_start, size_t line_end, const char * buffer) {
    548 //      When the error occurs, this is somehow getting an extra match:
    549 //        33: (261,269)
    550 //        138: (1235,1253)
    551 //        172: (1419,1423)
    552 //        278: (1949,2040) *****
    553 //        script : .*hir.*        (Alt[Name "hiragana" ,Name "katakanaorhiragana" ,Name "hira" ,Name "hiraganQ0ᅵᅵᅵᅵK" ])
    554547        parsedPropertyValues.emplace_back(buffer + line_start, buffer + line_end);
    555548    }
Note: See TracChangeset for help on using the changeset viewer.