43 static const int pic_digits[] = { 2, 4, 7, 9, 12, 14, 16, 18 };
48 const unsigned char *p;
58 for (p = (
const unsigned char *)name; *p; p++) {
59 if (!isdigit ((
int)(*p))) {
62 level = level * 10 + (*p -
'0');
76 if (level < 1 || level > 49) {
85 cb_error_x (x,
_(
"Invalid level number '%s'"), name);
120 last_real_field = last_field;
137 if (last_field->
level == 77 && f->
level != 01 &&
139 cb_error_x (name,
_(
"Level number must begin with 01 or 77"));
154 (last_field && f->
level == last_field->
level &&
163 if (last_field && last_field->
level == 88) {
164 last_field = last_field->
parent;
176 cb_error_x (name,
_(
"Level number must begin with 01 or 77"));
178 }
else if (f->
level == 66) {
185 }
else if (f->
level == 88) {
204 if (cb_relax_level_hierarchy && p->
level < f->
level) {
208 if (cb_relax_level_hierarchy
213 _(
"No previous data item of level %02d"),
229 _(
"No previous data item of level %02d"),
262 cb_error_x (x,
_(
"'%s' cannot be qualified here"), name);
268 cb_error_x (x,
_(
"'%s' cannot be subscripted here"), name);
275 if (strcasecmp (f->
name, name) == 0) {
287 for (; items; items =
CB_CHAIN (items)) {
301 cb_error_x (x,
_(
"Level number of REDEFINES entries must be identical"));
305 cb_error_x (x,
_(
"Level number of REDEFINES entry cannot be 66 or 88"));
309 if (!cb_indirect_redefines && f->
redefines) {
325 cb_error_x (x,
_(
"BLANK ZERO not compatible with USAGE"));
328 cb_error_x (x,
_(
"SIGN clause not compatible with USAGE"));
350 strcpy (pic,
"X(1)");
363 memset (pic, 0,
sizeof (pic));
370 pp += sprintf (pp,
"9(%d)", vorint);
373 sprintf (pp,
"V9(%d)", lp->
scale);
383 sprintf (pic,
"X(%d)", (
int)lp->
size);
391 cb_error_x (x,
_(
"PICTURE clause required for '%s'"),
396 cb_error_x (x,
_(
"PICTURE clause required for '%s'"),
401 cb_error_x (x,
_(
"A non-numeric literal is expected for '%s'"),
407 cb_warning_x (x,
_(
"Defining implicit picture size %d for '%s'"),
410 sprintf (pic,
"X(%d)", vorint);
438 if (f->
level != 01) {
470 if (f->
level == 77) {
483 cb_error_x (x,
_(
"'%s' EXTERNAL can only be specified in WORKING-STORAGE section"),
506 if (f->
level == 66) {
519 if ((!
cb_verify (cb_top_level_occurs_clause,
"01/77 OCCURS") &&
532 cb_depend_check =
cb_list_add (cb_depend_check, x);
534 if (!cb_complex_odo) {
540 _(
"'%s' cannot have the OCCURS clause due to '%s'"),
553 cb_warning_x (x,
_(
"The original definition '%s' should not have OCCURS"),
560 cb_error_x (x,
_(
"REDEFINES must follow the original definition"));
571 _(
"The original definition '%s' cannot be variable length"),
592 cb_error_x (x,
_(
"SCREEN group item '%s' has invalid clause"),
636 if (f->
pic ==
NULL && need_picture != 0) {
641 if (f->
pic !=
NULL && need_picture == 0) {
642 cb_error_x (x,
_(
"'%s' cannot have PICTURE clause"),
775 pstr = (
unsigned char *)(f->
pic->
str);
779 memcpy (pstr, (
void *)&vorint,
sizeof(
int));
785 memcpy (pstr, (
void *)&vorint,
sizeof(int));
789 memcpy (pstr, (
void *)&vorint,
sizeof(
int));
793 memcpy (pstr, (
void *)&vorint,
sizeof(
int));
799 pstr = (
unsigned char *)(f->
pic->
str);
803 memcpy (pstr, (
void *)&vorint,
sizeof(
int));
809 memcpy (pstr, (
void *)&vorint,
sizeof(
int));
826 cb_error_x (x,
_(
"Only level 88 item may have multiple values"));
830 for (p = f; p; p = p->
parent) {
832 cb_error_x (x,
_(
"Entries under REDEFINES cannot have a VALUE clause"));
835 cb_warning_x (x,
_(
"Initial VALUE clause ignored for EXTERNAL item"));
862 #ifndef WORDS_BIGENDIAN
900 strcpy (pic,
"9(36)");
906 #ifndef WORDS_BIGENDIAN
924 f->
size = ((size <= 2) ? 1 :
926 (size <= 9) ? 4 : (size <= 18) ? 8 : 16);
933 f->
size = ((size <= 4) ? 2 :
934 (size <= 9) ? 4 : (size <= 18) ? 8 : 16);
1101 if (f->
level == 66) {
1125 if (c->
level != 66 &&
1128 if (cb_larger_redefines_ok) {
1130 _(
"Size of '%s' larger than size of '%s'"),
1143 _(
"Size of '%s' larger than size of '%s'"),
1153 cb_verify (cb_synchronized_clause,
"SYNC")) {
1171 align_size = c->
size;
1176 align_size =
sizeof (int);
1182 align_size =
sizeof (
void *);
1187 if (c->
offset % align_size != 0) {
1188 pad = align_size - (c->
offset % align_size);
1206 _(
"'%s' cannot be larger than %d bytes"),
1209 f->
size = (int) size_check;
1218 f->
size = ((size <= 2) ? 1 : (size <= 4) ? 2 :
1219 (size <= 7) ? 3 : (size <= 9) ? 4 :
1220 (size <= 12) ? 5 : (size <= 14) ? 6 :
1221 (size <= 16) ? 7 : (size <= 19) ? 8 :
1222 (size <= 21) ? 9 : (size <= 24) ? 10 :
1223 (size <= 26) ? 11 : (size <= 28) ? 12 :
1224 (size <= 31) ? 13 : (size <= 33) ? 14 :
1225 (size <= 36) ? 15 : 16);
1235 _(
"'%s' binary field cannot be larger than %d digits"),
1243 _(
"'%s' binary field cannot be larger than %d digits"),
1254 _(
"'%s' cannot be larger than %d bytes"),
1269 f->
size =
sizeof (int);
1272 f->
size =
sizeof (float);
1275 f->
size =
sizeof (double);
1295 f->
size =
sizeof (
void *);
1309 if (cb_larger_redefines_ok) {
1408 cb_error_x (x,
_(
"Literal type does not match data type"));
1441 last_real_field =
NULL;
unsigned int flag_justified
static void compute_binary_size(struct cb_field *f, const int size)
#define CB_NUMERIC_LITERAL_P(x)
unsigned int flag_real_binary
void cb_error_x(cb_tree x, const char *fmt,...)
void cobc_abort_pr(const char *fmt,...)
cb_tree cb_build_filler(void)
unsigned int flag_any_length
void * cobc_parse_malloc(const size_t size)
void cb_warning_x(cb_tree x, const char *fmt,...)
#define COB_MAX_FIELD_SIZE
struct cb_field * children
unsigned int flag_filler_ref
unsigned int flag_synchronized
unsigned int cb_verify(const enum cb_support, const char *)
cb_tree cb_build_field_tree(cb_tree level, cb_tree name, struct cb_field *last_field, enum cb_storage storage, struct cb_file *fn, const int expl_level)
char * cb_name(cb_tree x)
cb_tree cb_build_field(cb_tree name)
struct cb_field * cb_resolve_redefines(struct cb_field *field, cb_tree redefines)
struct cb_field * cb_field_variable_size(const struct cb_field *f)
static int compute_size(struct cb_field *f)
unsigned char flag_is_global
void redefinition_warning(cb_tree x, cb_tree y)
static int occur_align_size
cb_tree cb_build_picture(const char *str)
unsigned int flag_no_field
void level_except_error(cb_tree x, const char *clause)
static unsigned int validate_field_1(struct cb_field *f)
unsigned int flag_item_78
static void validate_field_clauses(cb_tree x, struct cb_field *f)
unsigned int flag_is_verified
enum cb_category category
unsigned int flag_sign_leading
#define CB_BINARY_SIZE_2_4_8
static struct cb_field * last_real_field
EC ARGUMENT EC EC BOUND EC BOUND EC BOUND EC BOUND TABLE EC DATA EC DATA EC DATA PTR NULL
#define CB_BYTEORDER_BIG_ENDIAN
unsigned int flag_external
static unsigned int check_picture_item(cb_tree x, struct cb_field *f)
struct cb_field * cb_validate_78_item(struct cb_field *f, const cob_u32_t no78add)
int validate_move(cb_tree, cb_tree, const unsigned int)
unsigned int flag_invalid
unsigned int flag_binary_swap
void undefined_error(cb_tree x)
static int validate_field_value(struct cb_field *f)
void cb_add_78(struct cb_field *f)
int cb_get_level(cb_tree x)
unsigned int flag_any_numeric
struct cb_field * rename_thru
void cb_validate_88_item(struct cb_field *f)
#define CB_BINARY_SIZE_1_2_4_8
unsigned int flag_blank_zero
struct cb_picture * cb_build_binary_picture(const char *str, const cob_u32_t size, const cob_u32_t sign)
struct cb_field * cb_get_real_field(void)
#define CB_INVALID_TREE(x)
struct cb_program * current_program
void group_error(cb_tree x, const char *clause)
unsigned int flag_sign_separate
static void setup_parameters(struct cb_field *f)
void level_require_error(cb_tree x, const char *clause)
#define CB_BINARY_SIZE_1__8
unsigned int flag_trailing_separate
void cb_validate_field(struct cb_field *f)
struct cb_field * redefines
void level_redundant_error(cb_tree x, const char *clause)
static const int pic_digits[]
unsigned int flag_has_external
void cb_clear_real_field(void)
struct cb_field * cb_field_founder(const struct cb_field *f)
unsigned char flag_external
cb_tree cb_list_add(cb_tree l, cb_tree x)
unsigned int flag_item_based