32 #ifdef HAVE_SYS_TIME_H
38 #if defined(_WIN32) || defined(__CYGWIN__) || defined(HAVE_LANGINFO_CODESET)
39 #define LOCTIME_BUFSIZE 128
41 #if defined(_WIN32) || defined(__CYGWIN__)
42 #undef HAVE_LANGINFO_CODESET
43 #define WIN32_LEAN_AND_MEAN
46 #include <sys/timeb.h>
50 #ifdef HAVE_LANGINFO_CODESET
60 #define COB_LIB_EXPIMP
110 {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365};
112 {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366};
114 {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
116 {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
119 #define COB_DATESTR_LEN 11
120 #define COB_DATESTR_MAX (COB_DATESTR_LEN - 1)
122 #define COB_TIMEDEC_MAX 9
124 #define COB_TIMESTR_LEN 26
125 #define COB_TIMESTR_MAX (COB_TIMESTR_LEN - 1)
127 #define COB_DATETIMESTR_LEN 36
128 #define COB_DATETIMESTR_MAX (COB_DATETIMESTR_LEN - 1)
131 #if defined(_WIN32) || defined(__CYGWIN__)
134 const char *winlocalename;
135 const int winlocaleid;
138 static const struct winlocale wintable[] =
158 {
"arn_CL", 0x047a },
160 {
"az_Cyrl_AZ", 0x082c },
161 {
"az_Latn_AZ", 0x042c },
169 {
"bs_Cyrl_BA", 0x201a },
170 {
"bs_Latn_BA", 0x141a },
180 {
"dsb_DE", 0x082e },
183 {
"en_029", 0x2409 },
223 {
"fil_PH", 0x0464 },
233 {
"gbz_AF", 0x048c },
236 {
"gsw_FR", 0x0484 },
238 {
"ha_Latn_NG", 0x0468 },
251 {
"iu_Cans_CA", 0x045d },
252 {
"iu_Latn_CA", 0x085d },
260 {
"kok_IN", 0x0457 },
269 {
"mn_Cyrl_MN", 0x0450 },
270 {
"mn_Mong_CN", 0x0850 },
271 {
"moh_CA", 0x047c },
289 {
"qut_GT", 0x0486 },
290 {
"quz_BO", 0x046b },
291 {
"quz_EC", 0x086b },
292 {
"quz_PE", 0x0c6b },
300 {
"sah_RU", 0x0485 },
307 {
"sma_NO", 0x183b },
308 {
"sma_SE", 0x1c3b },
309 {
"smj_NO", 0x103b },
310 {
"smj_SE", 0x143b },
311 {
"smn_FI", 0x243b },
312 {
"sms_FI", 0x203b },
314 {
"sr_Cyrl_BA", 0x1c1a },
315 {
"sr_Cyrl_CS", 0x0c1a },
316 {
"sr_Latn_BA", 0x181a },
317 {
"sr_Latn_CS", 0x081a },
322 {
"syr_SY", 0x045a },
325 {
"tg_Cyrl_TJ", 0x0428 },
328 {
"tmz_Latn_DZ", 0x085f },
337 {
"uz_Cyrl_UZ", 0x0843 },
338 {
"uz_Latn_UZ", 0x0443 },
340 {
"wen_DE", 0x042e },
353 #define WINLOCSIZE sizeof(wintable) / sizeof(struct winlocale)
360 "3.141592653589793238462643383279502884197169399375"
361 "10582097494459230781640628620899862803482534211706"
362 "79821480865132823066470938446095505822317253594081"
363 "28481117450284102701938521105559644622948954930381"
364 "96442881097566593344612847564823378678316527120190"
365 "91456485669234603486104543266482133936072602491412"
366 "73724587006606315588174881520920962829254091715364"
367 "36789259036001133053054882046652138414695194151160"
368 "94330572703657595919530921861173819326117931051185"
369 "48074462379962749567351885752724891227938183011949"
370 "12983367336244065664308602139494639522473719070217"
371 "98609437027705392171762931767523846748184676694051"
372 "32000568127145263560827785771342757789609173637178"
373 "72146844090122495343014654958537105079227968925892"
374 "35420199561121290219608640344181598136297747713099"
375 "60518707211349999998372978049951059731732816096318"
376 "59502445945534690830264252230825334468503526193118"
380 "1.414213562373095048801688724209698078569671875376"
381 "94807317667973799073247846210703885038753432764157"
382 "27350138462309122970249248360558507372126441214970"
383 "99935831413222665927505592755799950501152782060571"
384 "47010955997160597027453459686201472851741864088919"
385 "86095523292304843087143214508397626036279952514079"
386 "89687253396546331808829640620615258352395054745750"
387 "28775996172983557522033753185701135437460340849884"
388 "71603868999706990048150305440277903164542478230684"
389 "92936918621580578463111596668713013015618568987237"
390 "23528850926486124949771542183342042856860601468247"
391 "20771435854874155657069677653720226485447015858801"
392 "62075847492265722600208558446652145839889394437092"
393 "65918003113882464681570826301005948587040031864803"
394 "42194897278290641045072636881313739855256117322040"
395 "24509122770022694112757362728049573810896750401836"
396 "98683684507257993647290607629969413804756548237289"
397 "97180326802474420629269124859052181004459842150591"
398 "12024944134172853147810580360337107730918286931471"
399 "01711116839165817268894197587165821521282295184884"
400 "72089694633862891562882765952635140542267653239694"
401 "61751129160240871551013515045538128756005263146801"
402 "71274026539694702403005174953188629256313851881634"
406 "-0.69314718055994530941723212145817656807550013436"
407 "02552541206800094933936219696947156058633269964186"
408 "87542001481020570685733685520235758130557032670751"
409 "63507596193072757082837143519030703862389167347112"
410 "33501153644979552391204751726815749320651555247341"
411 "39525882950453007095326366642654104239157814952043"
412 "74043038550080194417064167151864471283996817178454"
413 "69570262716310645461502572074024816377733896385506"
414 "95260668341137273873722928956493547025762652098859"
415 "69320196505855476470330679365443254763274495125040"
416 "60694381471046899465062201677204245245296126879465"
417 "46193165174681392672504103802546259656869144192871"
418 "60829380317271436778265487756648508567407764845146"
419 "44399404614226031930967354025744460703080960850474"
420 "86638523138181676751438667476647890881437141985494"
421 "23151997354880375165861275352916610007105355824987"
422 "94147295092931138971559982056543928717";
425 #define COB_PI_LEN 2820UL
426 #define COB_SQRT_TWO_LEN 3827UL
427 #define COB_LOG_HALF_LEN 2784UL
429 #define RETURN_IF_NOT_ZERO(expr) \
431 int error_pos = (expr); \
432 if (error_pos != 0) { \
448 if (curr_field->
data) {
454 s = curr_field->
data;
455 memset (s, 0, f->
size);
462 curr_field->
data = s;
472 return ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) ? 1 : 0;
493 if ((
size_t)offset <= f->size) {
494 calcoff = (size_t)offset - 1;
495 size = f->
size - calcoff;
496 if (length > 0 && (
size_t)length < size) {
497 size = (size_t)length;
501 memmove (f->
data, f->
data + calcoff, size);
519 if (!mpz_sgn (d->
value)) {
525 if (!mpz_divisible_ui_p (d->
value, 10UL)) {
548 memcpy (curr_field->
data, &val,
sizeof(
int));
569 unsigned short attrsign;
584 if (mpz_sgn (d->
value) < 0) {
594 bitnum = mpz_sizeinbase (d->
value, 2);
595 if (bitnum < (33 - sign) && d->
scale < 10) {
601 }
else if (bitnum < (65 - sign) && d->
scale < 19) {
609 size = (short)mpz_sizeinbase (d->
value, 10);
610 if (d->
scale > size) {
611 size = (short)d->
scale;
613 scale = (short)d->
scale;
615 scale, attrsign,
NULL);
632 if (!mpz_sgn (d3.
value)) {
645 }
else if (d2.
scale > 0) {
646 sign = mpz_sgn (d2.
value);
655 if (sign < 0 && mpz_sgn (
cob_mpzt)) {
689 unsigned char dec_pt;
691 if (!srcfield->
size) {
706 for (n = 0; n < (int)srcfield->
size; ++n, ++p) {
744 if (n == (
int)srcfield->
size) {
748 for (; n < (int)srcfield->
size; ++n, ++p) {
761 if (++exponent > 4 || !e_plus_minus) {
770 if (dec_seen || space_seen || e_seen) {
806 if (!digits || (e_seen && !exponent)) {
823 if (!mpf_sgn (src)) {
824 mpz_set_ui (d->
value, 0UL);
828 q = mpf_get_str (
NULL, &scale, 10, (
size_t)96, src);
830 mpz_set_str (d->
value, p, 10);
851 mpf_set_z (dst, d->
value);
857 }
else if (scale > 0) {
883 mpf_set (vf1, src_val);
885 mpf_set_ui (vf2, 1UL);
888 mpf_set_ui (dst_temp, 1UL);
890 if (mpf_sgn (vf1) < 0) {
897 mpf_get_d_2exp (&expon, vf1);
899 mpf_div_2exp (vf1, vf1, (
cob_uli_t)expon);
904 mpf_mul (vf2, vf2, vf1);
906 mpf_set (vf3, dst_temp);
907 mpf_add (dst_temp, dst_temp, vf2);
911 for (i = 0; i < expon; ++i) {
912 mpf_mul (dst_temp, dst_temp, dst_temp);
916 mpf_ui_div (dst_temp, 1UL, dst_temp);
919 mpf_set (dst_val, dst_temp);
920 mpf_clear (dst_temp);
933 mpf_t vf1, vf2, vf3, vf4;
940 if (mpf_sgn (src_val) <= 0 || !mpf_cmp_ui (src_val, 1UL)) {
941 mpf_set_ui (dst_val, 0UL);
948 mpf_set (vf1, src_val);
951 mpf_set_si (vf3, -1L);
954 mpf_set_ui (dst_temp, 0UL);
955 mpf_get_d_2exp (&expon, vf1);
959 mpf_mul_ui (dst_temp, dst_temp, (
cob_uli_t)expon);
960 mpf_neg (dst_temp, dst_temp);
961 mpf_div_2exp (vf1, vf1, (
cob_uli_t)expon);
963 mpf_mul_ui (dst_temp, dst_temp, (
cob_uli_t)-expon);
964 mpf_mul_2exp (vf1, vf1, (
cob_uli_t)-expon);
967 mpf_ui_sub (vf1, 1UL, vf1);
971 mpf_mul (vf3, vf3, vf1);
972 mpf_div_ui (vf2, vf3, n);
973 mpf_set (vf4, dst_temp);
974 mpf_add (dst_temp, dst_temp, vf2);
978 mpf_set (dst_val, dst_temp);
979 mpf_clear (dst_temp);
1001 mpf_set_ui (vf1, 10UL);
1003 mpf_div (dst_temp, dst_temp, vf1);
1005 mpf_set (dst_val, dst_temp);
1006 mpf_clear (dst_temp);
1018 mpf_t vf1, vf2, vf3, vf4, vf5;
1031 sign = mpf_sgn (src_val);
1033 mpf_abs (vf4, src_val);
1035 mpf_div_2exp (vf3, vf3, 1UL);
1036 mpf_div (vf1, vf4, vf3);
1037 mpf_floor (vf4, vf1);
1039 if (mpf_cmp_ui (vf4, 4UL) >= 0) {
1040 mpf_div_2exp (vf2, vf4, 2UL);
1041 mpf_floor (vf2, vf2);
1042 mpf_mul_2exp (vf2, vf2, 2UL);
1043 mpf_sub (vf2, vf4, vf2);
1048 arcquad = mpf_get_ui (vf2);
1049 mpf_sub (vf2, vf1, vf4);
1050 mpf_mul (vf4, vf3, vf2);
1056 mpf_sub (vf4, vf3, vf4);
1059 mpf_mul (vf3, vf4, vf4);
1063 mpf_set_ui (vf2, 1UL);
1064 mpf_set_ui (dst_temp, 1UL);
1068 mpf_div_ui (vf2, vf2, n);
1070 mpf_div_ui (vf2, vf2, n);
1071 mpf_mul (vf2, vf2, vf3);
1072 mpf_set (vf5, dst_temp);
1073 mpf_add (dst_temp, dst_temp, vf2);
1076 mpf_mul (dst_temp, dst_temp, vf4);
1078 mpf_neg (dst_temp, dst_temp);
1081 mpf_set (dst_val, dst_temp);
1082 mpf_clear (dst_temp);
1102 mpf_div_2exp (vf1, vf1, 1UL);
1103 mpf_sub (vf1, vf1, src_val);
1123 mpf_div (dst_val, vf1, vf2);
1134 mpf_t vf1, vf2, vf3, vf4;
1145 mpf_abs (vf1, src_val);
1148 if (mpf_cmp (vf1, vf3) > 0) {
1149 mpf_set (dst_temp,
cob_pi);
1150 mpf_div_2exp (dst_temp, dst_temp, 1UL);
1151 mpf_ui_div (vf1, 1UL, vf1);
1155 if (mpf_cmp (vf1, vf4) > 0) {
1156 mpf_set (dst_temp,
cob_pi);
1157 mpf_div_2exp (dst_temp, dst_temp, 2UL);
1158 mpf_sub_ui (vf3, vf1, 1UL);
1159 mpf_add_ui (vf4, vf1, 1UL);
1160 mpf_div (vf1, vf3, vf4);
1162 mpf_set_ui (dst_temp, 0UL);
1165 mpf_mul (vf2, vf1, vf1);
1167 mpf_add (dst_temp, dst_temp, vf1);
1172 mpf_mul (vf1, vf1, vf2);
1173 mpf_div_ui (vf3, vf1, 2UL * n + 1UL);
1174 mpf_set (vf4, dst_temp);
1175 mpf_add (dst_temp, dst_temp, vf3);
1179 if (mpf_sgn (src_val) < 0) {
1180 mpf_neg (dst_temp, dst_temp);
1183 mpf_set (dst_val, dst_temp);
1184 mpf_clear (dst_temp);
1203 if (!mpf_cmp_ui (src_val, 1UL) || !mpf_cmp_si (src_val, -1L)) {
1204 mpf_set (dst_temp,
cob_pi);
1205 mpf_div_ui (dst_temp, dst_temp, 2UL);
1206 if (mpf_sgn (src_val) < 0) {
1207 mpf_neg (dst_temp, dst_temp);
1209 mpf_set (dst_val, dst_temp);
1210 mpf_clear (dst_temp);
1213 if (!mpz_sgn (src_val)) {
1214 mpf_set_ui (dst_val, 0UL);
1215 mpf_clear (dst_temp);
1222 mpf_mul (vf2, src_val, src_val);
1223 mpf_ui_sub (vf2, 1UL, vf2);
1224 mpf_sqrt (vf2, vf2);
1226 mpf_add_ui (vf2, vf2, 1UL);
1228 mpf_div (vf1, src_val, vf2);
1230 mpf_mul_ui (dst_temp, dst_temp, 2UL);
1232 mpf_set (dst_val, dst_temp);
1233 mpf_clear (dst_temp);
1250 if (!mpf_sgn (src_val)) {
1251 mpf_set (dst_temp,
cob_pi);
1252 mpf_div_ui (dst_temp, dst_temp, 2UL);
1253 mpf_set (dst_val, dst_temp);
1254 mpf_clear (dst_temp);
1257 if (!mpf_cmp_ui (src_val, 1UL)) {
1258 mpf_set_ui (dst_val, 0UL);
1259 mpf_clear (dst_temp);
1262 if (!mpf_cmp_si (src_val, -1L)) {
1263 mpf_set (dst_val,
cob_pi);
1264 mpf_clear (dst_temp);
1271 mpf_add_ui (vf2, src_val, 1UL);
1272 mpf_mul (vf1, src_val, src_val);
1273 mpf_ui_sub (vf1, 1UL, vf1);
1274 mpf_sqrt (vf1, vf1);
1275 mpf_div (vf1, vf1, vf2);
1277 mpf_mul_ui (dst_temp, dst_temp, 2UL);
1279 mpf_set (dst_val, dst_temp);
1280 mpf_clear (dst_temp);
1291 int (*cmp_func)(
const void *,
const void *,
size_t))
1293 unsigned char *match_begin = original->
data;
1294 size_t orig_size = original->
size;
1295 size_t calcsize = 0;
1300 for (cur_idx = 0; cur_idx < orig_size; ) {
1302 for (i = 0; i < numreps; ++i) {
1304 if (cur_idx + matches[i]->size > orig_size) {
1309 if (!(*cmp_func) (match_begin, matches[i]->data, matches[i]->size)) {
1311 match_begin += matches[i]->
size;
1312 cur_idx += matches[i]->
size;
1314 calcsize += reps[i]->
size;
1337 int (*cmp_func)(
const void *,
const void *,
size_t),
1338 unsigned char *replaced_begin)
1340 unsigned char *match_begin = original->
data;
1341 size_t orig_size = original->
size;
1346 for (cur_idx = 0; cur_idx < orig_size; ) {
1348 for (i = 0; i < numreps; ++i) {
1350 if (cur_idx + matches[i]->size > orig_size) {
1355 if (!(*cmp_func) (match_begin, matches[i]->data, matches[i]->size)) {
1357 memcpy (replaced_begin, reps[i]->data, reps[i]->size);
1359 match_begin += matches[i]->
size;
1360 replaced_begin += reps[i]->
size;
1361 cur_idx += matches[i]->
size;
1374 *replaced_begin++ = *match_begin++;
1381 int (*cmp_func)(
const void *,
const void *,
size_t),
1390 int numreps = params / 2;
1398 for (i = 0; i < params - 1; ++i) {
1400 matches[i / 2] = va_arg (args,
cob_field *);
1402 reps[i / 2] = va_arg (args,
cob_field *);
1413 field.
size = calcsize;
1432 return (
int) strncasecmp (s1, s2, n);
1440 return i >= (field->
size - n);
1446 return memcmp (&srcfield->
data[pos],
"CR", (
size_t)2) == 0
1447 || memcmp (&srcfield->
data[pos],
"DB", (
size_t)2) == 0;
1459 unsigned char *currency_data =
NULL;
1461 int final_digits = 0;
1462 int decimal_digits = 0;
1464 int decimal_seen = 0;
1475 if (currency && currency->
size < srcfield->
size) {
1476 currency_data = currency->
data;
1479 for (i = 0; i < srcfield->
size; ++i) {
1486 if (currency_data) {
1488 && !memcmp (&srcfield->
data[i], currency_data,
1490 i += (currency->
size - 1);
1493 }
else if (type ==
NUMVAL_C && srcfield->
data[i] == cur_symb) {
1497 if (srcfield->
data[i] ==
' ') {
1500 if (srcfield->
data[i] ==
'+') {
1503 if (srcfield->
data[i] ==
'-') {
1507 if (srcfield->
data[i] == dec_pt) {
1511 if (srcfield->
data[i] >= (
unsigned char)
'0' &&
1512 srcfield->
data[i] <= (
unsigned char)
'9') {
1516 final_buff[final_digits++] = srcfield->
data[i];
1524 if (!final_digits) {
1525 final_buff[0] =
'0';
1528 mpz_set_str (d1.
value, (
char *)final_buff, 10);
1530 if (sign && mpz_sgn (d1.
value)) {
1533 d1.
scale = decimal_digits;
1551 for (i = 1; i < num_args; ++i) {
1569 mpz_set_ui (d1.
value, 0UL);
1572 for (i = 0; i < num_args; ++i) {
1594 mpz_set_ui (d1.
value, 0UL);
1599 mpz_set_ui (sum->
value, 0UL);
1604 for (i = 0; i < n; ++i) {
1615 num_numbers->
scale = 0;
1625 int *
const interval,
int *
const current_year)
1643 timeptr = localtime (&t);
1644 *current_year = 1900 + timeptr->tm_year;
1650 #if defined(_WIN32) || defined(__CYGWIN__) || defined (HAVE_LANGINFO_CODESET)
1651 #ifdef HAVE_LANGINFO_CODESET
1653 locale_time (
const int hours,
const int minutes,
const int seconds,
1656 char *deflocale =
NULL;
1658 char buff2[LOCTIME_BUFSIZE] = {
'\0' };
1662 memset ((
void *)&tstruct, 0,
sizeof(
struct tm));
1663 tstruct.tm_hour = hours;
1664 tstruct.tm_min = minutes;
1665 tstruct.tm_sec = seconds;
1673 deflocale = locale_buff;
1674 (void) setlocale (LC_TIME, deflocale);
1678 memset (buff2, 0, LOCTIME_BUFSIZE);
1679 snprintf(buff2, LOCTIME_BUFSIZE - 1,
"%s", nl_langinfo(T_FMT));
1683 (void) setlocale (LC_ALL, cobglobptr->
cob_locale);
1686 strftime (buff, LOCTIME_BUFSIZE, buff2, &tstruct);
1692 locale_time (
const int hours,
const int minutes,
const int seconds,
1697 LCID localeid = LOCALE_USER_DEFAULT;
1702 memset ((
void *)&syst, 0,
sizeof(syst));
1703 syst.wHour = (
WORD)hours;
1704 syst.wMinute = (
WORD)minutes;
1705 syst.wSecond = (
WORD)seconds;
1716 for (p = (
unsigned char *)locale_buff; *p; ++p) {
1717 if (isalnum((
int)*p) || *p ==
'_') {
1725 for (len = 0; len < WINLOCSIZE; ++len) {
1726 if (!strcmp(locale_buff, wintable[len].winlocalename)) {
1727 localeid = wintable[len].winlocaleid;
1731 if (len == WINLOCSIZE) {
1737 if (!GetTimeFormat (localeid, LOCALE_NOUSEROVERRIDE, &syst,
NULL, buff,
1751 const size_t str_len = strlen (str);
1756 memcpy (curr_field->
data, str, str_len);
1770 memset (curr_field->
data,
' ', (
size_t)n);
1784 return min <= val && val <= max;
1790 return in_range (1, 3067671, days);
1796 return in_range (1601, 9999, year);
1833 #define SECONDS_IN_DAY 86400
1847 seconds_in_day->
scale = 0;
1852 #undef SECONDS_IN_DAY
1857 const int minutes_in_day = 1440;
1858 return abs (offset) < minutes_in_day;
1864 int baseyear = 1601;
1868 while (days > leapyear) {
1873 for (i = 0; i < 13; ++i) {
1899 while (days > leapyear) {
1912 int baseyear = 1601;
1914 while (baseyear != year) {
1966 const char *scanf_str = format.
with_colons ?
"%2d:%2d:%2d" :
"%2d%2d%2d";
1973 int unscaled_fraction = 0;
1976 if (
unlikely(!sscanf (str, scanf_str, &hours, &minutes, &seconds))) {
1980 total_seconds = (hours * 60 * 60) + (minutes * 60) + seconds;
1985 for (; offset != end_of_decimal; ++offset) {
1986 unscaled_fraction = unscaled_fraction * 10 +
cob_ctoi (str[offset]);
1989 mpz_set_ui (fractional_seconds->
value, unscaled_fraction);
1992 mpz_set_ui (seconds_decimal->
value, total_seconds);
1995 mpz_set_ui (seconds_decimal->
value, total_seconds);
1996 seconds_decimal->
scale = 0;
2010 size_t str_len = strlen (str);
2012 for (i = 0; i < str_len && !isspace ((
int) str[i]); ++i);
2022 const char *format_str;
2026 format_str = with_hyphen ?
"%4.4d-%2.2d-%2.2d" :
"%4.4d%2.2d%2.2d";
2027 sprintf (buff, format_str, year, month, day_of_month);
2035 const char *format_str;
2039 format_str = with_hyphen ?
"%4.4d-%3.3d" :
"%4.4d%3.3d";
2040 sprintf (buff, format_str, year, day_of_year);
2047 return (day_num - 1) % 7;
2053 int jan_4 = day_num - day_of_year + 4;
2055 int first_monday = jan_4 - day_of_week;
2056 return first_monday;
2074 dec_29 = day_num - day_of_year + days_to_dec_29;
2076 if (day_num >= dec_29) {
2081 if (day_num < week_one) {
2092 if (day_num < week_one) {
2099 *week = (day_num - week_one) / 7 + 1;
2105 int ignored_day_of_year;
2109 const char *format_str;
2115 format_str = with_hyphen ?
"%4.4d-W%2.2d-%1.1d" :
"%4.4dW%2.2d%1.1d";
2116 sprintf (buff, format_str, year, week, day_of_week + 1);
2135 if (!strcmp (format_str,
"YYYYMMDD") || !strcmp (format_str,
"YYYY-MM-DD")) {
2137 }
else if (!strcmp (format_str,
"YYYYDDD") || !strcmp (format_str,
"YYYY-DDD")) {
2151 void (*formatting_func) (int, int,
char *);
2172 whole_seconds = &
d5;
2173 mpz_set_ui (whole_seconds->
value, (
unsigned long) seconds);
2174 whole_seconds->
scale = 0;
2183 ptrdiff_t offset = point_pos;
2184 int decimal_places = 0;
2186 while (str[++offset] ==
's') {
2190 return decimal_places;
2196 return !strcmp (str,
"Z");
2203 return !strcmp (str,
"+hh:mm");
2205 return !strcmp (str,
"+hhmm");
2214 int_pow (
const unsigned int base,
unsigned int power)
2216 unsigned int ret = 1;
2228 char *buff, ptrdiff_t *buff_pos)
2230 unsigned int scale = second_fraction->
scale;
2231 unsigned int power_of_ten;
2232 unsigned int fraction = mpz_get_ui (second_fraction->
value);
2239 while (scale != 0 && decimal_places != 0) {
2241 power_of_ten =
int_pow (10, scale);
2242 buff[*buff_pos] =
'0' + (fraction / power_of_ten);
2244 fraction %= power_of_ten;
2250 if (decimal_places != 0) {
2251 memset (buff + *buff_pos,
'0', decimal_places);
2252 *buff_pos += decimal_places;
2257 add_z (
const ptrdiff_t buff_pos,
char *buff)
2259 buff[buff_pos] =
'Z';
2264 const ptrdiff_t buff_pos,
char *buff)
2268 const char *format_str;
2271 hours = *offset_time / 60;
2272 minutes = abs (*offset_time) % 60;
2274 format_str = with_colon ?
"%+2.2d:%2.2d" :
"%+2.2d%2.2d";
2275 sprintf (buff + buff_pos, format_str, hours, minutes);
2277 sprintf (buff + buff_pos,
"00000");
2287 if (!strncmp (str,
"hhmmss", 6)) {
2295 if (str[offset] ==
'.' || str[offset] ==
',') {
2302 if (strlen (str) > (
size_t) offset) {
2317 cob_decimal *second_fraction,
int *offset_time,
char *buff)
2322 int date_overflow = 0;
2324 const char *format_str;
2327 format_str =
"%2.2d:%2.2d:%2.2d";
2330 format_str =
"%2.2d%2.2d%2.2d";
2335 hours = time / 3600;
2337 minutes = time / 60;
2338 seconds = time % 60;
2341 if (offset_time ==
NULL) {
2346 hours -= *offset_time / 60;
2347 minutes -= *offset_time % 60;
2350 if (minutes >= 60) {
2353 }
else if (minutes < 0) {
2361 }
else if (hours < 0) {
2367 sprintf (buff, format_str, hours, minutes, seconds);
2375 add_z (buff_pos, buff);
2380 return date_overflow;
2387 size_t first_length;
2388 size_t second_length;
2391 for (i = 0; str[i] !=
'\0' && str[i] !=
'T'; ++i);
2398 if (first !=
NULL) {
2399 strncpy (first, str, first_length);
2400 first[first_length] =
'\0';
2404 if (second !=
NULL) {
2405 if (strlen (str) - i == 0) {
2408 second_length = strlen (str) - i - 1U;
2412 strncpy (second, str + i + 1U, second_length);
2413 second[second_length] =
'\0';
2420 cob_field *offset_time_field,
int *offset_time)
2422 if (offset_time_field !=
NULL) {
2441 if (current_time.offset_known) {
2442 *offset_time = current_time.utc_offset;
2482 *millenium =
cob_ctoi (date[*offset - 1]);
2496 *state = *state * 10 +
cob_ctoi (date[*offset - 1]);
2504 *state = *state * 10 +
cob_ctoi (date[*offset - 1]);
2511 if (*state != 160) {
2518 *state = *state * 10 +
cob_ctoi (date[*offset - 1]);
2536 return with_hyphens ?
test_char (
'-', date, offset) : 0;
2547 first_digit =
cob_ctoi (date[*offset - 1]);
2550 if (first_digit == 0) {
2558 *month = first_digit * 10 +
cob_ctoi (date[*offset - 1]);
2567 char max_first_digit;
2568 char max_second_digit;
2576 max_first_digit =
'0' + (char) (days_in_month / 10);
2577 max_second_digit =
'0' + (char) (days_in_month % 10);
2581 date[*offset], offset));
2582 first_digit = date[*offset - 1];
2585 if (first_digit ==
'0') {
2588 }
else if (first_digit != max_first_digit) {
2592 date[*offset], offset));
2601 char max_last_digit;
2607 state =
cob_ctoi (date[*offset - 1]);
2617 state = state * 10 +
cob_ctoi (date[*offset - 1]);
2623 }
else if (state != 36) {
2627 max_last_digit =
leap_year (year) ?
'6' :
'5';
2629 date[*offset], offset));
2645 char max_last_digit;
2649 first_digit =
cob_ctoi (date[*offset - 1]);
2652 if (first_digit == 0) {
2655 }
else if (first_digit != 5) {
2658 max_last_digit =
max_week (year) == 53 ?
'3' :
'2';
2660 date[*offset], offset));
2697 if (end_of_string) {
2699 while (str[offset] !=
'\0') {
2700 if (str[offset] !=
' ') {
2707 return str[offset] ==
'\0' ? 0 : offset + 1;
2714 const int end_of_string)
2740 first_digit =
cob_ctoi (time[*offset - 1]);
2742 if (first_digit != 2) {
2778 const char *time,
int *offset)
2782 if (num_decimal_places != 0) {
2784 for (i = 0; i < num_decimal_places; ++i) {
2809 if (time[*offset] ==
'+' || time[*offset] ==
'-') {
2815 }
else if (time[*offset] ==
'0') {
2843 const char decimal_point)
2853 decimal_point, time, &offset));
2860 #undef RETURN_IF_NOT_ZERO
2864 const char *final_part)
2866 const char *scanf_str = format.
with_hyphens ?
"%2d-%2d" :
"%2d%2d";
2870 if (
unlikely(!sscanf (final_part, scanf_str, &month, &day))) {
2882 if (
unlikely(!sscanf (final_part,
"%3d", &day))) {
2890 const char *final_part)
2892 int first_week_monday;
2893 const char *scanf_str = format.
with_hyphens ?
"W%2d-%1d" :
"W%2d%1d";
2899 if (
unlikely(!sscanf (final_part, scanf_str, &week, &day_of_week))) {
2902 total_days = first_week_monday + ((week - 1) * 7) + day_of_week - 1;
2909 const char *formatted_date)
2914 if (
unlikely(!sscanf (formatted_date,
"%4d", &year))) {
2919 return integer_of_mmdd (format, year, formatted_date + final_part_start);
2923 return integer_of_wwwd (format, year, formatted_date + final_part_start);
2932 const int whole_seconds,
2941 overflow =
format_time (time_fmt, whole_seconds, fractional_seconds,
2942 offset_time, formatted_time);
2943 format_date (date_fmt, days + overflow, formatted_date);
2945 sprintf (buff,
"%sT%s", formatted_date, formatted_time);
2952 char *formatted_datetime)
2957 int seconds_from_midnight
2962 mpz_set_ui (fractional_second->
value, (
unsigned long) time.
nanosecond);
2963 fractional_second->
scale = 9;
2972 fractional_second, offset_time, formatted_datetime);
3003 sign = mpz_sgn (pd1->
value);
3005 if (!mpz_sgn (pd2->
value)) {
3011 mpz_set_ui (pd1->
value, 1UL);
3023 if (sign < 0 && pd2->scale) {
3034 if (!mpz_cmp_ui (pd2->
value, 1UL)) {
3038 if (mpz_sgn (pd2->
value) < 0 && mpz_fits_slong_p (pd2->
value)) {
3041 n = mpz_get_ui (pd2->
value);
3048 mpz_set_ui (pd1->
value, 1UL),
3054 if (mpz_fits_ulong_p (pd2->
value)) {
3056 n = mpz_get_ui (pd2->
value);
3070 if (pd2->
scale == 1 && !mpz_cmp_ui (pd2->
value, 5UL)) {
3113 size = (short)mpz_sizeinbase (d1.
value, 10);
3114 if (d1.
scale > size) {
3115 size = (short)d1.
scale;
3117 scale = (short)d1.
scale;
3133 const int chkcurr,
const int anycase)
3136 unsigned char *begp;
3137 unsigned char *endp;
3143 size_t break_needed;
3146 unsigned char dec_pt;
3147 unsigned char cur_symb;
3154 for (pos = 0; pos < currency->
size; pos++, p++) {
3175 if (pos < currency->size - 1) {
3176 if (!memcmp (p,
"CR", (
size_t)2)) {
3179 if (!memcmp (p,
"DB", (
size_t)2)) {
3193 currcy_size = endp - begp;
3195 if (currcy_size >= srcfield->
size) {
3199 }
else if (chkcurr) {
3205 if (!srcfield->
size) {
3218 for (n = 0; n < (int)srcfield->
size; ++n, ++p) {
3249 if (begp && n < (
int)(srcfield->
size - currcy_size)) {
3250 if (!memcmp (p, begp, currcy_size)) {
3261 if (n == (
int)srcfield->
size) {
3265 for (; n < (int)srcfield->
size; ++n, ++p) {
3283 if (dec_seen || space_seen) {
3288 }
else if (!chkcurr) {
3311 if (n < (
int)srcfield->
size - 1) {
3312 if (*(p + 1) ==
'R' ||
3313 (anycase && *(p + 1) ==
'r')) {
3330 if (n < (
int)srcfield->
size - 1) {
3331 if (*(p + 1) ==
'B' ||
3332 (anycase && *(p + 1) ==
'b')) {
3357 return !strcmp (format,
"YYYYMMDD")
3358 || !strcmp (format,
"YYYY-MM-DD")
3359 || !strcmp (format,
"YYYYDDD")
3360 || !strcmp (format,
"YYYY-DDD")
3361 || !strcmp (format,
"YYYYWwwD")
3362 || !strcmp (format,
"YYYY-Www-D");
3369 ptrdiff_t format_offset;
3370 unsigned int decimal_places = 0;
3372 if (!strncmp (format,
"hhmmss", 6)) {
3375 }
else if (!strncmp (format,
"hh:mm:ss", 8)) {
3383 if (format[format_offset] == decimal_point) {
3385 format_offset += decimal_places + 1;
3392 if (strlen (format) > (
size_t) format_offset
3445 if (!mpz_sgn (d2.
value)) {
3448 mpz_set_ui (d1.
value, 0UL);
3496 }
else if (d1.
scale > 0) {
3497 sign = mpz_sgn (d1.
value);
3501 if (sign < 0 && mpz_sgn (
cob_mpzt)) {
3520 }
else if (d1.
scale > 0) {
3541 mpz_set_ui (d1.
value, 0UL);
3565 size = srcfield->
size;
3566 for (i = 0; i < size; ++i) {
3582 size = srcfield->
size;
3583 for (i = 0; i < size; ++i) {
3599 size = srcfield->
size;
3600 for (i = 0; i < size; ++i) {
3601 curr_field->
data[i] = srcfield->
data[size - i - 1];
3619 snprintf (buff,
sizeof(buff),
"%8.8u",
COB_MODULE_PTR->module_date);
3620 memcpy (curr_field->
data, buff, (
size_t)8);
3634 snprintf (buff,
sizeof(buff),
"%6.6u",
COB_MODULE_PTR->module_time);
3635 memcpy (curr_field->
data, buff, (
size_t)6);
3661 curr_field->
size = 0;
3662 curr_field->
data[0] =
' ';
3710 curr_field->
size = 0;
3711 curr_field->
data[0] =
' ';
3724 const int params, ...)
3735 va_start (args, params);
3739 for (i = 0; i <
params; ++i) {
3741 calcsize += f[i]->
size;
3748 p = curr_field->
data;
3749 for (i = 0; i <
params; ++i) {
3750 memcpy (p, f[i]->data, f[i]->size);
3763 const int params, ...)
3768 va_start (args, params);
3769 ret =
substitute (offset, length, params, &memcmp, args);
3777 const int params, ...)
3782 va_start (args, params);
3791 cob_field *srcfield,
const int direction)
3793 unsigned char *begin;
3800 for (i = 0; i < srcfield->
size; ++i) {
3801 if (srcfield->
data[i] !=
' ') {
3805 if (i == srcfield->
size) {
3806 curr_field->
size = 0;
3807 curr_field->
data[0] =
' ';
3811 begin = srcfield->
data;
3812 if (direction != 2) {
3813 for (; *begin ==
' '; ++begin) ;
3815 end = srcfield->
data + srcfield->
size - 1;
3816 if (direction != 1) {
3817 for (; *end ==
' '; end--) ;
3821 for (i = 0; begin <= end; ++begin, ++i) {
3822 curr_field->
data[i] = *begin;
3825 curr_field->
size = size;
3843 memcpy (curr_field->
data,
"00", (
size_t)2);
3846 field.
size = flen + 2;
3848 memcpy (curr_field->
data,
3850 memcpy (&(curr_field->
data[2]),
3866 *(curr_field->
data) =
' ';
3892 field.
size = strlen (buff);
3894 memcpy (curr_field->
data, buff, field.
size);
3902 const char *except_name;
3908 memset (curr_field->
data,
' ', (
size_t)31);
3911 if (except_name ==
NULL) {
3912 except_name =
"EXCEPTION-OBJECT";
3914 memcpy (curr_field->
data, except_name, strlen (except_name));
3928 memset (curr_field->
data,
' ', (
size_t)31);
3956 char buff[22] = {
'\0' };
3963 sprintf (buff,
"%4.4d%2.2d%2.2d%2.2d%2.2d%2.2d%2.2d",
3969 memcpy (curr_field->
data, buff, (
size_t)21);
3986 if (i < 1 || i > 256) {
3987 *curr_field->
data = 0;
3989 *curr_field->
data = (
unsigned char)i - 1;
4007 count = srcfield->
size;
4008 p = srcfield->
data + srcfield->
size - 1;
4009 for (; count > 0; count--, p--) {
4034 combined_datetime = &
d1;
4035 mpz_set_ui (combined_datetime->
value, (
unsigned long) srdays);
4036 combined_datetime->
scale = 0;
4046 hundred_thousand = &
d3;
4047 mpz_set_ui (hundred_thousand->
value, 100000UL);
4048 hundred_thousand->
scale = 0;
4085 memset (curr_field->
data,
'0', (
size_t)8);
4091 snprintf (buff, (
size_t)15,
"%4.4d%2.2d%2.2d", year, month, days);
4092 memcpy (curr_field->
data, buff, (
size_t)8);
4114 memset (curr_field->
data,
'0', (
size_t)7);
4119 snprintf (buff, (
size_t)15,
"%4.4d%3.3d", baseyear, days);
4121 memcpy (curr_field->
data, buff, (
size_t)7);
4136 year = indate / 10000;
4143 month = indate / 100;
4149 days = indate % 100;
4170 year = indate / 1000;
4176 days = indate % 1000;
4197 year = indate / 10000;
4203 month = indate / 100;
4208 days = indate % 100;
4226 year = indate / 1000;
4231 days = indate % 1000;
4291 if (!mpz_sgn (d1.
value)) {
4315 sign = mpz_sgn (d1.
value);
4326 if (sign < 0 && mpz_fits_sint_p (d1.
value)) {
4329 mpz_set_ui (d1.
value, 1UL);
4334 if (sign > 0 && mpz_fits_ulong_p (d1.
value)) {
4335 mpz_ui_pow_ui (d1.
value, 10UL, mpz_get_ui (d1.
value));
4342 mpz_set_ui (d2.
value, 10UL);
4357 if (mpz_sgn (d1.
value) <= 0) {
4367 if (!d1.
scale && !mpz_cmp_ui (d1.
value, 1UL)) {
4388 if (mpz_sgn (d1.
value) <= 0) {
4398 if (!d1.
scale && !mpz_cmp_ui (d1.
value, 1UL)) {
4433 mpz_set_si (d2.
value, -1L);
4435 mpz_set_ui (d3.
value, 1UL);
4463 mpz_set_si (d2.
value, -1L);
4465 mpz_set_ui (d3.
value, 1UL);
4475 if (!mpz_sgn (d1.
value)) {
4497 if (!mpz_sgn (d1.
value)) {
4566 if (mpz_sgn (d1.
value) < 0) {
4572 mpz_set_ui (d2.
value, 5UL);
4598 unsigned char *final_buff;
4602 size_t decimal_digits;
4606 size_t e_plus_minus;
4608 unsigned char dec_pt;
4628 for (n = 0; n < srcfield->
size; ++n, ++p) {
4642 exponent += (*p & 0x0F);
4647 final_buff[digits++] = *p;
4669 final_buff[0] =
'0';
4672 mpz_set_str (d1.
value, (
char *)final_buff, 10);
4674 if (!mpz_sgn (d1.
value)) {
4687 d1.
scale = decimal_digits + exponent;
4690 if (decimal_digits >= exponent) {
4691 d1.
scale = decimal_digits - exponent;
4693 exponent -= decimal_digits;
4702 d1.
scale = decimal_digits;
4720 sign = mpz_sgn (d1.
value);
4721 if (sign < 0 || mpz_sgn (d2.
value) <= 0 || d2.
scale != 0) {
4728 mpz_set_ui (d1.
value, 1UL);
4741 mpz_set_ui (d4.
value, 1UL);
4747 mpz_set_ui (d4.
value, 1UL);
4765 mpz_set_ui (d1.
value, 0UL);
4768 va_start (args, params);
4770 for (i = 0; i <
params; ++i) {
4791 va_start (args, params);
4795 for (i = 1; i <
params; ++i) {
4817 va_start (args, params);
4821 for (i = 1; i <
params; ++i) {
4842 va_start (args, params);
4845 for (i = 1; i <
params; ++i) {
4866 va_start (args, params);
4869 for (i = 1; i <
params; ++i) {
4889 va_start (args, params);
4897 mpz_set_ui (d2.
value, 2UL);
4914 va_start (args, params);
4927 for (i = 1; i <
params; ++i) {
4928 field_alloc[i] = va_arg (args,
cob_field *);
4932 qsort (field_alloc, (
size_t)params, (
size_t)
sizeof (
cob_field *),
4944 mpz_set_ui (d2.
value, 2UL);
4961 va_start (args, params);
4971 mpz_set_ui (d1.
value, 0UL);
4974 for (i = 0; i <
params; ++i) {
5003 va_start (args, params);
5035 va_start (args, params);
5044 srandom ((
unsigned int)seed);
5046 srand ((
unsigned int)seed);
5052 randnum = (int)random ();
5057 val = (double)randnum / (
double)RAND_MAX;
5058 memcpy (curr_field->
data, &val,
sizeof(val));
5062 #define GET_VARIANCE(num_args, args) \
5065 va_start (args, num_args); \
5066 calc_mean_of_args (num_args, args); \
5069 cob_decimal_set (&d5, &d1); \
5072 va_start (args, num_args); \
5073 calc_variance_of_args (num_args, args, &d5); \
5100 mpz_set_ui (d3.
value, 5UL);
5119 va_start (args, params);
5124 mpz_set_ui (d2.
value, 1UL);
5128 mpz_set_ui (d4.
value, 0UL);
5131 for (i = 1; i <
params; ++i) {
5163 va_start (args, params);
5177 timeptr = localtime (&t);
5178 current_year = 1900 + timeptr->tm_year;
5182 if (year < 0 || year > 99) {
5192 maxyear = current_year + interval;
5193 if (maxyear < 1700 || maxyear > 9999) {
5198 if (maxyear % 100 >= year) {
5199 year += 100 * (maxyear / 100);
5201 year += 100 * ((maxyear / 100) - 1);
5220 va_start (args, params);
5224 mmdd = year % 10000;
5232 maxyear = current_year + interval;
5234 if (year < 0 || year > 999999
5236 || (maxyear < 1700 || maxyear > 9999)) {
5242 if (maxyear % 100 >= year) {
5243 year += 100 * (maxyear / 100);
5245 year += 100 * ((maxyear / 100) - 1);
5266 va_start (args, params);
5278 if (year < 0 || year > 999999) {
5288 maxyear = current_year + interval;
5289 if (maxyear < 1700 || maxyear > 9999) {
5294 if (maxyear % 100 >= year) {
5295 year += 100 * (maxyear / 100);
5297 year += 100 * ((maxyear / 100) - 1);
5313 timeptr = localtime (&t);
5315 if (timeptr->tm_sec >= 60) {
5316 timeptr->tm_sec = 59;
5318 seconds = (timeptr->tm_hour * 3600) + (timeptr->tm_min * 60) +
5330 int is_datetime = 0;
5336 memcpy (format_str, format_field->
data, str_length);
5352 memcpy (time_str, time_field->
data, str_length);
5378 #if defined(_WIN32) || defined(__CYGWIN__) || defined(HAVE_LANGINFO_CODESET)
5384 #ifdef HAVE_LANGINFO_CODESET
5386 char *deflocale =
NULL;
5391 LCID localeid = LOCALE_USER_DEFAULT;
5400 #if defined(_WIN32) || defined(__CYGWIN__) || defined(HAVE_LANGINFO_CODESET)
5404 if (srcfield->
size < 8) {
5409 for (len = 0; len < 8; ++len, ++p) {
5412 indate += (*p -
'0');
5418 year = indate / 10000;
5423 month = indate / 100;
5427 days = indate % 100;
5431 #ifdef HAVE_LANGINFO_CODESET
5434 memset ((
void *)&tstruct, 0,
sizeof(
struct tm));
5435 tstruct.tm_year = year - 1900;
5436 tstruct.tm_mon = month;
5437 tstruct.tm_mday = days;
5444 deflocale = locale_buff;
5445 (void) setlocale (LC_TIME, deflocale);
5447 memset (buff2, 0,
sizeof(buff2));
5448 snprintf(buff2,
sizeof(buff2) - 1,
"%s", nl_langinfo(D_FMT));
5450 (void) setlocale (LC_ALL, cobglobptr->
cob_locale);
5452 strftime (buff,
sizeof(buff), buff2, &tstruct);
5454 memset ((
void *)&syst, 0,
sizeof(syst));
5455 syst.wYear = (
WORD)year;
5456 syst.wMonth = (
WORD)month;
5457 syst.wDay = (
WORD)days;
5465 for (p = (
unsigned char *)locale_buff; *p; ++p) {
5466 if (isalnum(*p) || *p ==
'_') {
5472 for (len = 0; len < WINLOCSIZE; ++len) {
5473 if (!strcmp(locale_buff, wintable[len].winlocalename)) {
5474 localeid = wintable[len].winlocaleid;
5478 if (len == WINLOCSIZE) {
5482 if (!GetDateFormat (localeid, DATE_SHORTDATE, &syst,
NULL, buff,
sizeof(buff))) {
5499 #if defined(_WIN32) || defined(__CYGWIN__) || defined(HAVE_LANGINFO_CODESET)
5506 char buff[LOCTIME_BUFSIZE] = {
'\0' };
5511 #if defined(_WIN32) || defined(__CYGWIN__) || defined(HAVE_LANGINFO_CODESET)
5515 if (srcfield->
size < 6) {
5520 for (len = 0; len < 6; ++len, ++p) {
5523 indate += (*p -
'0');
5529 hours = indate / 10000;
5530 if (hours < 0 || hours > 24) {
5534 minutes = indate / 100;
5535 if (minutes < 0 || minutes > 59) {
5538 seconds = indate % 100;
5539 if (seconds < 0 || seconds > 59) {
5543 if (locale_time (hours, minutes, seconds, locale_field, buff)) {
5560 #if defined(_WIN32) || defined(__CYGWIN__) || defined(HAVE_LANGINFO_CODESET)
5565 char buff[LOCTIME_BUFSIZE] = {
'\0' };
5570 #if defined(_WIN32) || defined(__CYGWIN__) || defined(HAVE_LANGINFO_CODESET)
5579 hours = indate / 3600;
5581 minutes = indate / 60;
5582 seconds = indate % 60;
5584 if (locale_time (hours, minutes, seconds, locale_field, buff)) {
5600 #ifdef HAVE_LOCALECONV
5609 #ifdef HAVE_LOCALECONV
5611 size = strlen (p->mon_decimal_point);
5619 memcpy (curr_field->
data, p->mon_decimal_point, size);
5621 curr_field->
size = 0;
5622 curr_field->
data[0] = 0;
5635 #ifdef HAVE_LOCALECONV
5644 #ifdef HAVE_LOCALECONV
5646 size = strlen (p->decimal_point);
5654 memcpy (curr_field->
data, p->decimal_point, size);
5656 curr_field->
size = 0;
5657 curr_field->
data[0] = 0;
5670 #ifdef HAVE_LOCALECONV
5679 #ifdef HAVE_LOCALECONV
5681 size = strlen (p->mon_thousands_sep);
5689 memcpy (curr_field->
data, p->mon_thousands_sep, size);
5691 curr_field->
size = 0;
5692 curr_field->
data[0] = 0;
5705 #ifdef HAVE_LOCALECONV
5714 #ifdef HAVE_LOCALECONV
5716 size = strlen (p->thousands_sep);
5724 memcpy (curr_field->
data, p->thousands_sep, size);
5726 curr_field->
size = 0;
5727 curr_field->
data[0] = 0;
5740 #ifdef HAVE_LOCALECONV
5749 #ifdef HAVE_LOCALECONV
5751 size = strlen (p->currency_symbol);
5759 memcpy (curr_field->
data, p->currency_symbol, size);
5761 curr_field->
size = 0;
5762 curr_field->
data[0] = 0;
5820 mpz_ui_pow_ui (d1.
value, 2UL, expo);
5828 mpz_ui_pow_ui (d1.
value, 10UL, expo);
5850 mpz_ui_pow_ui (d1.
value, 10UL, expo);
5878 memset (curr_field->
data, 255, size);
5886 memset (curr_field->
data, 255, size);
5897 mpz_ui_pow_ui (d1.
value, 2UL, expo);
5905 mpz_ui_pow_ui (d1.
value, 10UL, expo);
5922 mpz_ui_pow_ui (d1.
value, 10UL, expo);
5955 va_start (args, params);
5959 locale_field = va_arg (args,
cob_field *);
5961 locale_field =
NULL;
5973 for (p = f1->
data + size - 1U; p != f1->
data; --p) {
5980 memcpy (p1, f1->
data, size2);
5984 for (p = f2->
data + size - 1U; p != f2->
data; --p) {
5991 memcpy (p2, f2->
data, size2);
5994 if (!locale_field->
size) {
5997 #ifdef HAVE_SETLOCALE
6000 (
size_t)(locale_field->
size + 1U));
6001 (void) setlocale (LC_COLLATE, deflocale);
6007 ret = strcoll ((
char *)p1, (
char *)p2);
6009 curr_field->
data[0] =
'<';
6010 }
else if (ret > 0) {
6011 curr_field->
data[0] =
'>';
6013 curr_field->
data[0] =
'=';
6018 #ifdef HAVE_SETLOCALE
6020 (void) setlocale (LC_ALL, cobglobptr->
cob_locale);
6028 curr_field->
data[0] =
' ';
6039 size_t field_length =
6046 memcpy (format_str, format_field->
data, field_length);
6061 memcpy (curr_field->
data, buff, field_length);
6066 memset (curr_field->
data,
' ', strlen (format_str));
6077 const int params, ...)
6084 size_t field_length;
6089 int use_system_offset;
6091 int *offset_time_ptr;
6094 if (!(params == 3 || params == 4)) {
6101 va_start (args, params);
6103 format_field = va_arg (args,
cob_field *);
6104 time_field = va_arg (args,
cob_field *);
6106 offset_time_field = va_arg (args,
cob_field *);
6108 offset_time_field =
NULL;
6110 use_system_offset = va_arg (args,
int);
6116 memcpy (format_str, format_field->
data, field_length);
6130 fractional_seconds = &
d2;
6138 if (use_system_offset) {
6145 offset_time_ptr = &offset_time;
6149 format_time (format, whole_seconds, fractional_seconds, offset_time_ptr,
6152 memcpy (curr_field->
data, buff, field_length);
6157 if (format_str !=
NULL) {
6158 memset (curr_field->
data,
' ', strlen (format_str));
6170 const int params, ...)
6178 size_t field_length;
6187 int use_system_offset;
6189 int *offset_time_ptr;
6192 if (!(params == 4 || params == 5)) {
6199 va_start (args, params);
6202 days_field = va_arg (args,
cob_field *);
6203 time_field = va_arg (args,
cob_field *);
6205 offset_time_field = va_arg (args,
cob_field *);
6207 offset_time_field =
NULL;
6209 use_system_offset = va_arg (args,
int);
6214 memcpy (fmt_str, fmt_field->
data, field_length);
6236 if (use_system_offset) {
6243 offset_time_ptr = &offset_time;
6250 fractional_seconds = &
d1;
6254 fractional_seconds, offset_time_ptr, buff);
6256 memcpy (curr_field->
data, buff, (
size_t) field_length);
6261 if (fmt_str !=
NULL) {
6262 memset (curr_field->
data,
' ', strlen (fmt_str));
6276 char *datetime_format_str = (
char *)format_field->
data;
6281 char *formatted_datetime = (
char *)datetime_field->data;
6284 int time_part_offset;
6306 if (date_present && time_present) {
6307 split_around_t (datetime_format_str, date_format_str, time_format_str);
6308 }
else if (date_present) {
6314 if (date_present && time_present) {
6315 split_around_t (formatted_datetime, formatted_date, formatted_time);
6316 }
else if (date_present) {
6326 time_part_offset = strlen (formatted_date) + 1;
6328 time_part_offset = 0;
6334 formatted_date, !time_present);
6335 if (error_pos != 0) {
6343 if (error_pos != 0) {
6364 char *format_field_data = (
char *) format_field->
data;
6366 char *date_field_data = (
char *) date_field->data;
6411 size_t field_length =
6420 strncpy (format_str, (
char *) format_field->
data, field_length);
6430 memset (curr_field->
data,
' ', field_length);
6441 memcpy (curr_field->
data, formatted_date, field_length);
6471 const int params, ...)
6534 mpz_clear (d5.
value);
6535 mpz_clear (d4.
value);
6536 mpz_clear (d3.
value);
6537 mpz_clear (d2.
value);
6538 mpz_clear (d1.
value);
6575 mpz_init2 (d1.
value, 1536UL);
6577 mpz_init2 (d2.
value, 1536UL);
6579 mpz_init2 (d3.
value, 1536UL);
6581 mpz_init2 (d4.
value, 1536UL);
6583 mpz_init2 (d5.
value, 1536UL);
6600 #undef COB_DATETIMESTR_LEN
6601 #undef COB_TIMESTR_LEN
6602 #undef COB_DATESTR_LEN
static void make_field_entry(cob_field *f)
cob_field * cob_intr_log10(cob_field *srcfield)
static void get_min_and_max_of_args(const int num_args, va_list args, cob_field **min, cob_field **max)
void cob_free(void *mptr)
cob_field * cob_intr_integer_of_day(cob_field *srcfield)
cob_field * cob_intr_fraction_part(cob_field *srcfield)
static int rest_is_z(const char *str)
unsigned int cob_orig_line
#define COB_TYPE_NATIONAL_EDITED
cob_field * cob_intr_concatenate(const int offset, const int length, const int params,...)
cob_field * cob_intr_reverse(const int offset, const int length, cob_field *srcfield)
#define COB_FERROR_CODEGEN
static void cob_alloc_set_field_int(const int val)
cob_field * cob_intr_present_value(const int params,...)
#define COB_FIELD_SCALE(f)
cob_field * cob_intr_module_source(void)
cob_field * cob_intr_integer_of_formatted_date(cob_field *format_field, cob_field *date_field)
cob_file * cob_error_file
static cob_field * move_field
void cob_decimal_mul(cob_decimal *, cob_decimal *)
static const int leap_days[]
static int get_day_of_week(const int day_num)
cob_field * cob_intr_cos(cob_field *srcfield)
cob_field * cob_intr_year_to_yyyy(const int params,...)
cob_field * cob_intr_mod(cob_field *srcfield1, cob_field *srcfield2)
static void cob_mpf_acos(mpf_t dst_val, const mpf_t src_val)
cob_field * cob_intr_substitute_case(const int offset, const int length, const int params,...)
cob_field * cob_intr_variance(const int num_args,...)
static int num_leading_nonspace(const char *str)
static int test_date_end(const struct date_format format, const char *date, const int year, int *offset)
static size_t get_substituted_size(cob_field *original, cob_field **matches, cob_field **reps, const int numreps, int(*cmp_func)(const void *, const void *, size_t))
#define COB_TYPE_NUMERIC_PACKED
cob_field * cob_intr_integer(cob_field *srcfield)
static int valid_integer_date(const int days)
static cob_u32_t integer_of_date(const int, const int, const int)
static void get_interval_and_current_year_from_args(const int num_args, va_list args, int *const interval, int *const current_year)
static void cob_alloc_set_field_uint(const cob_u32_t val)
static int test_z_presence(const char *time, int *offset)
cob_field * cob_intr_asin(cob_field *srcfield)
cob_field * cob_intr_exception_statement(void)
#define COB_FIELD_IS_NUMERIC(f)
void cob_move(cob_field *, cob_field *)
cob_field * cob_intr_formatted_date(const int offset, const int length, cob_field *format_field, cob_field *days_field)
static void format_datetime(const struct date_format date_fmt, const struct time_format time_fmt, const int days, const int whole_seconds, cob_decimal *fractional_seconds, int *offset_time, char *buff)
cob_field * cob_intr_atan(cob_field *srcfield)
static const int leap_month_days[]
static void date_of_integer(int days, int *year, int *month, int *day)
#define COB_TYPE_ALPHANUMERIC
cob_field * cob_intr_pi(void)
static cob_u32_t days_up_to_year(const int year)
static void split_around_t(const char *str, char *first, char *second)
cob_field * cob_intr_range(const int params,...)
static const char cob_log_half_str[]
static cob_u32_t integer_of_ddd(const int year, const char *final_part)
static void cob_mpf_tan(mpf_t dst_val, const mpf_t src_val)
void cob_decimal_pow(cob_decimal *pd1, cob_decimal *pd2)
static cob_u32_t integer_of_day(const int year, const int days)
#define COB_FIELD_TYPE(f)
static const cob_field_attr const_alpha_attr
static cob_field * substitute(const int offset, const int length, const int params, int(*cmp_func)(const void *, const void *, size_t), va_list args)
cob_field * cob_intr_date_of_integer(cob_field *srcdays)
cob_field * cob_intr_day_to_yyyyddd(const int params,...)
static int test_week(const char *date, const int year, int *offset)
static COB_INLINE COB_A_INLINE int in_range(const int min, const int max, const int val)
static mpf_t cob_mpft_get
cob_field * cob_intr_ord_max(const int params,...)
cob_field * cob_intr_min(const int params,...)
#define COB_DATETIMESTR_LEN
int cob_valid_time_format(const char *format, const char decimal_point)
static int get_iso_week_one(const int day_num, const int day_of_year)
cob_field * cob_intr_seconds_past_midnight(void)
static unsigned int int_pow(const unsigned int base, unsigned int power)
cob_field * cob_intr_char_national(cob_field *srcfield)
cob_field * cob_intr_mon_thousands_sep(void)
void cob_exit_intrinsic(void)
static void cob_alloc_set_field_str(char *str, const int offset, const int length)
cob_field * cob_intr_tan(cob_field *srcfield)
#define COB_FERROR_FUNCTION
cob_field * cob_intr_display_of(const int offset, const int length, const int params,...)
static int test_year(const char *date, int *offset, int *state)
static int decimal_places_for_seconds(const char *str, const ptrdiff_t point_pos)
void cob_decimal_set_field(cob_decimal *, cob_field *)
cob_field * cob_intr_date_to_yyyymmdd(const int params,...)
static int test_decade(const char *date, int *offset, int *state)
const char * cob_orig_paragraph
static int valid_day_of_year(const int year, const int day)
cob_field * cob_intr_lower_case(const int offset, const int length, cob_field *srcfield)
cob_field * cob_intr_sin(cob_field *srcfield)
static cob_u32_t curr_entry
static void cob_mpf_log(mpf_t dst_val, const mpf_t src_val)
#define COB_ATTR_INIT(u, v, x, y, z)
static int test_formatted_date(const struct date_format format, const char *date, const int end_of_string)
void cob_get_indirect_field(cob_field *f)
static int valid_day_of_month(const int year, const int month, const int day)
cob_field * cob_intr_log(cob_field *srcfield)
static int leap_year(const int year)
static cob_u32_t integer_of_mmdd(const struct date_format format, const int year, const char *final_part)
static cob_field * numval(cob_field *srcfield, cob_field *currency, const enum numval_type type)
static int valid_time(const int seconds_from_midnight)
cob_field * cob_intr_module_caller_id(void)
cob_field * cob_intr_sum(const int params,...)
static int rest_is_offset_format(const char *str, const int with_colon)
static void cob_alloc_field(cob_decimal *d)
static void cob_mpf_asin(mpf_t dst_val, const mpf_t src_val)
cob_field * cob_intr_module_formatted_date(void)
static void cob_mpf_atan(mpf_t dst_val, const mpf_t src_val)
int cob_get_switch(const int n)
static int test_char(const char wanted, const char *str, int *offset)
cob_field * cob_intr_substitute(const int offset, const int length, const int params,...)
#define COB_FIELD_IS_NATIONAL(f)
cob_field * cob_intr_locale_compare(const int params,...)
unsigned char * file_status
#define COB_FLAG_HAVE_SIGN
cob_field * cob_intr_binop(cob_field *f1, const int op, cob_field *f2)
cob_field * cob_intr_ord_min(const int params,...)
static cob_u32_t integer_of_formatted_date(const struct date_format format, const char *formatted_date)
cob_field * cob_intr_e(void)
static cob_field * cob_mod_or_rem(cob_field *f1, cob_field *f2, const int func_is_rem)
int cob_get_int(cob_field *)
cob_field * cob_intr_integer_of_boolean(cob_field *srcfield)
#define COB_TYPE_NATIONAL
cob_field * cob_intr_midrange(const int params,...)
cob_field * cob_intr_abs(cob_field *srcfield)
cob_field * cob_intr_module_time(void)
void cob_field_to_string(const cob_field *, void *, const size_t)
static int test_formatted_time(const struct time_format format, const char *time, const char decimal_point)
static void seconds_from_formatted_time(const struct time_format format, const char *str, cob_decimal *seconds_decimal)
static int valid_month(const int month)
static void format_field(cob_screen *s)
static int valid_decimal_time(cob_decimal *seconds_from_midnight)
#define RETURN_IF_NOT_ZERO(expr)
void cob_put_indirect_field(cob_field *f)
static void calc_ref_mod(cob_field *f, const int offset, const int length)
void cob_fatal_error(const int fatal_error)
static int test_offset_time(const struct time_format format, const char *time, int *offset)
cob_field * cob_intr_test_day_yyyyddd(cob_field *srcfield)
static void format_as_yyyyddd(const int day_num, const int with_hyphen, char *buff)
cob_field * cob_intr_module_date(void)
cob_field * cob_intr_module_path(void)
#define COB_TYPE_NUMERIC_FLOAT
const char * cob_get_exception_name(void)
cob_field * cob_intr_national_of(const int offset, const int length, const int params,...)
cob_field * cob_intr_mean(const int params,...)
cob_field * cob_intr_exception_file_n(void)
cob_field * cob_intr_exception_location(void)
static cob_global * cobglobptr
#define COB_FIELD_REAL_BINARY(f)
static void format_date(const struct date_format format, const int days, char *buff)
#define COB_FIELD_INIT(x, y, z)
static void day_of_integer(int days, int *year, int *day)
cob_field * cob_intr_char(cob_field *srcfield)
cob_field * cob_intr_exp(cob_field *srcfield)
cob_field * cob_intr_boolean_of_integer(cob_field *f1, cob_field *f2)
static void cob_decimal_get_mpf(mpf_t dst, const cob_decimal *d)
cob_field * cob_intr_exception_file(void)
static void cob_mpf_log10(mpf_t dst_val, const mpf_t src_val)
int cob_check_numval(const cob_field *srcfield, const cob_field *currency, const int chkcurr, const int anycase)
void cob_gmp_free(void *)
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
static void calc_variance_of_args(const int n, va_list numbers, cob_decimal *mean)
cob_field * cob_intr_lcl_time_from_secs(const int offset, const int length, cob_field *srcfield, cob_field *locale_field)
cob_field * cob_intr_numval(cob_field *srcfield)
cob_field * cob_intr_module_id(void)
static int test_hour(const char *time, int *offset)
int cob_valid_date_format(const char *format)
cob_field * cob_intr_random(const int params,...)
static const char cob_pi_str[]
static const int normal_month_days[]
int cob_decimal_cmp(cob_decimal *, cob_decimal *)
static mpf_t cob_sqrt_two
cob_field * cob_intr_exception_status(void)
void cob_decimal_add(cob_decimal *, cob_decimal *)
cob_field * cob_intr_day_of_integer(cob_field *srcdays)
static struct calc_struct * calc_base
cob_field * cob_intr_acos(cob_field *srcfield)
static void format_current_date(const struct date_format date_fmt, const struct time_format time_fmt, char *formatted_datetime)
cob_field * cob_intr_factorial(cob_field *srcfield)
cob_field * cob_intr_test_numval(cob_field *srcfield)
cob_field * cob_intr_test_numval_c(cob_field *srcfield, cob_field *currency)
#define COB_FIELD_BINARY_TRUNC(f)
#define COB_TYPE_NUMERIC_BINARY
cob_field * cob_intr_locale_time(const int offset, const int length, cob_field *srcfield, cob_field *locale_field)
cob_field * cob_intr_currency_symbol(void)
void cob_set_exception(const int id)
#define GET_VARIANCE(num_args, args)
static int test_two_zeroes(const char *str, int *offset)
static int try_get_valid_offset_time(const struct time_format time_format, cob_field *offset_time_field, int *offset_time)
cob_field * cob_intr_sqrt(cob_field *srcfield)
static void cob_trim_decimal(cob_decimal *d)
static int int_strncasecmp(const void *s1, const void *s2, size_t n)
cob_field * cob_intr_combined_datetime(cob_field *srcdays, cob_field *srctime)
cob_field * cob_intr_when_compiled(const int offset, const int length, cob_field *f)
static int max_week(int year)
static int in_last_n_chars(const cob_field *field, const size_t n, const int i)
static void add_offset_time(const int with_colon, int const *offset_time, const ptrdiff_t buff_pos, char *buff)
#define COB_TYPE_ALPHANUMERIC_EDITED
cob_field * cob_switch_value(const int id)
cob_field * cob_intr_ord(cob_field *srcfield)
#define COB_TYPE_NUMERIC_DISPLAY
cob_field * cob_intr_num_decimal_point(void)
cob_field * cob_intr_locale_date(const int offset, const int length, cob_field *srcfield, cob_field *locale_field)
void cob_decimal_div(cob_decimal *, cob_decimal *)
void cob_init_intrinsic(cob_global *lptr)
static int valid_year(const int year)
static int test_day_of_week(const char *date, int *offset)
static int test_century(const char *date, int *offset, int *state)
cob_field * cob_intr_stored_char_length(cob_field *srcfield)
int cob_cmp(cob_field *f1, cob_field *f2)
static int test_less_than_60(const char *time, int *offset)
const char * cob_orig_section
static int test_colon_presence(const int with_colons, const char *time, int *offset)
int cob_valid_datetime_format(const char *format, const char decimal_point)
cob_field * cob_intr_current_date(const int offset, const int length)
void cob_decimal_move_temp(cob_field *src, cob_field *dst)
cob_field * cob_intr_median(const int params,...)
static int test_month(const char *date, int *offset, int *month)
static int test_w_presence(const char *date, int *offset)
static void cob_mpf_cos(mpf_t dst_val, const mpf_t src_val)
cob_field * cob_intr_upper_case(const int offset, const int length, cob_field *srcfield)
void cob_decimal_sub(cob_decimal *, cob_decimal *)
const char * cob_orig_statement
unsigned int cob_got_exception
static void get_fractional_seconds(cob_field *time, cob_decimal *fraction)
cob_field * cob_intr_test_date_yyyymmdd(cob_field *srcfield)
cob_field * cob_intr_formatted_datetime(const int offset, const int length, const int params,...)
cob_field * cob_intr_formatted_time(const int offset, const int length, const int params,...)
static void add_decimal_digits(int decimal_places, cob_decimal *second_fraction, char *buff, ptrdiff_t *buff_pos)
static cob_field * curr_field
static int test_char_cond(const int cond, int *offset)
cob_field * cob_intr_numval_c(cob_field *srcfield, cob_field *currency)
static int test_time_end(const struct time_format format, const char *time, int *offset)
cob_field * cob_intr_lowest_algebraic(cob_field *srcfield)
static int cob_check_numval_f(const cob_field *srcfield)
int cob_decimal_get_field(cob_decimal *, cob_field *, const int)
static int format_time(const struct time_format format, int time, cob_decimal *second_fraction, int *offset_time, char *buff)
#define COB_TYPE_NUMERIC_DOUBLE
static cob_u32_t integer_of_wwwd(const struct date_format format, const int year, const char *final_part)
static int test_unit_year(const char *date, int *offset, int *state)
static int test_millenium(const char *date, int *offset, int *millenium)
strict implicit external call column overflow
cob_field * cob_intr_formatted_current_date(const int offset, const int length, cob_field *format_field)
static void calc_mean_of_args(const int num_args, va_list args)
const cob_field_attr * attr
cob_field * cob_intr_exception_location_n(void)
cob_field * cob_intr_numval_f(cob_field *srcfield)
static int valid_day_and_format(const int day, const char *format)
struct cob_time cob_get_current_date_and_time(void)
cob_field * cob_intr_exp10(cob_field *srcfield)
cob_field * cob_intr_highest_algebraic(cob_field *srcfield)
static void format_as_yyyymmdd(const int day_num, const int with_hyphen, char *buff)
static struct time_format parse_time_format_string(const char *str)
cob_field * cob_intr_mon_decimal_point(void)
static void format_as_yyyywwwd(const int day_num, const int with_hyphen, char *buff)
static int valid_offset_time(const int offset)
void * cob_malloc(const size_t size)
cob_field * cob_intr_annuity(cob_field *srcfield1, cob_field *srcfield2)
static const char cob_sqrt_two_str[]
const char * cob_orig_program_id
static void cob_mpf_sin(mpf_t dst_val, const mpf_t src_val)
static void add_z(const ptrdiff_t buff_pos, char *buff)
static void substitute_matches(cob_field *original, cob_field **matches, cob_field **reps, const int numreps, int(*cmp_func)(const void *, const void *, size_t), unsigned char *replaced_begin)
#define COB_FIELD_HAVE_SIGN(f)
cob_field * cob_intr_max(const int params,...)
cob_field * cob_intr_length(cob_field *srcfield)
static mpf_t cob_log_half
static int test_second(const char *time, int *offset)
#define COB_NATIONAL_SIZE
static int * get_system_offset_time_ptr(int *const offset_time)
static struct date_format parse_date_format_string(const char *format_str)
cob_field * cob_intr_byte_length(cob_field *srcfield)
static COB_INLINE COB_A_INLINE int test_char_in_range(const char min, const char max, const char ch, int *offset)
static void cob_alloc_set_field_spaces(const int n)
cob_field * cob_intr_seconds_from_formatted_time(cob_field *format_field, cob_field *time_field)
static COB_INLINE COB_A_INLINE void cob_decimal_set(cob_decimal *dst, const cob_decimal *src)
cob_field * cob_intr_num_thousands_sep(void)
static int test_minute(const char *time, int *offset)
static int days_in_year(const int year)
static void get_iso_week(const int, int *, int *)
static int test_hyphen_presence(const int with_hyphens, const char *date, int *offset)
cob_field * cob_intr_trim(const int offset, const int length, cob_field *srcfield, const int direction)
cob_field * cob_intr_standard_compare(const int params,...)
cob_field * cob_intr_rem(cob_field *srcfield1, cob_field *srcfield2)
#define COB_FIELD_DIGITS(f)
static const int normal_days[]
static int test_day_of_month(const char *date, const int year, const int month, int *offset)
static void cob_decimal_set_mpf(cob_decimal *d, const mpf_t src)
strict implicit external call params
static int test_no_trailing_junk(const char *str, int offset, int end_of_string)
static void cob_mpf_exp(mpf_t dst_val, const mpf_t src_val)
cob_field * cob_intr_standard_deviation(const int num_args,...)
cob_field * cob_intr_integer_part(cob_field *srcfield)
cob_field * cob_intr_sign(cob_field *srcfield)
#define COB_TYPE_NUMERIC_EDITED
cob_field * cob_intr_test_formatted_datetime(cob_field *format_field, cob_field *datetime_field)
cob_field * cob_intr_test_numval_f(cob_field *srcfield)
#define COB_FIELD_SIZE(f)
static int at_cr_or_db(const cob_field *srcfield, const int pos)
static int test_decimal_places(const int num_decimal_places, const char decimal_point, const char *time, int *offset)
static int test_day_of_year(const char *date, const int year, int *offset)
static COB_INLINE COB_A_INLINE int test_digit(const unsigned char ch, int *offset)
static int comp_field(const void *m1, const void *m2)
cob_field * cob_intr_integer_of_date(cob_field *srcfield)