| 1162 | }; |
| 1163 | |
| 1164 | static SSHORT cvt_get_short(const dsc* desc, SSHORT scale, DecimalStatus decSt, ErrorFunction err) |
| 1165 | { |
| 1166 | /************************************** |
| 1167 | * |
| 1168 | * C V T _ g e t _ s h o r t |
| 1169 | * |
| 1170 | ************************************** |
| 1171 | * |
| 1172 | * Functional description |
| 1173 | * Convert something arbitrary to a short (16 bit) integer of given |
| 1174 | * scale. |
| 1175 | * |
| 1176 | **************************************/ |
| 1177 | SSHORT value; |
| 1178 | |
| 1179 | if (desc->isText()) |
| 1180 | { |
| 1181 | VaryStr<20> buffer; // long enough to represent largest short in ASCII |
| 1182 | const char* p; |
| 1183 | USHORT length = CVT_make_string(desc, ttype_ascii, &p, &buffer, sizeof(buffer), decSt, err); |
| 1184 | |
| 1185 | { |
| 1186 | RetValue<SSHORTTraits> rv(&value); |
| 1187 | scale -= cvt_decompose(p, length, &rv, err); |
| 1188 | } |
| 1189 | adjustForScale(value, scale, SHORT_LIMIT, err); |
| 1190 | } |
| 1191 | else { |
| 1192 | ULONG lval = CVT_get_long(desc, scale, decSt, err); |
| 1193 | value = (SSHORT) lval; |
| 1194 | if (value != SLONG(lval)) |
| 1195 | err(Arg::Gds(isc_arith_except) << Arg::Gds(isc_numeric_out_of_range)); |
| 1196 | } |
| 1197 | |
| 1198 | return value; |
| 1199 | } |
| 1200 | |
| 1201 | |
| 1202 | class SLONGTraits |
no test coverage detected