| 3671 | } |
| 3672 | |
| 3673 | ULONG CommonCallbacks::validateLength(Jrd::CharSet* charSet, CHARSET_ID charSetId, ULONG length, const UCHAR* start, |
| 3674 | const USHORT size) |
| 3675 | { |
| 3676 | if (length > size) |
| 3677 | { |
| 3678 | fb_assert(!charSet || (!charSet->isMultiByte() && charSet->getSpaceLength() == 1)); |
| 3679 | UCHAR fillChar = charSet ? |
| 3680 | *charSet->getSpace() : |
| 3681 | (charSetId == ttype_binary ? 0x00 : ASCII_SPACE); |
| 3682 | |
| 3683 | const UCHAR* p = start + size; |
| 3684 | |
| 3685 | // Scan the truncated string to ensure only spaces lost |
| 3686 | |
| 3687 | while (p < start + length) |
| 3688 | { |
| 3689 | if (*p++ != fillChar) |
| 3690 | { |
| 3691 | err(Arg::Gds(isc_arith_except) << Arg::Gds(isc_string_truncation) << |
| 3692 | Arg::Gds(isc_trunc_limits) << |
| 3693 | Arg::Num(size) << Arg::Num(length)); |
| 3694 | } |
| 3695 | } |
| 3696 | } |
| 3697 | |
| 3698 | return MIN(length, size); |
| 3699 | } |
| 3700 | |
| 3701 | CHARSET_ID CommonCallbacks::getChid(const dsc* d) |
| 3702 | { |
no test coverage detected