| 6482 | |
| 6483 | |
| 6484 | dsc* evlRight(thread_db* tdbb, const SysFunction*, const NestValueArray& args, |
| 6485 | impure_value* impure) |
| 6486 | { |
| 6487 | fb_assert(args.getCount() == 2); |
| 6488 | |
| 6489 | Request* request = tdbb->getRequest(); |
| 6490 | |
| 6491 | const dsc* value = EVL_expr(tdbb, request, args[0]); |
| 6492 | if (request->req_flags & req_null) // return NULL if value is NULL |
| 6493 | return NULL; |
| 6494 | |
| 6495 | const dsc* len = EVL_expr(tdbb, request, args[1]); |
| 6496 | if (request->req_flags & req_null) // return NULL if len is NULL |
| 6497 | return NULL; |
| 6498 | |
| 6499 | CharSet* charSet = INTL_charset_lookup(tdbb, value->getCharSet()); |
| 6500 | SLONG start; |
| 6501 | |
| 6502 | if (value->isBlob()) |
| 6503 | { |
| 6504 | blb* blob = blb::open(tdbb, tdbb->getRequest()->req_transaction, |
| 6505 | reinterpret_cast<bid*>(value->dsc_address)); |
| 6506 | |
| 6507 | if (charSet->isMultiByte()) |
| 6508 | { |
| 6509 | HalfStaticArray<UCHAR, BUFFER_LARGE> buffer; |
| 6510 | SLONG length = blob->BLB_get_data(tdbb, buffer.getBuffer(blob->blb_length), |
| 6511 | blob->blb_length, false); |
| 6512 | start = charSet->length(length, buffer.begin(), true); |
| 6513 | } |
| 6514 | else |
| 6515 | start = blob->blb_length / charSet->maxBytesPerChar(); |
| 6516 | |
| 6517 | blob->BLB_close(tdbb); |
| 6518 | } |
| 6519 | else |
| 6520 | { |
| 6521 | MoveBuffer temp; |
| 6522 | UCHAR* p; |
| 6523 | start = MOV_make_string2(tdbb, value, value->getTextType(), &p, temp); |
| 6524 | start = charSet->length(start, p, true); |
| 6525 | } |
| 6526 | |
| 6527 | start -= MOV_get_long(tdbb, len, 0); |
| 6528 | start = MAX(0, start); |
| 6529 | |
| 6530 | dsc startDsc; |
| 6531 | startDsc.makeLong(0, &start); |
| 6532 | |
| 6533 | return SubstringNode::perform(tdbb, impure, value, &startDsc, len); |
| 6534 | } |
| 6535 | |
| 6536 | |
| 6537 | dsc* evlRound(thread_db* tdbb, const SysFunction* function, const NestValueArray& args, |
nothing calls this directly
no test coverage detected