| 141 | |
| 142 | |
| 143 | ULONG FixedWidthCharSet::substring(const ULONG srcLen, const UCHAR* src, const ULONG dstLen, UCHAR* dst, |
| 144 | const ULONG startPos, const ULONG len) const |
| 145 | { |
| 146 | ULONG result; |
| 147 | |
| 148 | if (getStruct()->charset_fn_substring) |
| 149 | result = getStruct()->charset_fn_substring(getStruct(), srcLen, src, dstLen, dst, startPos, len); |
| 150 | else |
| 151 | { |
| 152 | fb_assert(src != NULL && dst != NULL); |
| 153 | |
| 154 | result = MIN(srcLen / minBytesPerChar() - startPos, len) * minBytesPerChar(); |
| 155 | |
| 156 | if (dstLen < result) |
| 157 | result = INTL_BAD_STR_LENGTH; |
| 158 | else if (startPos * minBytesPerChar() > srcLen) |
| 159 | result = 0; |
| 160 | else |
| 161 | memcpy(dst, src + startPos * minBytesPerChar(), result); |
| 162 | } |
| 163 | |
| 164 | if (result == INTL_BAD_STR_LENGTH) |
| 165 | status_exception::raise(Arg::Gds(isc_arith_except) << Arg::Gds(isc_string_truncation) << |
| 166 | Arg::Gds(isc_trunc_limits) << Arg::Num(dstLen) << Arg::Num(len)); |
| 167 | |
| 168 | return result; |
| 169 | } |
| 170 | |
| 171 | |
| 172 | //------------- |
no test coverage detected