37 #define COB_LIB_EXPIMP
46 static unsigned int cob_locale_edit;
47 static unsigned char cob_lc_dec;
48 static unsigned char cob_lc_thou;
127 return ((*p & 0x0F) == 0x0D) ? -1 : 1;
132 const size_t size,
const int scale)
134 const unsigned char *p;
140 int hf1 = (int) size + lf1;
149 csize = (size_t)(gcf - lcf);
150 p = data + hf1 - gcf;
152 for (cinc = 0; cinc < csize; ++cinc, ++p, ++q) {
153 if (
unlikely(*p ==
' ' || *p == 0)) {
154 *q = (
unsigned char)
'0';
166 size_t fsiz = 8U - f->
size;
168 #ifndef WORDS_BIGENDIAN
204 size_t fsiz = 8U - f->
size;
206 #ifndef WORDS_BIGENDIAN
223 #ifndef WORDS_BIGENDIAN
228 s = ((
unsigned char *)&n) + 8 - f->
size;
230 s = (
unsigned char *)&n;
241 #ifndef WORDS_BIGENDIAN
246 s = ((
unsigned char *)&n) + 8 - f->
size;
248 s = (
unsigned char *)&n;
270 unsigned char dec_pt;
271 unsigned char num_sep;
281 for (; s1 < e1; ++s1) {
282 if (!isspace (*s1)) {
290 if (*s1 ==
'+' || *s1 ==
'-') {
291 sign = (*s1++ ==
'+') ? 1 : -1;
300 for (p = s1; p < e1 && *p != dec_pt; ++p) {
311 while (count-- > size) {
312 while (!isdigit (*s1++)) {
320 for (; s1 < e1 && s2 < e2; ++s1) {
324 }
else if (c == dec_pt) {
328 }
else if (!(isspace (c) || c == num_sep)) {
357 unsigned char *data1;
358 unsigned char *data2;
382 memset (data2 + size2,
'0', (
size_t) zero_size);
385 diff = (int)(size2 - size1);
388 memset (data2,
' ', (
size_t)diff);
392 memmove (data2, data1 + size1 - size2, size2);
395 diff = (int)(size2 - size1);
397 memmove (data2, data1, size2);
399 memmove (data2, data1, size1);
403 memset (data2 + size1,
'0', (
size_t)zero_size);
408 memset (data2 + size1 + zero_size,
' ',
420 unsigned char *data1;
421 unsigned char *data2;
429 if (size1 >= size2) {
432 memmove (data2, data1 + size1 - size2, size2);
434 memmove (data2, data1, size2);
439 memset (data2,
' ', size2 - size1);
440 memmove (data2 + size2 - size1, data1, size1);
442 memmove (data2, data1, size1);
443 memset (data2 + size1,
' ', size2 - size1);
453 unsigned char *data1;
454 unsigned char *data2;
476 offset = digits2 % 2;
478 offset = 1 - (digits2 % 2);
480 p = data1 + (digits1 - scale1) - (digits2 - scale2);
481 for (i = offset; i < digits2 + offset; ++i, ++p) {
482 n = (data1 <= p && p < data1 + digits1 && *p !=
' ') ?
485 data2[i / 2] = n << 4;
497 *p = (*p & 0xF0) | 0x0F;
498 }
else if (sign < 0) {
499 *p = (*p & 0xF0) | 0x0D;
501 *p = (*p & 0xF0) | 0x0C;
512 unsigned char buff[256];
525 buff[i - offset] =
COB_I2D (data[i / 2] >> 4);
527 buff[i - offset] =
COB_I2D (data[i / 2] & 0x0F);
547 memmove ((
void *)&ffp, src->
data,
sizeof(
float));
550 memmove ((
void *)&dfp, src->
data,
sizeof(
double));
554 memmove (dst->
data, (
void *)&ffp,
sizeof(
float));
556 memmove (dst->
data, (
void *)&dfp,
sizeof(
double));
595 unsigned char *data1;
608 for (i = 0; i < size; ++i) {
662 buff[--i] = (char)
COB_I2D (val % 10);
684 unsigned char *decimal_point;
701 unsigned char sign_symbol;
702 unsigned char curr_symbol;
703 unsigned char dec_symbol;
704 unsigned char currency;
706 decimal_point =
NULL;
729 neg = (sign < 0) ? 1 : 0;
733 memmove ((
unsigned char *)&repeat, p + 1,
sizeof(
int));
734 if (c ==
'9' || c ==
'Z' || c ==
'*') {
738 }
else if (count_curr && c == currency) {
740 }
else if (count_sign && (c ==
'+' || c ==
'-')) {
742 }
else if (c ==
'P') {
751 }
else if (c ==
'V' || c == dec_symbol) {
763 memmove ((
void *)&n, p,
sizeof(
int));
765 for (; n > 0; n--, ++dst) {
773 *dst = suppress_zero ? pad :
'B';
784 *dst = (min <= src && src < max) ? *src++ : (src++,
'0');
786 is_zero = suppress_zero = 0;
800 if (c == dec_symbol) {
816 if (neg && !is_zero) {
818 memcpy (dst,
"CR", (
size_t)2);
820 memcpy (dst,
"DB", (
size_t)2);
823 memset (dst,
' ', (
size_t)2);
830 x = (min <= src && src < max) ? *src++ : (src++,
'0');
832 is_zero = suppress_zero = 0;
834 pad = (c ==
'*') ?
'*' :
' ';
835 *dst = suppress_zero ? pad : x;
842 x = (min <= src && src < max) ? *src++ : (src++,
'0');
844 is_zero = suppress_zero = 0;
848 if (neg && !is_zero) {
850 }
else if (c ==
'+') {
856 }
else if (dst == f2->
data || suppress_zero) {
869 x = (min <= src && src < max) ? *src++ : (src++,
'0');
871 is_zero = suppress_zero = 0;
876 }
else if (dst == f2->
data || suppress_zero) {
878 curr_symbol = currency;
892 if (neg && !is_zero) {
894 }
else if (sign_symbol !=
'+') {
904 for (dst = f2->
data; dst < f2->data + f2->
size; ++dst) {
905 if (*dst != dec_symbol) {
913 for (dst = decimal_point + 1; dst < end; ++dst) {
938 if (sign_symbol || curr_symbol) {
939 for (dst = end - 1; dst > f2->
data; --dst) {
944 if (sign_symbol && curr_symbol) {
948 if (dst >= f2->
data) {
954 if (dst >= f2->
data) {
958 }
else if (sign_symbol) {
967 for (dst = f2->
data; dst < end; ++dst) {
997 unsigned char dec_pt;
1003 for (i = 0; i < f1->
size; ++i) {
1037 memmove ((
void *)&n, p1 + 1,
sizeof(
int));
1038 if (c ==
'9' || c ==
'0' || c ==
'Z' || c ==
'*') {
1044 }
else if (c ==
'P') {
1051 }
else if (c ==
'V') {
1081 memcpy ((
void *)&n, p,
sizeof(
int));
1083 for (; n > 0; --n) {
1088 *dst++ = (src < max) ? *src++ :
' ';
1110 const size_t size,
const int scale)
1138 digcount = src->
size;
1139 for (i = 0; i < dst->
size; ++i) {
1140 dst->
data[i] = src->
data[i % digcount];
1151 digcount = dst->
size;
1154 temp.
size = digcount;
1158 memset (p, src->
data[0], digcount);
1160 for (i = 0; i < digcount; ++i) {
1174 unsigned char data[4];
1179 if (dst->
size == 0) {
1345 memmove (dst->
data, src->
data,
sizeof(
double));
1371 memmove (dst->
data, src->
data,
sizeof(
float));
1400 memmove (dst->
data, src->
data, (
size_t)8);
1422 memmove (dst->
data, src->
data, (
size_t)16);
1474 unsigned char *data;
1491 val += data[i / 2] >> 4;
1493 val += data[i / 2] & 0x0F;
1505 unsigned char *data;
1522 val += data[i / 2] >> 4;
1524 val += data[i / 2] & 0x0F;
1536 unsigned char *data;
1546 for (i = 0; i < size; ++i) {
1554 for (; i < size; ++i) {
1555 val = val * 10 +
COB_D2I (data[i]);
1560 for (; i < size; ++i) {
1561 val = val * 10 +
COB_D2I (data[i]);
1575 unsigned char *data;
1585 for (i = 0; i < size; ++i) {
1593 for (; i < size; ++i) {
1594 val = val * 10 +
COB_D2I (data[i]);
1599 for (; i < size; ++i) {
1600 val = val * 10 +
COB_D2I (data[i]);
1620 temp.
data = (
unsigned char *)&n;
1648 temp.
data = (
unsigned char *)&n;
1675 temp.
data = (
unsigned char *)&n;
void cob_free(void *mptr)
#define COB_FIELD_SCALE(f)
static void cob_move_edited_to_display(cob_field *f1, cob_field *f2)
#define COB_FIELD_DATA(f)
#define COB_FIELD_BINARY_SWAP(f)
#define COB_TYPE_NUMERIC_PACKED
static void cob_move_alphanum_to_display(cob_field *f1, cob_field *f2)
#define COB_FIELD_IS_NUMERIC(f)
static void cob_move_display_to_packed(cob_field *f1, cob_field *f2)
#define COB_TYPE_ALPHANUMERIC
static void cob_move_alphanum_to_edited(cob_field *f1, cob_field *f2)
static void cob_move_binary_to_display(cob_field *f1, cob_field *f2)
#define COB_TYPE_NUMERIC_FP_BIN32
void cob_move(cob_field *src, cob_field *dst)
static int cob_display_get_int(cob_field *f)
#define COB_FIELD_TYPE(f)
static void cob_move_display_to_binary(cob_field *f1, cob_field *f2)
static const int cob_exp10[10]
static void cob_move_packed_to_display(cob_field *f1, cob_field *f2)
#define COB_FLAG_REAL_BINARY
static COB_INLINE COB_A_INLINE void cob_binary_mset_uint64(cob_field *f, cob_u64_t n)
static COB_INLINE int cob_max_int(const int x, const int y)
static void cob_move_alphanum_to_alphanum(cob_field *f1, cob_field *f2)
#define COB_ATTR_INIT(u, v, x, y, z)
static void store_common_region(cob_field *f, const unsigned char *data, const size_t size, const int scale)
static void indirect_move(void(*func)(cob_field *src, cob_field *dst), cob_field *src, cob_field *dst, const size_t size, const int scale)
static void cob_move_display_to_display(cob_field *f1, cob_field *f2)
static const cob_s64_t cob_exp10_ll[19]
#define COB_FLAG_HAVE_SIGN
#define COB_TYPE_NUMERIC_FP_BIN64
#define COB_FIELD_IS_ALNUM(f)
#define COB_FIELD_JUSTIFIED(f)
static cob_global * cobglobptr
int cob_get_int(cob_field *f)
static void cob_move_display_to_alphanum(cob_field *f1, cob_field *f2)
static cob_s64_t cob_display_get_long_long(cob_field *f)
#define COB_TYPE_NUMERIC_FP_DEC64
#define COB_FIELD_NO_SIGN_NIBBLE(f)
void cob_set_int(cob_field *f, const int n)
#define COB_TYPE_NUMERIC_FLOAT
static cob_settings * cobsetptr
#define COB_FIELD_REAL_BINARY(f)
static COB_INLINE COB_A_INLINE void cob_binary_mset_sint64(cob_field *f, cob_s64_t n)
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
static void cob_move_all(cob_field *src, cob_field *dst)
static COB_INLINE COB_A_INLINE cob_s64_t cob_binary_mget_sint64(const cob_field *const f)
#define COB_FIELD_BLANK_ZERO(f)
static int cob_packed_get_sign(const cob_field *f)
#define COB_FIELD_BINARY_TRUNC(f)
#define COB_TYPE_NUMERIC_BINARY
#define COB_TYPE_ALPHANUMERIC_EDITED
#define COB_TYPE_NUMERIC_DISPLAY
#define COB_TYPE_NUMERIC_FP_BIN128
#define COB_PUT_SIGN(f, s)
static const cob_field_attr const_binll_attr
#define COB_TYPE_ALPHANUMERIC_ALL
static void cob_move_display_to_edited(cob_field *f1, cob_field *f2)
static void cob_move_fp_to_fp(cob_field *src, cob_field *dst)
void cob_decimal_setget_fld(cob_field *, cob_field *, const int)
static COB_INLINE COB_A_INLINE cob_u64_t cob_binary_mget_uint64(const cob_field *const f)
#define COB_TYPE_NUMERIC_DOUBLE
const cob_field_attr * attr
static int cob_packed_get_int(cob_field *f1)
static cob_s64_t cob_packed_get_long_long(cob_field *f1)
void * cob_malloc(const size_t size)
static COB_INLINE COB_A_INLINE void own_byte_memcpy(unsigned char *s1, const unsigned char *s2, size_t size)
#define COB_STORE_TRUNC_ON_OVERFLOW
#define COB_FIELD_HAVE_SIGN(f)
cob_s64_t cob_get_llint(cob_field *f)
#define COB_TYPE_NUMERIC_FP_DEC128
void cob_decimal_move_temp(cob_field *, cob_field *)
#define COB_FIELD_DIGITS(f)
static COB_INLINE int cob_min_int(const int x, const int y)
#define COB_BSWAP_64(val)
#define COB_TYPE_NUMERIC_EDITED
#define COB_TYPE_NUMERIC_L_DOUBLE
static void cob_move_binary_to_binary(cob_field *f1, cob_field *f2)
#define COB_FIELD_SIZE(f)
void cob_init_move(cob_global *lptr, cob_settings *sptr)
static const cob_field_attr const_alpha_attr