GnuCOBOL  2.0
A free COBOL compiler
move.c
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2012, 2014-2015 Free Software Foundation, Inc.
3  Written by Keisuke Nishida, Roger While, Simon Sobisch, Ron Norman
4 
5  This file is part of GnuCOBOL.
6 
7  The GnuCOBOL runtime library is free software: you can redistribute it
8  and/or modify it under the terms of the GNU Lesser General Public License
9  as published by the Free Software Foundation, either version 3 of the
10  License, or (at your option) any later version.
11 
12  GnuCOBOL is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public License
18  along with GnuCOBOL. If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 
22 #include "config.h"
23 
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <stddef.h>
27 #include <string.h>
28 #include <ctype.h>
29 #include <errno.h>
30 #include <math.h>
31 
32 #ifdef HAVE_LOCALE_H
33 #include <locale.h>
34 #endif
35 
36 /* Force symbol exports */
37 #define COB_LIB_EXPIMP
38 
39 #include "libcob.h"
40 #include "coblocal.h"
41 
44 
45 #if 0 /* RXWRXW local edit symbols */
46 static unsigned int cob_locale_edit;
47 static unsigned char cob_lc_dec;
48 static unsigned char cob_lc_thou;
49 #endif
50 
52  {COB_TYPE_ALPHANUMERIC, 0, 0, 0, NULL};
56 
57 static const int cob_exp10[10] = {
58  1,
59  10,
60  100,
61  1000,
62  10000,
63  100000,
64  1000000,
65  10000000,
66  100000000,
67  1000000000
68 };
69 
70 static const cob_s64_t cob_exp10_ll[19] = {
71  COB_S64_C(1),
72  COB_S64_C(10),
73  COB_S64_C(100),
74  COB_S64_C(1000),
75  COB_S64_C(10000),
76  COB_S64_C(100000),
77  COB_S64_C(1000000),
78  COB_S64_C(10000000),
79  COB_S64_C(100000000),
80  COB_S64_C(1000000000),
81  COB_S64_C(10000000000),
82  COB_S64_C(100000000000),
83  COB_S64_C(1000000000000),
84  COB_S64_C(10000000000000),
85  COB_S64_C(100000000000000),
86  COB_S64_C(1000000000000000),
87  COB_S64_C(10000000000000000),
88  COB_S64_C(100000000000000000),
89  COB_S64_C(1000000000000000000)
90 };
91 
92 static COB_INLINE int
93 cob_min_int (const int x, const int y)
94 {
95  if (x < y) {
96  return x;
97  }
98  return y;
99 }
100 
101 static COB_INLINE int
102 cob_max_int (const int x, const int y)
103 {
104  if (x > y) {
105  return x;
106  }
107  return y;
108 }
109 
110 static COB_INLINE COB_A_INLINE void
111 own_byte_memcpy (unsigned char *s1, const unsigned char *s2, size_t size)
112 {
113  do {
114  *s1++ = *s2++;
115  } while (--size);
116 }
117 
118 static int
120 {
121  unsigned char *p;
122 
123  if (!COB_FIELD_HAVE_SIGN (f)) {
124  return 0;
125  }
126  p = f->data + f->size - 1;
127  return ((*p & 0x0F) == 0x0D) ? -1 : 1;
128 }
129 
130 static void
131 store_common_region (cob_field *f, const unsigned char *data,
132  const size_t size, const int scale)
133 {
134  const unsigned char *p;
135  unsigned char *q;
136  size_t csize;
137  size_t cinc;
138  int lf1 = -scale;
139  int lf2 = -COB_FIELD_SCALE (f);
140  int hf1 = (int) size + lf1;
141  int hf2 = (int) COB_FIELD_SIZE (f) + lf2;
142  int lcf;
143  int gcf;
144 
145  lcf = cob_max_int (lf1, lf2);
146  gcf = cob_min_int (hf1, hf2);
147  memset (COB_FIELD_DATA (f), '0', COB_FIELD_SIZE (f));
148  if (gcf > lcf) {
149  csize = (size_t)(gcf - lcf);
150  p = data + hf1 - gcf;
151  q = COB_FIELD_DATA (f) + hf2 - gcf;
152  for (cinc = 0; cinc < csize; ++cinc, ++p, ++q) {
153  if (unlikely(*p == ' ' || *p == 0)) {
154  *q = (unsigned char)'0';
155  } else {
156  *q = *p;
157  }
158  }
159  }
160 }
161 
164 {
165  cob_s64_t n = 0;
166  size_t fsiz = 8U - f->size;
167 
168 #ifndef WORDS_BIGENDIAN
169  if (COB_FIELD_BINARY_SWAP (f)) {
170  if (COB_FIELD_HAVE_SIGN (f)) {
171  own_byte_memcpy ((unsigned char *)&n, f->data, f->size);
172  n = COB_BSWAP_64 (n);
173  /* Shift with sign */
174  n >>= 8 * fsiz;
175  } else {
176  own_byte_memcpy (((unsigned char *)&n) + fsiz, f->data, f->size);
177  n = COB_BSWAP_64 (n);
178  }
179  } else {
180  if (COB_FIELD_HAVE_SIGN (f)) {
181  own_byte_memcpy (((unsigned char *)&n) + fsiz, f->data, f->size);
182  /* Shift with sign */
183  n >>= 8 * fsiz;
184  } else {
185  own_byte_memcpy ((unsigned char *)&n, f->data, f->size);
186  }
187  }
188 #else /* WORDS_BIGENDIAN */
189  if (COB_FIELD_HAVE_SIGN (f)) {
190  own_byte_memcpy ((unsigned char *)&n, f->data, f->size);
191  /* Shift with sign */
192  n >>= 8 * fsiz;
193  } else {
194  own_byte_memcpy (((unsigned char *)&n) + fsiz, f->data, f->size);
195  }
196 #endif /* WORDS_BIGENDIAN */
197  return n;
198 }
199 
202 {
203  cob_u64_t n = 0;
204  size_t fsiz = 8U - f->size;
205 
206 #ifndef WORDS_BIGENDIAN
207  if (COB_FIELD_BINARY_SWAP (f)) {
208  own_byte_memcpy (((unsigned char *)&n) + fsiz, f->data, f->size);
209  n = COB_BSWAP_64 (n);
210  } else {
211  own_byte_memcpy ((unsigned char *)&n, f->data, f->size);
212  }
213 #else /* WORDS_BIGENDIAN */
214  own_byte_memcpy (((unsigned char *)&n) + fsiz, f->data, f->size);
215 #endif /* WORDS_BIGENDIAN */
216 
217  return n;
218 }
219 
220 static COB_INLINE COB_A_INLINE void
222 {
223 #ifndef WORDS_BIGENDIAN
224  unsigned char *s;
225 
226  if (COB_FIELD_BINARY_SWAP (f)) {
227  n = COB_BSWAP_64 (n);
228  s = ((unsigned char *)&n) + 8 - f->size;
229  } else {
230  s = (unsigned char *)&n;
231  }
232  own_byte_memcpy (f->data, s, f->size);
233 #else /* WORDS_BIGENDIAN */
234  own_byte_memcpy (f->data, ((unsigned char *)&n) + 8 - f->size, f->size);
235 #endif /* WORDS_BIGENDIAN */
236 }
237 
238 static COB_INLINE COB_A_INLINE void
240 {
241 #ifndef WORDS_BIGENDIAN
242  unsigned char *s;
243 
244  if (COB_FIELD_BINARY_SWAP (f)) {
245  n = COB_BSWAP_64 (n);
246  s = ((unsigned char *)&n) + 8 - f->size;
247  } else {
248  s = (unsigned char *)&n;
249  }
250  own_byte_memcpy (f->data, s, f->size);
251 #else /* WORDS_BIGENDIAN */
252  own_byte_memcpy (f->data, ((unsigned char *)&n) + 8 - f->size, f->size);
253 #endif /* WORDS_BIGENDIAN */
254 }
255 
256 /* Display */
257 
258 static void
260 {
261  unsigned char *p;
262  unsigned char *s1;
263  unsigned char *s2;
264  unsigned char *e1;
265  unsigned char *e2;
266  int sign;
267  int count;
268  int size;
269  unsigned char c;
270  unsigned char dec_pt;
271  unsigned char num_sep;
272 
273  /* Initialize */
274  s1 = f1->data;
275  e1 = s1 + f1->size;
276  s2 = COB_FIELD_DATA (f2);
277  e2 = s2 + COB_FIELD_SIZE (f2);
278  memset (f2->data, '0', f2->size);
279 
280  /* Skip white spaces */
281  for (; s1 < e1; ++s1) {
282  if (!isspace (*s1)) {
283  break;
284  }
285  }
286 
287  /* Check for sign */
288  sign = 0;
289  if (s1 != e1) {
290  if (*s1 == '+' || *s1 == '-') {
291  sign = (*s1++ == '+') ? 1 : -1;
292  }
293  }
294 
295  dec_pt = COB_MODULE_PTR->decimal_point;
296  num_sep = COB_MODULE_PTR->numeric_separator;
297 
298  /* Count the number of digits before decimal point */
299  count = 0;
300  for (p = s1; p < e1 && *p != dec_pt; ++p) {
301  if (isdigit (*p)) {
302  ++count;
303  }
304  }
305 
306  /* Find the start position */
307  size = (int) COB_FIELD_SIZE (f2) - COB_FIELD_SCALE(f2);
308  if (count < size) {
309  s2 += size - count;
310  } else {
311  while (count-- > size) {
312  while (!isdigit (*s1++)) {
313  ;
314  }
315  }
316  }
317 
318  /* Move */
319  count = 0;
320  for (; s1 < e1 && s2 < e2; ++s1) {
321  c = *s1;
322  if (isdigit (c)) {
323  *s2++ = c;
324  } else if (c == dec_pt) {
325  if (count++ > 0) {
326  goto error;
327  }
328  } else if (!(isspace (c) || c == num_sep)) {
329  goto error;
330  }
331  }
332 
333  COB_PUT_SIGN (f2, sign);
334  return;
335 
336 error:
337  memset (f2->data, '0', f2->size);
338  COB_PUT_SIGN (f2, 0);
339 }
340 
341 static void
343 {
344  int sign;
345 
346  sign = COB_GET_SIGN (f1);
348  COB_FIELD_SCALE (f1));
349 
350  COB_PUT_SIGN (f1, sign);
351  COB_PUT_SIGN (f2, sign);
352 }
353 
354 static void
356 {
357  unsigned char *data1;
358  unsigned char *data2;
359  size_t size1;
360  size_t size2;
361  int sign;
362  int diff;
363  int zero_size;
364 
365  data1 = COB_FIELD_DATA (f1);
366  size1 = COB_FIELD_SIZE (f1);
367  sign = COB_GET_SIGN (f1);
368  if (unlikely(COB_FIELD_SCALE(f1) < 0)) {
369  /* Scaling */
370  zero_size = (int)-COB_FIELD_SCALE(f1);
371  } else {
372  zero_size = 0;
373  }
374  data2 = f2->data;
375  size2 = f2->size;
376  if (unlikely(COB_FIELD_JUSTIFIED (f2))) {
377  /* Justified right */
378  if (zero_size) {
379  /* Implied 0 ('P's) */
380  zero_size = cob_min_int (zero_size, (int)size2);
381  size2 -= zero_size;
382  memset (data2 + size2, '0', (size_t) zero_size);
383  }
384  if (size2) {
385  diff = (int)(size2 - size1);
386  if (diff > 0) {
387  /* Padding */
388  memset (data2, ' ', (size_t)diff);
389  data2 += diff;
390  size2 -= diff;
391  }
392  memmove (data2, data1 + size1 - size2, size2);
393  }
394  } else {
395  diff = (int)(size2 - size1);
396  if (diff < 0) {
397  memmove (data2, data1, size2);
398  } else {
399  memmove (data2, data1, size1);
400  if (zero_size) {
401  /* Implied 0 ('P's) */
402  zero_size = cob_min_int (zero_size, diff);
403  memset (data2 + size1, '0', (size_t)zero_size);
404  diff -= zero_size;
405  }
406  if (diff) {
407  /* Padding */
408  memset (data2 + size1 + zero_size, ' ',
409  (size_t)diff);
410  }
411  }
412  }
413 
414  COB_PUT_SIGN (f1, sign);
415 }
416 
417 static void
419 {
420  unsigned char *data1;
421  unsigned char *data2;
422  size_t size1;
423  size_t size2;
424 
425  data1 = f1->data;
426  size1 = f1->size;
427  data2 = f2->data;
428  size2 = f2->size;
429  if (size1 >= size2) {
430  /* Move string with truncation */
431  if (COB_FIELD_JUSTIFIED (f2)) {
432  memmove (data2, data1 + size1 - size2, size2);
433  } else {
434  memmove (data2, data1, size2);
435  }
436  } else {
437  /* Move string with padding */
438  if (COB_FIELD_JUSTIFIED (f2)) {
439  memset (data2, ' ', size2 - size1);
440  memmove (data2 + size2 - size1, data1, size1);
441  } else {
442  memmove (data2, data1, size1);
443  memset (data2 + size1, ' ', size2 - size1);
444  }
445  }
446 }
447 
448 /* Packed decimal */
449 
450 static void
452 {
453  unsigned char *data1;
454  unsigned char *data2;
455  unsigned char *p;
456  size_t digits1;
457  size_t digits2;
458  size_t i;
459  size_t offset;
460  int sign;
461  int scale1;
462  int scale2;
463  unsigned char n;
464 
465  sign = COB_GET_SIGN (f1);
466  data1 = COB_FIELD_DATA (f1);
467  digits1 = COB_FIELD_DIGITS (f1);
468  scale1 = COB_FIELD_SCALE (f1);
469  data2 = f2->data;
470  digits2 = COB_FIELD_DIGITS (f2);
471  scale2 = COB_FIELD_SCALE (f2);
472 
473  /* Pack string */
474  memset (f2->data, 0, f2->size);
475  if (COB_FIELD_NO_SIGN_NIBBLE (f2)) {
476  offset = digits2 % 2;
477  } else {
478  offset = 1 - (digits2 % 2);
479  }
480  p = data1 + (digits1 - scale1) - (digits2 - scale2);
481  for (i = offset; i < digits2 + offset; ++i, ++p) {
482  n = (data1 <= p && p < data1 + digits1 && *p != ' ') ?
483  COB_D2I (*p) : 0;
484  if (i % 2 == 0) {
485  data2[i / 2] = n << 4;
486  } else {
487  data2[i / 2] |= n;
488  }
489  }
490 
491  COB_PUT_SIGN (f1, sign);
492  if (COB_FIELD_NO_SIGN_NIBBLE (f2)) {
493  return;
494  }
495  p = f2->data + f2->size - 1;
496  if (!COB_FIELD_HAVE_SIGN (f2)) {
497  *p = (*p & 0xF0) | 0x0F;
498  } else if (sign < 0) {
499  *p = (*p & 0xF0) | 0x0D;
500  } else {
501  *p = (*p & 0xF0) | 0x0C;
502  }
503 }
504 
505 static void
507 {
508  unsigned char *data;
509  size_t i;
510  size_t offset;
511  int sign;
512  unsigned char buff[256];
513 
514  /* Unpack string */
515  data = f1->data;
516  if (COB_FIELD_NO_SIGN_NIBBLE (f1)) {
517  sign = 0;
518  offset = COB_FIELD_DIGITS(f1) % 2;
519  } else {
520  sign = cob_packed_get_sign (f1);
521  offset = 1 - (COB_FIELD_DIGITS(f1) % 2);
522  }
523  for (i = offset; i < COB_FIELD_DIGITS(f1) + offset; ++i) {
524  if (i % 2 == 0) {
525  buff[i - offset] = COB_I2D (data[i / 2] >> 4);
526  } else {
527  buff[i - offset] = COB_I2D (data[i / 2] & 0x0F);
528  }
529  }
530 
531  /* Store */
532  store_common_region (f2, buff, (size_t)COB_FIELD_DIGITS (f1),
533  COB_FIELD_SCALE (f1));
534 
535  COB_PUT_SIGN (f2, sign);
536 }
537 
538 /* Floating point */
539 
540 static void
542 {
543  double dfp;
544  float ffp;
545 
546  if (COB_FIELD_TYPE (src) == COB_TYPE_NUMERIC_FLOAT) {
547  memmove ((void *)&ffp, src->data, sizeof(float));
548  dfp = (double)ffp;
549  } else {
550  memmove ((void *)&dfp, src->data, sizeof(double));
551  ffp = (float)dfp;
552  }
553  if (COB_FIELD_TYPE (dst) == COB_TYPE_NUMERIC_FLOAT) {
554  memmove (dst->data, (void *)&ffp, sizeof(float));
555  } else {
556  memmove (dst->data, (void *)&dfp, sizeof(double));
557  }
558 }
559 
560 /* Binary integer */
561 
562 
563 static void
565 {
566  union {
567  cob_u64_t val;
568  cob_s64_t val2;
569  } ul64;
570  unsigned int sign;
571 
572  sign = 0;
573  if (COB_FIELD_HAVE_SIGN (f1)) {
574  ul64.val2 = cob_binary_mget_sint64 (f1);
575  if (ul64.val2 < 0) {
576  sign = 1;
577  }
578  } else {
579  ul64.val = cob_binary_mget_uint64 (f1);
580  }
581  if (COB_FIELD_HAVE_SIGN (f2)) {
582  cob_binary_mset_sint64 (f2, ul64.val2);
583  } else {
584  if (sign) {
585  cob_binary_mset_uint64 (f2, (cob_u64_t)(-ul64.val2));
586  } else {
587  cob_binary_mset_uint64 (f2, ul64.val);
588  }
589  }
590 }
591 
592 static void
594 {
595  unsigned char *data1;
596  cob_u64_t val;
597  cob_s64_t val2;
598  size_t i, size;
599  size_t size1;
600  int sign;
601 
602  size1 = COB_FIELD_SIZE (f1);
603  data1 = COB_FIELD_DATA (f1);
604  sign = COB_GET_SIGN (f1);
605  /* Get value */
606  val = 0;
607  size = size1 - COB_FIELD_SCALE(f1) + COB_FIELD_SCALE(f2);
608  for (i = 0; i < size; ++i) {
609  if (val) {
610  val *= 10;
611  }
612  if (i < size1) {
613  val += COB_D2I (data1[i]);
614  }
615  }
616 
617  if (COB_FIELD_BINARY_TRUNC (f2) &&
618  !COB_FIELD_REAL_BINARY(f2)) {
619  val %= cob_exp10_ll[(int)COB_FIELD_DIGITS(f2)];
620  }
621 
622  if (COB_FIELD_HAVE_SIGN (f2)) {
623  if (sign < 0) {
624  val2 = -(cob_s64_t)val;
625  } else {
626  val2 = val;
627  }
628  cob_binary_mset_sint64 (f2, val2);
629  } else {
630  cob_binary_mset_uint64 (f2, val);
631  }
632 
633  COB_PUT_SIGN (f1, sign);
634 }
635 
636 static void
638 {
639  cob_u64_t val;
640  cob_s64_t val2;
641  int i;
642  int sign;
643  char buff[32];
644 
645  sign = 1;
646  /* Get value */
647  if (COB_FIELD_HAVE_SIGN (f1)) {
648  val2 = cob_binary_mget_sint64 (f1);
649  if (val2 < 0) {
650  sign = -1;
651  val = (cob_u64_t)-val2;
652  } else {
653  val = (cob_u64_t)val2;
654  }
655  } else {
656  val = cob_binary_mget_uint64 (f1);
657  }
658 
659  /* Convert to string */
660  i = 20;
661  while (val > 0) {
662  buff[--i] = (char) COB_I2D (val % 10);
663  val /= 10;
664  }
665 
666  /* Store */
667  store_common_region (f2, (cob_u8_ptr)buff + i, (size_t)(20 - i),
668  COB_FIELD_SCALE(f1));
669 
670  COB_PUT_SIGN (f2, sign);
671 }
672 
673 /* Edited */
674 
675 static void
677 {
678  const char *p;
679  unsigned char *min;
680  unsigned char *max;
681  unsigned char *src;
682  unsigned char *dst;
683  unsigned char *end;
684  unsigned char *decimal_point;
685  int sign;
686  int neg;
687  int count;
688  int count_sign;
689  int count_curr;
690  int trailing_sign;
691  int trailing_curr;
692  int is_zero;
693  int suppress_zero;
694  int sign_first;
695  int p_is_left;
696  int repeat;
697  int n;
698  unsigned char pad;
699  unsigned char x;
700  unsigned char c;
701  unsigned char sign_symbol;
702  unsigned char curr_symbol;
703  unsigned char dec_symbol;
704  unsigned char currency;
705 
706  decimal_point = NULL;
707  count = 0;
708  count_sign = 1;
709  count_curr = 1;
710  trailing_sign = 0;
711  trailing_curr = 0;
712  is_zero = 1;
713  suppress_zero = 1;
714  sign_first = 0;
715  p_is_left = 0;
716  pad = ' ';
717  sign_symbol = 0;
718  curr_symbol = 0;
719 
720  currency = COB_MODULE_PTR->currency_symbol;
721 
722  if (COB_MODULE_PTR->decimal_point == ',') {
723  dec_symbol = ',';
724  } else {
725  dec_symbol = '.';
726  }
727 
728  sign = COB_GET_SIGN (f1);
729  neg = (sign < 0) ? 1 : 0;
730  /* Count the number of digit places before decimal point */
731  for (p = COB_FIELD_PIC (f2); *p; p += 5) {
732  c = p[0];
733  memmove ((unsigned char *)&repeat, p + 1, sizeof(int));
734  if (c == '9' || c == 'Z' || c == '*') {
735  count += repeat;
736  count_sign = 0;
737  count_curr = 0;
738  } else if (count_curr && c == currency) {
739  count += repeat;
740  } else if (count_sign && (c == '+' || c == '-')) {
741  count += repeat;
742  } else if (c == 'P') {
743  if (count == 0) {
744  p_is_left = 1;
745  break;
746  } else {
747  count += repeat;
748  count_sign = 0;
749  count_curr = 0;
750  }
751  } else if (c == 'V' || c == dec_symbol) {
752  break;
753  }
754  }
755 
756  min = COB_FIELD_DATA (f1);
757  max = min + COB_FIELD_SIZE (f1);
758  src = max - COB_FIELD_SCALE(f1) - count;
759  dst = f2->data;
760  end = f2->data + f2->size;
761  for (p = COB_FIELD_PIC (f2); *p;) {
762  c = *p++; /* PIC char */
763  memmove ((void *)&n, p, sizeof(int)); /* PIC char count */
764  p += sizeof(int);
765  for (; n > 0; n--, ++dst) {
766  switch (c) {
767  case '0':
768  case '/':
769  *dst = c;
770  break;
771 
772  case 'B':
773  *dst = suppress_zero ? pad : 'B';
774  break;
775 
776  case 'P':
777  if (p_is_left) {
778  ++src;
779  --dst;
780  }
781  break;
782 
783  case '9':
784  *dst = (min <= src && src < max) ? *src++ : (src++, '0');
785  if (*dst != '0') {
786  is_zero = suppress_zero = 0;
787  }
788  suppress_zero = 0;
789  trailing_sign = 1;
790  trailing_curr = 1;
791  break;
792 
793  case 'V':
794  --dst;
795  decimal_point = dst;
796  break;
797 
798  case '.':
799  case ',':
800  if (c == dec_symbol) {
801  *dst = dec_symbol;
802  decimal_point = dst;
803  } else {
804  if (suppress_zero) {
805  *dst = pad;
806  } else {
807  *dst = c;
808  }
809  }
810  break;
811 
812  case 'C':
813  case 'D':
814  end = dst;
815  /* Check negative and not zero */
816  if (neg && !is_zero) {
817  if (c == 'C') {
818  memcpy (dst, "CR", (size_t)2);
819  } else {
820  memcpy (dst, "DB", (size_t)2);
821  }
822  } else {
823  memset (dst, ' ', (size_t)2);
824  }
825  dst++;
826  break;
827 
828  case 'Z':
829  case '*':
830  x = (min <= src && src < max) ? *src++ : (src++, '0');
831  if (x != '0') {
832  is_zero = suppress_zero = 0;
833  }
834  pad = (c == '*') ? '*' : ' ';
835  *dst = suppress_zero ? pad : x;
836  trailing_sign = 1;
837  trailing_curr = 1;
838  break;
839 
840  case '+':
841  case '-':
842  x = (min <= src && src < max) ? *src++ : (src++, '0');
843  if (x != '0') {
844  is_zero = suppress_zero = 0;
845  }
846  if (trailing_sign) {
847  /* Check negative and not zero */
848  if (neg && !is_zero) {
849  *dst = '-';
850  } else if (c == '+') {
851  *dst = '+';
852  } else {
853  *dst = ' ';
854  }
855  --end;
856  } else if (dst == f2->data || suppress_zero) {
857  *dst = pad;
858  sign_symbol = c;
859  if (!curr_symbol) {
860  ++sign_first;
861  }
862  } else {
863  *dst = x;
864  }
865  break;
866 
867  default:
868  if (c == currency) {
869  x = (min <= src && src < max) ? *src++ : (src++, '0');
870  if (x != '0') {
871  is_zero = suppress_zero = 0;
872  }
873  if (trailing_curr) {
874  *dst = currency;
875  --end;
876  } else if (dst == f2->data || suppress_zero) {
877  *dst = pad;
878  curr_symbol = currency;
879  } else {
880  *dst = x;
881  }
882  break;
883  }
884 
885  *dst = '?'; /* Invalid PIC */
886  }
887  }
888  }
889 
890  if (sign_symbol) {
891  /* Check negative and not zero */
892  if (neg && !is_zero) {
893  sign_symbol = '-';
894  } else if (sign_symbol != '+') {
895  sign_symbol = ' ';
896  }
897  }
898 
899  if (suppress_zero || (is_zero && COB_FIELD_BLANK_ZERO (f2))) {
900  /* All digits are zeros */
901  if (pad == ' ' || COB_FIELD_BLANK_ZERO (f2)) {
902  memset (f2->data, ' ', f2->size);
903  } else {
904  for (dst = f2->data; dst < f2->data + f2->size; ++dst) {
905  if (*dst != dec_symbol) {
906  *dst = pad;
907  }
908  }
909  }
910  } else {
911  /* Put zero after the decimal point if necessary */
912  if (decimal_point) {
913  for (dst = decimal_point + 1; dst < end; ++dst) {
914  switch (*dst) {
915  case '0':
916  case '1':
917  case '2':
918  case '3':
919  case '4':
920  case '5':
921  case '6':
922  case '7':
923  case '8':
924  case '9':
925  case ',':
926  case '+':
927  case '-':
928  case '/':
929  case 'B':
930  break;
931  default:
932  *dst = '0';
933  }
934  }
935  }
936 
937  /* Put sign or currency symbol at the beginning */
938  if (sign_symbol || curr_symbol) {
939  for (dst = end - 1; dst > f2->data; --dst) {
940  if (*dst == ' ') {
941  break;
942  }
943  }
944  if (sign_symbol && curr_symbol) {
945  if (sign_first) {
946  *dst = curr_symbol;
947  --dst;
948  if (dst >= f2->data) {
949  *dst = sign_symbol;
950  }
951  } else {
952  *dst = sign_symbol;
953  --dst;
954  if (dst >= f2->data) {
955  *dst = curr_symbol;
956  }
957  }
958  } else if (sign_symbol) {
959  *dst = sign_symbol;
960  } else {
961  *dst = curr_symbol;
962  }
963  }
964 
965  /* Replace all 'B's by pad */
966  count = 0;
967  for (dst = f2->data; dst < end; ++dst) {
968  if (*dst == 'B') {
969  if (count == 0) {
970  *dst = pad;
971  } else {
972  *dst = ' ';
973  }
974  } else {
975  ++count;
976  }
977  }
978  }
979 
980  COB_PUT_SIGN (f1, sign);
981 }
982 
983 static void
985 {
986  unsigned char *p;
987  unsigned char *buff;
988  const char *p1;
989  size_t i;
990  int sign = 0;
991  int scale = 0;
992  int count = 0;
993  int have_point = 0;
994  int n;
995  unsigned char c;
996  unsigned char cp;
997  unsigned char dec_pt;
998 
999  dec_pt = COB_MODULE_PTR->decimal_point;
1000  buff = cob_malloc (f1->size);
1001  p = buff;
1002  /* De-edit */
1003  for (i = 0; i < f1->size; ++i) {
1004  cp = f1->data[i];
1005  switch (cp) {
1006  case '0':
1007  case '1':
1008  case '2':
1009  case '3':
1010  case '4':
1011  case '5':
1012  case '6':
1013  case '7':
1014  case '8':
1015  case '9':
1016  *p++ = cp;
1017  if (have_point) {
1018  ++scale;
1019  }
1020  break;
1021  case '.':
1022  case ',':
1023  if (cp == dec_pt) {
1024  have_point = 1;
1025  }
1026  break;
1027  case '-':
1028  case 'C':
1029  sign = -1;
1030  break;
1031  }
1032  }
1033  /* Count number of digit places after decimal point in case of 'V', 'P' */
1034  if (scale == 0) {
1035  for (p1 = COB_FIELD_PIC (f1); *p1; p1 += 5) {
1036  c = p1[0];
1037  memmove ((void *)&n, p1 + 1, sizeof(int));
1038  if (c == '9' || c == '0' || c == 'Z' || c == '*') {
1039  if (have_point) {
1040  scale += n;
1041  } else {
1042  count += n;
1043  }
1044  } else if (c == 'P') {
1045  if (count == 0) {
1046  have_point = 1;
1047  scale += n;
1048  } else {
1049  scale -= n;
1050  }
1051  } else if (c == 'V') {
1052  have_point = 1;
1053  }
1054  }
1055  }
1056 
1057  /* Store */
1058  store_common_region (f2, buff, (size_t)(p - buff), scale);
1059 
1060  COB_PUT_SIGN (f2, sign);
1061  cob_free (buff);
1062 }
1063 
1064 static void
1066 {
1067  const char *p;
1068  unsigned char *max;
1069  unsigned char *src;
1070  unsigned char *dst;
1071  int sign;
1072  int n;
1073  unsigned char c;
1074 
1075  sign = COB_GET_SIGN (f1);
1076  src = COB_FIELD_DATA (f1);
1077  max = src + COB_FIELD_SIZE (f1);
1078  dst = f2->data;
1079  for (p = COB_FIELD_PIC (f2); *p;) {
1080  c = *p++; /* PIC char */
1081  memcpy ((void *)&n, p, sizeof(int)); /* PIC char count */
1082  p += sizeof(int);
1083  for (; n > 0; --n) {
1084  switch (c) {
1085  case 'A':
1086  case 'X':
1087  case '9':
1088  *dst++ = (src < max) ? *src++ : ' ';
1089  break;
1090  case '0':
1091  case '/':
1092  *dst++ = c;
1093  break;
1094  case 'B':
1095  *dst++ = ' ';
1096  break;
1097  default:
1098  *dst++ = '?'; /* Invalid PIC */
1099  }
1100  }
1101  }
1102  COB_PUT_SIGN (f1, sign);
1103 }
1104 
1105 /* MOVE dispatcher */
1106 
1107 static void
1108 indirect_move (void (*func) (cob_field *src, cob_field *dst),
1109  cob_field *src, cob_field *dst,
1110  const size_t size, const int scale)
1111 {
1112  cob_field temp;
1113  cob_field_attr attr;
1114 
1117  temp.size = size;
1118  temp.data = cob_malloc (size);
1119  temp.attr = &attr;
1120  func (src, &temp);
1121  cob_move (&temp, dst);
1122  cob_free (temp.data);
1123 }
1124 
1125 static void
1127 {
1128  unsigned char *p;
1129  size_t i;
1130  size_t digcount;
1131  cob_field temp;
1132  cob_field_attr attr;
1133 
1134  if (likely(COB_FIELD_IS_ALNUM(dst))) {
1135  if (likely(src->size == 1)) {
1136  memset (dst->data, src->data[0], dst->size);
1137  } else {
1138  digcount = src->size;
1139  for (i = 0; i < dst->size; ++i) {
1140  dst->data[i] = src->data[i % digcount];
1141  }
1142  }
1143  return;
1144  }
1146  if (COB_FIELD_IS_NUMERIC(dst)) {
1147  digcount = COB_MAX_DIGITS;
1149  attr.digits = COB_MAX_DIGITS;
1150  } else {
1151  digcount = dst->size;
1152  }
1153  p = cob_malloc (digcount);
1154  temp.size = digcount;
1155  temp.data = p;
1156  temp.attr = &attr;
1157  if (likely(src->size == 1)) {
1158  memset (p, src->data[0], digcount);
1159  } else {
1160  for (i = 0; i < digcount; ++i) {
1161  p[i] = src->data[i % src->size];
1162  }
1163  }
1164 
1165  cob_move (&temp, dst);
1166  cob_free (p);
1167 }
1168 
1169 void
1171 {
1172  int opt;
1173  cob_field temp;
1174  unsigned char data[4];
1175 
1176  if (src == dst) {
1177  return;
1178  }
1179  if (dst->size == 0) {
1180  return;
1181  }
1182  if (unlikely(src->size == 0)) {
1183  temp.size = 1;
1184  temp.data = data;
1185  temp.attr = &const_alpha_attr;
1186  data[0] = ' ';
1187  data[1] = 0;
1188  src = &temp;
1189  }
1191  cob_move_all (src, dst);
1192  return;
1193  }
1194 
1195  /* Non-elementary move */
1196  if (COB_FIELD_TYPE (src) == COB_TYPE_GROUP ||
1197  COB_FIELD_TYPE (dst) == COB_TYPE_GROUP) {
1198  cob_move_alphanum_to_alphanum (src, dst);
1199  return;
1200  }
1201 
1202  opt = 0;
1203  if (COB_FIELD_TYPE (dst) == COB_TYPE_NUMERIC_BINARY) {
1204  if (COB_FIELD_BINARY_TRUNC (dst) &&
1205  !COB_FIELD_REAL_BINARY(dst)) {
1207  }
1208  }
1209 
1210  /* Elementary move */
1211  switch (COB_FIELD_TYPE (src)) {
1213  switch (COB_FIELD_TYPE (dst)) {
1222  cob_decimal_setget_fld (src, dst, 0);
1223  return;
1225  cob_move_display_to_display (src, dst);
1226  return;
1228  cob_move_display_to_packed (src, dst);
1229  return;
1231  cob_move_display_to_binary (src, dst);
1232  return;
1234  cob_move_display_to_edited (src, dst);
1235  return;
1237  if (COB_FIELD_SCALE(src) < 0 ||
1238  COB_FIELD_SCALE(src) > COB_FIELD_DIGITS(src)) {
1239  /* Expand P's */
1241  (size_t)cob_max_int ((int)COB_FIELD_DIGITS(src), (int)COB_FIELD_SCALE(src)),
1242  cob_max_int (0, (int)COB_FIELD_SCALE(src)));
1243  return;
1244  } else {
1245  cob_move_alphanum_to_edited (src, dst);
1246  return;
1247  }
1248  default:
1249  cob_move_display_to_alphanum (src, dst);
1250  return;
1251  }
1252 
1254  switch (COB_FIELD_TYPE (dst)) {
1256  cob_move_packed_to_display (src, dst);
1257  return;
1259  cob_decimal_setget_fld (src, dst, opt);
1260  return;
1270  cob_decimal_setget_fld (src, dst, 0);
1271  return;
1272  default:
1274  (size_t)(COB_FIELD_DIGITS(src)),
1275  COB_FIELD_SCALE(src));
1276  return;
1277  }
1278 
1280  switch (COB_FIELD_TYPE (dst)) {
1282  if (COB_FIELD_SCALE(src) == COB_FIELD_SCALE(dst)) {
1283  cob_move_binary_to_binary (src, dst);
1284  return;
1285  }
1286  cob_decimal_setget_fld (src, dst, opt);
1287  return;
1289  cob_move_binary_to_display (src, dst);
1290  return;
1300  cob_decimal_setget_fld (src, dst, 0);
1301  return;
1304  (size_t)COB_MAX_DIGITS,
1305  COB_FIELD_SCALE(src));
1306  return;
1307  default:
1309  (size_t)(COB_FIELD_DIGITS(src)),
1310  COB_FIELD_SCALE(src));
1311  return;
1312  }
1313 
1315  switch (COB_FIELD_TYPE (dst)) {
1317  cob_move_edited_to_display (src, dst);
1318  return;
1331  (size_t)(2 * COB_MAX_DIGITS),
1332  COB_MAX_DIGITS);
1333  return;
1335  cob_move_alphanum_to_edited (src, dst);
1336  return;
1337  default:
1338  cob_move_alphanum_to_alphanum (src, dst);
1339  return;
1340  }
1341 
1343  switch (COB_FIELD_TYPE (dst)) {
1345  memmove (dst->data, src->data, sizeof(double));
1346  return;
1348  cob_move_fp_to_fp (src, dst);
1349  return;
1351  cob_decimal_setget_fld (src, dst, opt);
1352  return;
1361  cob_decimal_setget_fld (src, dst, 0);
1362  return;
1363  default:
1364  cob_decimal_move_temp (src, dst);
1365  return;
1366  }
1367 
1369  switch (COB_FIELD_TYPE (dst)) {
1371  memmove (dst->data, src->data, sizeof(float));
1372  return;
1374  cob_move_fp_to_fp (src, dst);
1375  return;
1377  cob_decimal_setget_fld (src, dst, opt);
1378  return;
1387  cob_decimal_setget_fld (src, dst, 0);
1388  return;
1389  default:
1390  cob_decimal_move_temp (src, dst);
1391  return;
1392  }
1393 
1395  switch (COB_FIELD_TYPE (dst)) {
1397  cob_decimal_setget_fld (src, dst, opt);
1398  return;
1400  memmove (dst->data, src->data, (size_t)8);
1401  return;
1410  cob_decimal_setget_fld (src, dst, 0);
1411  return;
1412  default:
1413  cob_decimal_move_temp (src, dst);
1414  return;
1415  }
1417  switch (COB_FIELD_TYPE (dst)) {
1419  cob_decimal_setget_fld (src, dst, opt);
1420  return;
1422  memmove (dst->data, src->data, (size_t)16);
1423  return;
1433  cob_decimal_setget_fld (src, dst, 0);
1434  return;
1435  default:
1436  cob_decimal_move_temp (src, dst);
1437  return;
1438  }
1439  default:
1440  switch (COB_FIELD_TYPE (dst)) {
1442  cob_move_alphanum_to_display (src, dst);
1443  return;
1456  (size_t)(2* COB_MAX_DIGITS),
1457  COB_MAX_DIGITS);
1458  return;
1460  cob_move_alphanum_to_edited (src, dst);
1461  return;
1462  default:
1463  cob_move_alphanum_to_alphanum (src, dst);
1464  return;
1465  }
1466  }
1467 }
1468 
1469 /* Convenience functions */
1470 
1471 static int
1473 {
1474  unsigned char *data;
1475  size_t i;
1476  size_t offset;
1477  int val = 0;
1478  int sign;
1479 
1480  data = f1->data;
1481  if (COB_FIELD_NO_SIGN_NIBBLE (f1)) {
1482  sign = 0;
1483  offset = COB_FIELD_DIGITS(f1) % 2;
1484  } else {
1485  sign = cob_packed_get_sign (f1);
1486  offset = 1 - (COB_FIELD_DIGITS(f1) % 2);
1487  }
1488  for (i = offset; i < COB_FIELD_DIGITS(f1) - COB_FIELD_SCALE(f1) + offset; ++i) {
1489  val *= 10;
1490  if (i % 2 == 0) {
1491  val += data[i / 2] >> 4;
1492  } else {
1493  val += data[i / 2] & 0x0F;
1494  }
1495  }
1496  if (sign < 0) {
1497  val = -val;
1498  }
1499  return val;
1500 }
1501 
1502 static cob_s64_t
1504 {
1505  unsigned char *data;
1506  size_t i;
1507  size_t offset;
1508  cob_s64_t val = 0;
1509  int sign;
1510 
1511  data = f1->data;
1512  if (COB_FIELD_NO_SIGN_NIBBLE (f1)) {
1513  sign = 0;
1514  offset = COB_FIELD_DIGITS(f1) % 2;
1515  } else {
1516  sign = cob_packed_get_sign (f1);
1517  offset = 1 - (COB_FIELD_DIGITS(f1) % 2);
1518  }
1519  for (i = offset; i < COB_FIELD_DIGITS(f1) - COB_FIELD_SCALE(f1) + offset; ++i) {
1520  val *= 10;
1521  if (i % 2 == 0) {
1522  val += data[i / 2] >> 4;
1523  } else {
1524  val += data[i / 2] & 0x0F;
1525  }
1526  }
1527  if (sign < 0) {
1528  val = -val;
1529  }
1530  return val;
1531 }
1532 
1533 static int
1535 {
1536  unsigned char *data;
1537  size_t size;
1538  size_t i;
1539  int val = 0;
1540  int sign;
1541 
1542  size = COB_FIELD_SIZE (f);
1543  data = COB_FIELD_DATA (f);
1544  sign = COB_GET_SIGN (f);
1545  /* Skip preceding zeros */
1546  for (i = 0; i < size; ++i) {
1547  if (COB_D2I (data[i]) != 0) {
1548  break;
1549  }
1550  }
1551 
1552  /* Get value */
1553  if (COB_FIELD_SCALE(f) < 0) {
1554  for (; i < size; ++i) {
1555  val = val * 10 + COB_D2I (data[i]);
1556  }
1557  val *= cob_exp10[(int)-COB_FIELD_SCALE(f)];
1558  } else {
1559  size -= COB_FIELD_SCALE(f);
1560  for (; i < size; ++i) {
1561  val = val * 10 + COB_D2I (data[i]);
1562  }
1563  }
1564  if (sign < 0) {
1565  val = -val;
1566  }
1567 
1568  COB_PUT_SIGN (f, sign);
1569  return val;
1570 }
1571 
1572 static cob_s64_t
1574 {
1575  unsigned char *data;
1576  size_t size;
1577  size_t i;
1578  cob_s64_t val = 0;
1579  int sign;
1580 
1581  size = COB_FIELD_SIZE (f);
1582  data = COB_FIELD_DATA (f);
1583  sign = COB_GET_SIGN (f);
1584  /* Skip preceding zeros */
1585  for (i = 0; i < size; ++i) {
1586  if (COB_D2I (data[i]) != 0) {
1587  break;
1588  }
1589  }
1590 
1591  /* Get value */
1592  if (COB_FIELD_SCALE(f) < 0) {
1593  for (; i < size; ++i) {
1594  val = val * 10 + COB_D2I (data[i]);
1595  }
1596  val *= cob_exp10_ll[(int)-COB_FIELD_SCALE(f)];
1597  } else {
1598  size -= COB_FIELD_SCALE(f);
1599  for (; i < size; ++i) {
1600  val = val * 10 + COB_D2I (data[i]);
1601  }
1602  }
1603  if (sign < 0) {
1604  val = -val;
1605  }
1606 
1607  COB_PUT_SIGN (f, sign);
1608  return val;
1609 }
1610 
1611 void
1612 cob_set_int (cob_field *f, const int n)
1613 {
1614  cob_field temp;
1615  cob_field_attr attr;
1616 
1619  temp.size = 4;
1620  temp.data = (unsigned char *)&n;
1621  temp.attr = &attr;
1622  cob_move (&temp, f);
1623 }
1624 
1625 int
1627 {
1628  int n;
1629  cob_s64_t val;
1630  cob_field temp;
1631  cob_field_attr attr;
1632 
1633  switch (COB_FIELD_TYPE (f)) {
1635  return cob_display_get_int (f);
1637  return cob_packed_get_int (f);
1639  val = cob_binary_mget_sint64 (f);
1640  for (n = COB_FIELD_SCALE (f); n > 0 && val; --n) {
1641  val /= 10;
1642  }
1643  return (int)val;
1644  default:
1647  temp.size = 4;
1648  temp.data = (unsigned char *)&n;
1649  temp.attr = &attr;
1650  cob_move (f, &temp);
1651  return n;
1652  }
1653 }
1654 
1655 cob_s64_t
1657 {
1658  cob_s64_t n;
1659  int inc;
1660  cob_field temp;
1661 
1662  switch (COB_FIELD_TYPE (f)) {
1664  return cob_display_get_long_long (f);
1666  return cob_packed_get_long_long (f);
1668  n = cob_binary_mget_sint64 (f);
1669  for (inc = COB_FIELD_SCALE (f); inc > 0 && n; --inc) {
1670  n /= 10;
1671  }
1672  return n;
1673  default:
1674  temp.size = 8;
1675  temp.data = (unsigned char *)&n;
1676  temp.attr = &const_binll_attr;
1677  cob_move (f, &temp);
1678  return n;
1679  }
1680 }
1681 
1682 void
1684 {
1685  cobglobptr = lptr;
1686  cobsetptr = sptr;
1687 }
void cob_free(void *mptr)
Definition: common.c:1284
#define COB_FIELD_SCALE(f)
Definition: common.h:664
static void cob_move_edited_to_display(cob_field *f1, cob_field *f2)
Definition: move.c:984
#define COB_FIELD_DATA(f)
Definition: common.h:668
#define COB_FIELD_BINARY_SWAP(f)
Definition: common.h:648
#define COB_TYPE_NUMERIC_PACKED
Definition: common.h:609
static void cob_move_alphanum_to_display(cob_field *f1, cob_field *f2)
Definition: move.c:259
#define COB_FIELD_IS_NUMERIC(f)
Definition: common.h:674
static void cob_move_display_to_packed(cob_field *f1, cob_field *f2)
Definition: move.c:451
#define COB_TYPE_ALPHANUMERIC
Definition: common.h:621
static void cob_move_alphanum_to_edited(cob_field *f1, cob_field *f2)
Definition: move.c:1065
static void cob_move_binary_to_display(cob_field *f1, cob_field *f2)
Definition: move.c:637
#define COB_TYPE_NUMERIC_FP_BIN32
Definition: common.h:615
void cob_move(cob_field *src, cob_field *dst)
Definition: move.c:1170
static int cob_display_get_int(cob_field *f)
Definition: move.c:1534
#define COB_FIELD_TYPE(f)
Definition: common.h:662
static void cob_move_display_to_binary(cob_field *f1, cob_field *f2)
Definition: move.c:593
static const int cob_exp10[10]
Definition: move.c:57
cob_field f2
Definition: cobxref.c.l.h:55
static void cob_move_packed_to_display(cob_field *f1, cob_field *f2)
Definition: move.c:506
#define COB_TYPE_GROUP
Definition: common.h:603
#define COB_FLAG_REAL_BINARY
Definition: common.h:636
#define COB_INLINE
Definition: common.h:354
static COB_INLINE COB_A_INLINE void cob_binary_mset_uint64(cob_field *f, cob_u64_t n)
Definition: move.c:239
static COB_INLINE int cob_max_int(const int x, const int y)
Definition: move.c:102
static void cob_move_alphanum_to_alphanum(cob_field *f1, cob_field *f2)
Definition: move.c:418
#define COB_ATTR_INIT(u, v, x, y, z)
Definition: coblocal.h:150
static void store_common_region(cob_field *f, const unsigned char *data, const size_t size, const int scale)
Definition: move.c:131
unsigned char * data
Definition: common.h:952
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)
Definition: move.c:1108
#define cob_s64_t
Definition: common.h:51
static void cob_move_display_to_display(cob_field *f1, cob_field *f2)
Definition: move.c:342
#define COB_S64_C(x)
Definition: common.h:54
static const cob_s64_t cob_exp10_ll[19]
Definition: move.c:70
#define COB_FLAG_HAVE_SIGN
Definition: common.h:630
#define COB_TYPE_NUMERIC_FP_BIN64
Definition: common.h:616
#define COB_MAX_DIGITS
Definition: common.h:562
#define COB_I2D(x)
Definition: coblocal.h:183
#define COB_FIELD_IS_ALNUM(f)
Definition: common.h:676
#define COB_FIELD_JUSTIFIED(f)
Definition: common.h:647
static cob_global * cobglobptr
Definition: move.c:42
int cob_get_int(cob_field *f)
Definition: move.c:1626
static void cob_move_display_to_alphanum(cob_field *f1, cob_field *f2)
Definition: move.c:355
static cob_s64_t cob_display_get_long_long(cob_field *f)
Definition: move.c:1573
#define COB_TYPE_NUMERIC_FP_DEC64
Definition: common.h:613
#define COB_FIELD_NO_SIGN_NIBBLE(f)
Definition: common.h:651
#define COB_GET_SIGN(f)
Definition: coblocal.h:158
void cob_set_int(cob_field *f, const int n)
Definition: move.c:1612
#define cob_u8_ptr
Definition: common.h:66
#define COB_TYPE_NUMERIC_FLOAT
Definition: common.h:610
static cob_settings * cobsetptr
Definition: move.c:43
#define COB_FIELD_REAL_BINARY(f)
Definition: common.h:649
#define unlikely(x)
Definition: common.h:437
static COB_INLINE COB_A_INLINE void cob_binary_mset_sint64(cob_field *f, cob_s64_t n)
Definition: move.c:221
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
Definition: exception.def:95
static void cob_move_all(cob_field *src, cob_field *dst)
Definition: move.c:1126
if sign
Definition: flag.def:42
static COB_INLINE COB_A_INLINE cob_s64_t cob_binary_mget_sint64(const cob_field *const f)
Definition: move.c:163
#define COB_FIELD_BLANK_ZERO(f)
Definition: common.h:646
static int cob_packed_get_sign(const cob_field *f)
Definition: move.c:119
cob_field f1
Definition: cobxref.c.l.h:54
#define COB_FIELD_BINARY_TRUNC(f)
Definition: common.h:654
#define COB_TYPE_NUMERIC_BINARY
Definition: common.h:608
#define COB_TYPE_ALPHANUMERIC_EDITED
Definition: common.h:623
#define COB_TYPE_NUMERIC_DISPLAY
Definition: common.h:607
#define COB_TYPE_NUMERIC_FP_BIN128
Definition: common.h:617
#define COB_PUT_SIGN(f, s)
Definition: coblocal.h:160
static const cob_field_attr const_binll_attr
Definition: move.c:53
#define COB_TYPE_ALPHANUMERIC_ALL
Definition: common.h:622
#define COB_FIELD_PIC(f)
Definition: common.h:666
#define COB_MODULE_PTR
Definition: coblocal.h:185
static void cob_move_display_to_edited(cob_field *f1, cob_field *f2)
Definition: move.c:676
unsigned short digits
Definition: common.h:942
static void cob_move_fp_to_fp(cob_field *src, cob_field *dst)
Definition: move.c:541
void cob_decimal_setget_fld(cob_field *, cob_field *, const int)
Definition: numeric.c:2007
static COB_INLINE COB_A_INLINE cob_u64_t cob_binary_mget_uint64(const cob_field *const f)
Definition: move.c:201
#define COB_A_INLINE
Definition: common.h:440
size_t size
Definition: common.h:951
#define COB_TYPE_NUMERIC_DOUBLE
Definition: common.h:611
const cob_field_attr * attr
Definition: common.h:953
static int cob_packed_get_int(cob_field *f1)
Definition: move.c:1472
static cob_s64_t cob_packed_get_long_long(cob_field *f1)
Definition: move.c:1503
void * cob_malloc(const size_t size)
Definition: common.c:1250
static COB_INLINE COB_A_INLINE void own_byte_memcpy(unsigned char *s1, const unsigned char *s2, size_t size)
Definition: move.c:111
#define COB_STORE_TRUNC_ON_OVERFLOW
Definition: common.h:869
#define COB_FIELD_HAVE_SIGN(f)
Definition: common.h:643
unsigned short type
Definition: common.h:941
cob_s64_t cob_get_llint(cob_field *f)
Definition: move.c:1656
#define COB_D2I(x)
Definition: coblocal.h:177
#define COB_TYPE_NUMERIC_FP_DEC128
Definition: common.h:614
void cob_decimal_move_temp(cob_field *, cob_field *)
Definition: intrinsic.c:3104
#define cob_u64_t
Definition: common.h:52
#define COB_FIELD_DIGITS(f)
Definition: common.h:663
static COB_INLINE int cob_min_int(const int x, const int y)
Definition: move.c:93
#define COB_BSWAP_64(val)
Definition: common.h:258
#define COB_TYPE_NUMERIC_EDITED
Definition: common.h:619
#define COB_TYPE_NUMERIC_L_DOUBLE
Definition: common.h:612
#define likely(x)
Definition: common.h:436
static void cob_move_binary_to_binary(cob_field *f1, cob_field *f2)
Definition: move.c:564
#define COB_FIELD_SIZE(f)
Definition: common.h:671
void cob_init_move(cob_global *lptr, cob_settings *sptr)
Definition: move.c:1683
static const cob_field_attr const_alpha_attr
Definition: move.c:51