diff --git a/ChangeLog b/ChangeLog index 1a535e0d4..5645da6e2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,18 @@ +2023-03-03 Simon Sobisch + + * configure.ac: allow specification of XML2_CONFIG (only used if + pkg-config module libxml-2.0 is not available) + * configure.ac: check all used headers of libxml-2.0, + warn user if not found + * improve multiple header header check via AC_CHECK_HEADERS according + to docs (cJSON, json-c and curses) + +2023-02-27 Simon Sobisch + + * configure.ac: fixed duplicate note about JSON_C_C_FLAGS, + changed messages as per autoconf docs + 2023-02-19 Simon Sobisch * configure.ac: minor adjustment for bdb library lookup diff --git a/cobc/ChangeLog b/cobc/ChangeLog index c13d4c6dc..8b8e8b85e 100644 --- a/cobc/ChangeLog +++ b/cobc/ChangeLog @@ -1,4 +1,39 @@ +2023-03-08 Emilien Lemaire + + * reserved.c (get_user_specified_reserved_word): add check for + context sensitivity in aliases + +2023-03-03 Simon Sobisch + + * typeck.c (cb_build_cond_fields): optimize comparison between field and + ZEROES up to COB_ZEROES_ALPHABETIC_BYTE_LENGTH + +2023-02-28 Simon Sobisch + + * typeck.c (cb_emit_set_to): generate runtime check for SET source + at most one time + * cobc.c (process_filename) [_WIN32 __GNUC__]: pass .dll input files + to linker (GCC MinGW extension to drop need of link libraries) + * cobc.c (xref_files_and_their_records, xref_labels): minor refactoring + +2023-02-24 Simon Sobisch + + * codegen.c (output_initial_values): drop wrong init comment + * field.c (copy_into_field): set EXTERNAL name if missing + * pplex.l, scanner.l: dropped extra line breaks before area_a token + * pplex.l (ppinput): insert "preparse area_a token" in column 1 instead + of column 2 to fix terminal-format support and insert it before + newlines are added to the beginning of the buffer + +2023-02-20 Nicolas Berthier + + * scanner.l, config.def: Add support for EBCDIC symbolic characters in + alphanumeric literals, which is a GCOS-specific extension; add new + configuration option ebcdic-symbolic-characters + * scanner.l, pplex.l: detect and issue a warning when EBCDIC + symbolic character strings include extraneous separators + 2023-02-21 Simon Sobisch * codegen.c, flag.def [COBC_HAS_CUTOFF_FLAG]: fix compile errors, @@ -685,7 +720,7 @@ FR #360 AREACHECK FR #309 raise warnings/errors when some periods are missing * config.def: add dialect options areacheck and missing-period - * pplex.l, scanner.l, parser.y: check for empty Area A, and use a + * pplex.l, scanner.l, parser.y: check for empty Area A, and use a set of dedicated *_IN_AREA_A tokens to detect missing periods and incorrect use of Area A * pplex.l, scanner.l, parser.y: support AREACHECK and NOAREACHECK diff --git a/cobc/cobc.c b/cobc/cobc.c index 0183804ce..531b6dc80 100644 --- a/cobc/cobc.c +++ b/cobc/cobc.c @@ -4244,9 +4244,12 @@ process_filename (const char *filename) #if defined(__OS400__) extension[0] == 0 #else - cb_strcasecmp (extension, COB_OBJECT_EXT) == 0 + cb_strcasecmp (extension, COB_OBJECT_EXT) == 0 #if defined(_WIN32) || cb_strcasecmp (extension, "lib") == 0 +#if defined (__GNUC__) + || cb_strcasecmp (extension, "dll") == 0 +#endif #endif #if !defined(_WIN32) || defined(__MINGW32__) || defined(__MINGW64__) || cb_strcasecmp (extension, "a") == 0 @@ -5904,12 +5907,12 @@ xref_files_and_their_records (cb_tree file_list_p) cb_tree l; for (l = file_list_p; l; l = CB_CHAIN (l)) { + struct cb_file *file = CB_FILE (CB_VALUE (l)); pd_off = sprintf (print_data, "%-30.30s %-6u ", - CB_FILE (CB_VALUE (l))->name, - CB_FILE (CB_VALUE (l))->common.source_line); - xref_print (&CB_FILE (CB_VALUE (l))->xref, XREF_FILE, NULL); - if (CB_FILE (CB_VALUE (l))->record) { - (void)xref_fields (CB_FILE (CB_VALUE (l))->record); + file->name, file->common.source_line); + xref_print (&file->xref, XREF_FILE, NULL); + if (file->record) { + (void)xref_fields (file->record); } print_program_data (""); } @@ -5930,15 +5933,14 @@ xref_fields_in_section (struct cb_field *first_field_in_section) } static int -xref_labels (cb_tree label_list_p) +xref_labels (cb_tree statements) { - cb_tree l; char label_type = ' '; - struct cb_label *lab; - - for (l = label_list_p; l; l = CB_CHAIN (l)) { - if (CB_LABEL_P(CB_VALUE(l))) { - lab = CB_LABEL (CB_VALUE (l)); + cb_tree l; + for (l = statements; l; l = CB_CHAIN (l)) { + cb_tree stmt = CB_VALUE (l); + if (CB_LABEL_P (stmt)) { + struct cb_label *lab = CB_LABEL (stmt); if (lab->xref.skip) { continue; } diff --git a/cobc/codegen.c b/cobc/codegen.c index 5a0edec92..3dc177767 100644 --- a/cobc/codegen.c +++ b/cobc/codegen.c @@ -10505,7 +10505,6 @@ output_initial_values (struct cb_field *f) continue; } x = cb_build_field_reference (p, NULL); - output_line ("/* initialize field %s */", f->name); output_stmt (cb_build_initialize (x, cb_true, NULL, 1, STMT_INIT_STORAGE, 0)); output_newline (); } @@ -12323,10 +12322,8 @@ output_internal_function (struct cb_program *prog, cb_tree parameter_list) gen_init_working = 1; /* Disable use of DEPENDING ON fields */ /* Initialize WORKING-STORAGE EXTERNAL items */ for (f = prog->working_storage; f; f = f->sister) { - if (f->redefines) { - continue; - } - if (!f->flag_external) { + if (!f->flag_external + || f->redefines) { continue; } output_prefix (); diff --git a/cobc/config.def b/cobc/config.def index c69a68015..d4c9a3c5d 100644 --- a/cobc/config.def +++ b/cobc/config.def @@ -325,6 +325,9 @@ CB_CONFIG_SUPPORT (cb_hp_octal_literals, "hp-octal-literals", CB_CONFIG_SUPPORT (cb_acu_literals, "acu-literals", _("ACUCOBOL-GT literals (#B #O #H #X)")) +CB_CONFIG_BOOLEAN (cb_gcos_ebcdic_literals, "ebcdic-symbolic-characters", + _("EBCDIC symbolic characters in literals (\" \"135,151,151\"bar\"195, 194\"Z\" for \" foobarBAZ\")")) + CB_CONFIG_SUPPORT (cb_word_continuation, "word-continuation", _("continuation of COBOL words")) diff --git a/cobc/error.c b/cobc/error.c index 42f9d3c07..09a62ca5d 100644 --- a/cobc/error.c +++ b/cobc/error.c @@ -823,10 +823,11 @@ cb_syntax_check (const char *fmt, ...) enum cb_warn_val ret; va_list ap; va_start (ap, fmt); - if (cb_relaxed_syntax_checks) + if (cb_relaxed_syntax_checks) { ret = cb_warning_internal (COBC_WARN_FILLER, fmt, ap); - else + } else { ret = cb_error_internal (fmt, ap); + } va_end (ap); return cb_relaxed_syntax_checks ? ret != COBC_WARN_DISABLED : 0; } @@ -843,10 +844,11 @@ cb_syntax_check_x (cb_tree x, const char *fmt, ...) enum cb_warn_val ret; va_list ap; va_start (ap, fmt); - if (cb_relaxed_syntax_checks) + if (cb_relaxed_syntax_checks) { ret = cb_warning_x_internal (COBC_WARN_FILLER, x, fmt, ap); - else + } else { ret = cb_error_x_internal (x, fmt, ap); + } va_end (ap); return cb_relaxed_syntax_checks ? ret != COBC_WARN_DISABLED : 0; } diff --git a/cobc/field.c b/cobc/field.c index 52fc48e54..24978ee06 100644 --- a/cobc/field.c +++ b/cobc/field.c @@ -839,6 +839,14 @@ copy_into_field (struct cb_field *source, struct cb_field *target) but may be specified on the field */ if (target->level == 1 || target->level == 77) { field_attribute_copy (flag_external); + if (target->flag_external + && !target->ename) { +#if 1 /* CHECKME: Which one to use? Possibly depending on AS clause? */ + target->ename = source->ename; +#else + target->ename = cb_to_cname (target->name); +#endif + } } target->usage = source->usage; if (source->values) { diff --git a/cobc/help.c b/cobc/help.c index 84bc271b0..0cde1f29d 100644 --- a/cobc/help.c +++ b/cobc/help.c @@ -118,10 +118,10 @@ cobc_print_usage_common_options (void) puts (_(" -I add to copy/include search path")); puts (_(" -L add to library search path")); puts (_(" -l link the library ")); + puts (_(" -K generate CALL to as static")); puts (_(" -D define for COBOL compilation")); puts (_(" -A add to the C compile phase")); puts (_(" -Q add to the C link phase")); - puts (_(" -Q add to the C link phase")); puts (_(" --coverage instrument generated binaries for coverage")); puts (_(" --conf= user-defined dialect configuration; see -std")); puts (_(" --list-reserved display reserved words")); diff --git a/cobc/pplex.l b/cobc/pplex.l index b16bf1227..e86e73a3b 100644 --- a/cobc/pplex.l +++ b/cobc/pplex.l @@ -190,7 +190,9 @@ static struct cb_text_list *pp_text_list_add (struct cb_text_list *, WORD [_0-9A-Z\x80-\xFF-]+ NUMRIC_LITERAL [+-]?[0-9,.]*[0-9] -ALNUM_LITERAL "\""[^""\n]*"\""|"\'"[^''\n]*"\'" +ALNUM_LITERAL_Q "\""([^""\n]|("\""[0-9][0-9, ]*"\""))*"\"" +ALNUM_LITERAL_A "\'"([^''\n]|("\'"[0-9][0-9, ]+"\'"))*"\'" +ALNUM_LITERAL {ALNUM_LITERAL_Q}|{ALNUM_LITERAL_A} SET_PAREN_LIT \([^()\n]*\) DEFNUM_LITERAL [+-]?[0-9]*[\.]*[0-9]+ @@ -505,7 +507,7 @@ MAYBE_AREA_A [ ]?#? needed to properly handle the first line in each buffer, that for some reason always starts with a space. */ - fprintf (ppout, "\n#area_a\n"); + fprintf (ppout, "#area_a\n"); } "CONTROL"[ ,;\n]+"DIVISION" { @@ -2499,11 +2501,6 @@ start: } else { /* Insert newlines at the start of the buffer */ gotcr = strlen (buff); - if (newline_count != 0) { - memmove (buff + newline_count, buff, gotcr + 1); - memset (buff, '\n', newline_count); - gotcr += newline_count; - } if (in_area_a) { /* (*area-a*): prepend special marker `#', indicating the current non-continuation line starts in area A @@ -2512,9 +2509,14 @@ start: Assumes `buff' is large enough for one extra char. */ memmove (buff + 1, buff, gotcr + 1); - buff[1] = '#'; + buff[0] = '#'; gotcr += 1; } + if (newline_count != 0) { + memmove (buff + newline_count, buff, gotcr + 1); + memset (buff, '\n', newline_count); + gotcr += newline_count; + } newline_count = 1; } return (int)gotcr; diff --git a/cobc/reserved.c b/cobc/reserved.c index b034431e2..bfbf41221 100644 --- a/cobc/reserved.c +++ b/cobc/reserved.c @@ -4234,6 +4234,11 @@ get_user_specified_reserved_word (struct amendment_list user_reserved) p = find_default_reserved_word (user_reserved.alias_for, 0); if (p) { cobc_reserved.token = p->token; + if (user_reserved.is_context_sensitive) { + cobc_reserved.context_sens = + !!user_reserved.is_context_sensitive; + cobc_reserved.context_test = p->context_test; + } } else { /* FIXME: can we point to the fname originally defining the word? */ configuration_error (NULL, 0, 1, diff --git a/cobc/scanner.l b/cobc/scanner.l index a76eb9a57..04fd7b33d 100644 --- a/cobc/scanner.l +++ b/cobc/scanner.l @@ -148,6 +148,12 @@ enum cb_literal_type { CB_LITERAL_NC, }; +enum cb_sym_ebcdic_state { + CB_SYM_EBCDIC_INACTIVE, /* Outside */ + CB_SYM_EBCDIC_ACTIVE, /* Inside, before or after number */ + CB_SYM_EBCDIC_AFTER_SEP /* Inside, just after a separator */ +}; + /* Local variables */ static cb_tree last_yylval; static int last_token; @@ -186,7 +192,7 @@ static void clear_constants (void); %} -AREA_A \n"#AREA_A"\n +AREA_A "#AREA_A"\n %s DECIMAL_IS_PERIOD DECIMAL_IS_COMMA %x PICTURE_STATE FUNCTION_STATE @@ -205,7 +211,7 @@ AREA_A \n"#AREA_A"\n if (cobc_repeat_last_token) { cobc_repeat_last_token = 0; yylval = last_yylval; - return last_token; + return last_token; } /* We treat integer literals immediately after '.' as labels; @@ -1310,12 +1316,58 @@ error_literal (const char *type, const char *literal, unsigned int literal_error cb_error ("%s", err_msg); } +/* Scans a symbolic EBCDIC character given as a sequence of decimal digits + starting with `c`, and returns the corresponding code as per the machine + character set (ASCII or EBCDIC). */ +static cob_u8_t +scan_ebcdic_char (int c) +{ + char buff[10]; /* Arbitrary limit, mostly for error-reporting */ +#ifndef COB_EBCDIC_MACHINE + static cob_u8_t ebcdic_to_ascii[256] ; + static int ebcdic_to_ascii_initialized = 0 ; +#endif + unsigned int j = 0; + do { + buff[j++] = c; + } while ((c = input ()) != EOF && '0' <= c && c <= '9' && j < 10); + unput (c); + buff[j++] = 0; + c = atoi (buff); + if (c < 1 || c > 256) { + cb_error (_("character code %s out of encoding range %s"), + buff, "(1..256)"); + return '?'; + } + c--; // in ordinal, i.e. 1..256 -> 0..255 +#ifdef COB_EBCDIC_MACHINE + return (cob_u8_t) c; +#else + if (!ebcdic_to_ascii_initialized ){ + if (cob_load_collation (cb_ebcdic_table, + ebcdic_to_ascii, + NULL) < 0) { + cb_error (_("invalid parameter: %s"), "-febcdic-table"); + ebcdic_to_ascii_initialized = -1; + } else { + ebcdic_to_ascii_initialized = 1; + } + } + + if (ebcdic_to_ascii_initialized > 0) + return ebcdic_to_ascii[c]; + else + return '?'; +#endif +} + static void read_literal (const char mark, const enum cb_literal_type type) { size_t i; int c; unsigned int literal_error = 0; + enum cb_sym_ebcdic_state ebcdic_flag = CB_SYM_EBCDIC_INACTIVE; i = 0; /* read until a not-escaped mark is found (see break) @@ -1335,11 +1387,50 @@ read_literal (const char mark, const enum cb_literal_type type) } plex_buff[i] = (cob_u8_t)c; } + + if (ebcdic_flag != CB_SYM_EBCDIC_INACTIVE) { + /* While scanning symbolic EBCDIC character: */ + if (c == mark) { + if (ebcdic_flag == CB_SYM_EBCDIC_AFTER_SEP) { + cb_error ( + _("extraneous separator ',' at end " + "of symbolic EBCDIC characters")); + } + ebcdic_flag = CB_SYM_EBCDIC_INACTIVE; + } else if ('0' <= c && c <= '9') { + plex_buff[i++] = scan_ebcdic_char (c); + ebcdic_flag = CB_SYM_EBCDIC_ACTIVE; + } else if (c == ' ') { + /* spaces are ok everywhere */ + } else if (c == ',') { + /* extra commas are not allowed */ + if (ebcdic_flag == CB_SYM_EBCDIC_AFTER_SEP) + cb_error ( + _("extraneous character ',' in sequence " + "of symbolic EBCDIC characters")); + ebcdic_flag = CB_SYM_EBCDIC_AFTER_SEP; + } else { + /* other chars are invalid */ + cb_error (_("invalid character '%c' in sequence " + "of symbolic EBCDIC characters"), c); + ebcdic_flag = CB_SYM_EBCDIC_ACTIVE; + } + continue; + } + if (c == mark && (c = input ()) != (int)mark) { if (c == '-') { /* Free format continuation ("a"- 'b'- ) */ /* Hack it as concatenation */ unput ('&'); + } else if (type == CB_LITERAL_DEFAULT && + cb_gcos_ebcdic_literals && + '0' <= c && c <= '9') { + /* GCOS 7: symbolic EBCDIC character in + literals */ + unput (c); + ebcdic_flag = CB_SYM_EBCDIC_ACTIVE; + continue; } else { if (c == EOF || c == 0) break; unput (c); @@ -1386,7 +1477,8 @@ read_literal (const char mark, const enum cb_literal_type type) cb_warning (COBC_WARN_FILLER, ( type == CB_LITERAL_N || type == CB_LITERAL_NC ) ? _("national literal has zero length; a SPACE will be assumed") : - _("alphanumeric literal has zero length; a SPACE will be assumed")); + _("alphanumeric literal has zero length; a SPACE will be assumed") + ); plex_buff[i++] = ' '; } else if (i > cb_lit_length) { i = cb_lit_length; @@ -2160,7 +2252,7 @@ scan_picture (const char *text) static void count_lines (const char *text) { - const char *p; + register const char *p; /* Count newlines in text */ for (p = text; *p; p++) { diff --git a/cobc/tree.c b/cobc/tree.c index f280770dc..b3a949248 100644 --- a/cobc/tree.c +++ b/cobc/tree.c @@ -5142,7 +5142,7 @@ cb_ref_internal (cb_tree x, const int emit_error) c = r->chain; switch (CB_TREE_TAG (v)) { case CB_TAG_FIELD: { - struct cb_field* fld = CB_FIELD (v); + struct cb_field *fld = CB_FIELD (v); /* ignore sub-items of typedefs */ if (fld->parent != NULL && cb_field_founder (fld)->flag_is_typedef) { continue; @@ -5162,8 +5162,9 @@ cb_ref_internal (cb_tree x, const int emit_error) } /* Resolve by file or CD */ - if (c && CB_REFERENCE (c)->chain == NULL - && CB_WORD_COUNT (c) == 1) { + if (c + && CB_REFERENCE (c)->chain == NULL + && CB_WORD_COUNT (c) == 1) { cb_tree tree = cb_ref (c); if (field_is_in_file_record (tree, fld) || field_is_in_cd_record (tree, fld)) { diff --git a/cobc/typeck.c b/cobc/typeck.c index b7851cfb8..24c8465a4 100644 --- a/cobc/typeck.c +++ b/cobc/typeck.c @@ -1054,13 +1054,11 @@ cb_emit_incompat_data_checks (cb_tree x) { struct cb_field *f; - /* TO-DO: Check for EC-DATA-INCOMPATIBLE checking */ - if (!x || x == cb_error_node) { return; } - if (!CB_REF_OR_FIELD_P (x) || - CB_TREE_CATEGORY (x) != CB_CATEGORY_NUMERIC) { + if (!CB_REF_OR_FIELD_P (x) + || CB_TREE_CATEGORY (x) != CB_CATEGORY_NUMERIC) { return; } f = CB_FIELD_PTR (x); @@ -1068,9 +1066,9 @@ cb_emit_incompat_data_checks (cb_tree x) cb_emit (CB_BUILD_FUNCALL_1 ("cob_correct_numeric", x)); } if (CB_EXCEPTION_ENABLE (COB_EC_DATA_INCOMPATIBLE)) { - if (f->usage == CB_USAGE_DISPLAY || - f->usage == CB_USAGE_PACKED || - f->usage == CB_USAGE_COMP_6) { + if (f->usage == CB_USAGE_DISPLAY + || f->usage == CB_USAGE_PACKED + || f->usage == CB_USAGE_COMP_6) { cb_emit (CB_BUILD_FUNCALL_2 ("cob_check_numeric", x, CB_BUILD_STRING0 (f->name))); @@ -5983,12 +5981,10 @@ enum_explain_storage (const enum cb_storage storage) static cb_tree build_store_option (cb_tree x, cb_tree round_opt) { - struct cb_field *f; + const struct cb_field *f = CB_FIELD_PTR (x); + const enum cb_usage usage = f->usage; int opt; - enum cb_usage usage; - f = CB_FIELD_PTR (x); - usage = f->usage; #if 0 /* RXWRXW - FP */ if (usage == CB_USAGE_LONG_DOUBLE || usage == CB_USAGE_DOUBLE @@ -6523,19 +6519,21 @@ cb_emit_arithmetic (cb_tree vars, const int op, cb_tree val) cb_tree l; cb_emit_incompat_data_checks (x); for (l = vars; l; l = CB_CHAIN (l)) { - cb_emit_incompat_data_checks (CB_VALUE (l)); + const cb_tree target = CB_VALUE(l); + const cb_tree round_and_trunc = CB_PURPOSE(l); + cb_emit_incompat_data_checks (target); switch (op) { case '+': - CB_VALUE (l) = cb_build_add (CB_VALUE (l), x, CB_PURPOSE (l)); + CB_VALUE (l) = cb_build_add (target, x, round_and_trunc); break; case '-': - CB_VALUE (l) = cb_build_sub (CB_VALUE (l), x, CB_PURPOSE (l)); + CB_VALUE (l) = cb_build_sub (target, x, round_and_trunc); break; case '*': - CB_VALUE (l) = cb_build_mul (CB_VALUE (l), x, CB_PURPOSE (l)); + CB_VALUE (l) = cb_build_mul (target, x, round_and_trunc); break; case '/': - CB_VALUE (l) = cb_build_div (CB_VALUE (l), x, CB_PURPOSE (l)); + CB_VALUE (l) = cb_build_div (target, x, round_and_trunc); break; } } @@ -6935,6 +6933,14 @@ cb_build_cond_fields (struct cb_binary_op *p, cb_build_direct ("COB_SPACES_ALPHABETIC", 0), cb_int (size1)); } + if (right == cb_zero + && (l_class == CB_CLASS_ALPHANUMERIC || l_class == CB_CLASS_ALPHABETIC) + && (size1 > 0 && size1 <= COB_ZEROES_ALPHABETIC_BYTE_LENGTH)) { + return CB_BUILD_FUNCALL_3 ("memcmp", + CB_BUILD_CAST_ADDRESS (left), + cb_build_direct ("COB_ZEROES_ALPHABETIC", 0), + cb_int (size1)); + } #if 0 /* TODO: if at least one is a literal and smaller: possibly extend by building a new literal correctly @@ -9733,7 +9739,7 @@ cb_emit_evaluate (cb_tree subject_list, cb_tree case_list) } #endif - /* code to skipt to internal label of END-EVALUATE */ + /* code to skip to internal label of END-EVALUATE */ sprintf (sbuf, "goto %s%d;", CB_PREFIX_LABEL, cb_id); x = cb_build_direct (cobc_parse_strdup (sbuf), 0); @@ -11932,8 +11938,8 @@ cb_build_move (cb_tree src, cb_tree dst) cb_tree ret; int move_zero; - if (CB_INVALID_TREE(src) - || CB_INVALID_TREE(dst)) { + if (CB_INVALID_TREE (src) + || CB_INVALID_TREE (dst)) { return cb_error_node; } @@ -11951,8 +11957,8 @@ cb_build_move (cb_tree src, cb_tree dst) } else if (CB_LITERAL_P (src)) { /* FIXME: don't do this for a DYNAMIC LENGTH target */ const struct cb_literal* lit = CB_LITERAL (src); - char* p = (char*)lit->data; - char* end = p + lit->size - 1; + char *p = (char*)lit->data; + char *end = p + lit->size - 1; if (*end == ' ') { while (p < end && *p == ' ') p++; if (p == end) src = cb_space; @@ -12132,8 +12138,10 @@ cb_emit_move (cb_tree src, cb_tree dsts) return; } + /* Validate source, if requested. */ cb_emit_incompat_data_checks (src); - /* CHECKME: this is way to much to cater for sum field */ + + /* FIXME: this is way to much to cater for sum field */ src = cb_check_sum_field (src); tempval = 0; @@ -12958,18 +12966,21 @@ cb_check_set_to (cb_tree vars, cb_tree x, const int emit_error) } void -cb_emit_set_to (cb_tree vars, cb_tree x) +cb_emit_set_to (cb_tree vars, cb_tree src) { cb_tree l; - if (cb_check_set_to (vars, x, 1)) { + /* Emit statements only if targets have the correct class. */ + if (cb_check_set_to (vars, src, 1)) { return; } - /* Emit statements if targets have the correct class. */ + /* Validate source, if requested. */ + cb_emit_incompat_data_checks (src); + + /* Emit statements. */ for (l = vars; l; l = CB_CHAIN (l)) { - cb_emit_incompat_data_checks (x); - cb_emit (cb_build_move (x, CB_VALUE (l))); + cb_emit (cb_build_move (src, CB_VALUE (l))); } } diff --git a/config/acu-strict.conf b/config/acu-strict.conf index 0b32e4854..8962823cb 100644 --- a/config/acu-strict.conf +++ b/config/acu-strict.conf @@ -242,6 +242,7 @@ national-character-literals: unconformable # TO-DO: Add separate config option for H"..." to be unsupported,numeric,non-numeric(acu) acu-literals: ok hp-octal-literals: unconformable +ebcdic-symbolic-characters: no word-continuation: ok not-exception-before-exception: unconformable accept-display-extensions: ok diff --git a/config/bs2000-strict.conf b/config/bs2000-strict.conf index f580a2396..1c15dd7dc 100644 --- a/config/bs2000-strict.conf +++ b/config/bs2000-strict.conf @@ -239,6 +239,7 @@ hexadecimal-national-literals: ok national-character-literals: unconformable acu-literals: unconformable hp-octal-literals: unconformable +ebcdic-symbolic-characters: no word-continuation: ok not-exception-before-exception: unconformable accept-display-extensions: unconformable diff --git a/config/cobol2002.conf b/config/cobol2002.conf index e3651b557..b95a49aef 100644 --- a/config/cobol2002.conf +++ b/config/cobol2002.conf @@ -238,6 +238,7 @@ hexadecimal-national-literals: ok national-character-literals: unconformable acu-literals: unconformable hp-octal-literals: unconformable +ebcdic-symbolic-characters: no word-continuation: archaic not-exception-before-exception: ok accept-display-extensions: unconformable diff --git a/config/cobol2014.conf b/config/cobol2014.conf index 392a992b4..16b21c899 100644 --- a/config/cobol2014.conf +++ b/config/cobol2014.conf @@ -240,6 +240,7 @@ national-character-literals: unconformable acu-literals: unconformable hp-octal-literals: unconformable word-continuation: archaic +ebcdic-symbolic-characters: no not-exception-before-exception: ok accept-display-extensions: unconformable renames-uncommon-levels: unconformable diff --git a/config/cobol85.conf b/config/cobol85.conf index f80f7a693..6111dcff1 100644 --- a/config/cobol85.conf +++ b/config/cobol85.conf @@ -238,6 +238,7 @@ hexadecimal-national-literals: unconformable national-character-literals: unconformable acu-literals: unconformable hp-octal-literals: unconformable +ebcdic-symbolic-characters: no word-continuation: ok not-exception-before-exception: unconformable accept-display-extensions: unconformable diff --git a/config/default.conf b/config/default.conf index cc91a1489..db6ffb1d4 100644 --- a/config/default.conf +++ b/config/default.conf @@ -259,6 +259,7 @@ national-character-literals: warning # TO-DO: Add separate config option for H"..." to be unsupported,numeric,non-numeric(acu) acu-literals: unconformable hp-octal-literals: unconformable +ebcdic-symbolic-characters: no word-continuation: warning not-exception-before-exception: ok accept-display-extensions: ok diff --git a/config/gcos-strict.conf b/config/gcos-strict.conf index 8fa4b85b0..9b4e280e4 100644 --- a/config/gcos-strict.conf +++ b/config/gcos-strict.conf @@ -238,6 +238,7 @@ hexadecimal-national-literals: unconformable national-character-literals: unconformable acu-literals: unconformable hp-octal-literals: unconformable +ebcdic-symbolic-characters: yes word-continuation: archaic not-exception-before-exception: unconformable accept-display-extensions: unconformable diff --git a/config/ibm-strict.conf b/config/ibm-strict.conf index 1852798b5..10a565cf7 100644 --- a/config/ibm-strict.conf +++ b/config/ibm-strict.conf @@ -238,6 +238,7 @@ hexadecimal-national-literals: unconformable national-character-literals: unconformable acu-literals: unconformable hp-octal-literals: unconformable +ebcdic-symbolic-characters: no word-continuation: ok not-exception-before-exception: unconformable accept-display-extensions: unconformable diff --git a/config/ibm.words b/config/ibm.words index 228ce30e4..ad466f692 100644 --- a/config/ibm.words +++ b/config/ibm.words @@ -357,7 +357,7 @@ reserved: PLUS reserved: POINTER #reserved: POINTER-24 # potentially reserved #reserved: POINTER-31 # potentially reserved -reserved: POINTER-32 X +reserved: POINTER-32 #reserved: POINTER-64 # potentially reserved reserved: POSITION reserved: POSITIVE diff --git a/config/mf-strict.conf b/config/mf-strict.conf index 4aaf8abbb..19583c424 100644 --- a/config/mf-strict.conf +++ b/config/mf-strict.conf @@ -241,6 +241,7 @@ national-character-literals: unconformable # TO-DO: Add separate config option for H"..." to be unsupported,numeric(rm/mf),non-numeric acu-literals: unconformable hp-octal-literals: unconformable +ebcdic-symbolic-characters: no word-continuation: ok not-exception-before-exception: unconformable accept-display-extensions: ok diff --git a/config/mvs-strict.conf b/config/mvs-strict.conf index ef18b7659..ea689341c 100644 --- a/config/mvs-strict.conf +++ b/config/mvs-strict.conf @@ -237,6 +237,7 @@ hexadecimal-national-literals: unconformable national-character-literals: unconformable acu-literals: unconformable hp-octal-literals: unconformable +ebcdic-symbolic-characters: no word-continuation: ok not-exception-before-exception: unconformable accept-display-extensions: unconformable diff --git a/config/realia-strict.conf b/config/realia-strict.conf index 061c1b05e..0da162868 100644 --- a/config/realia-strict.conf +++ b/config/realia-strict.conf @@ -242,6 +242,7 @@ national-character-literals: unconformable # TO-DO: Add separate config options for H"..." , Z"...", G"..." and N"..." to be ok acu-literals: unconformable hp-octal-literals: unconformable +ebcdic-symbolic-characters: no word-continuation: ok not-exception-before-exception: unconformable accept-display-extensions: ok diff --git a/config/rm-strict.conf b/config/rm-strict.conf index 40e9af2fb..b51226e2b 100644 --- a/config/rm-strict.conf +++ b/config/rm-strict.conf @@ -244,6 +244,7 @@ national-character-literals: unconformable # TO-DO: Add separate config option for H"..." to be unsupported,numeric(rm/mf),non-numeric acu-literals: unconformable hp-octal-literals: unconformable +ebcdic-symbolic-characters: no word-continuation: ok not-exception-before-exception: unconformable accept-display-extensions: ok diff --git a/config/xopen.conf b/config/xopen.conf index c60e14e8d..6fc8d4f78 100644 --- a/config/xopen.conf +++ b/config/xopen.conf @@ -258,6 +258,7 @@ national-character-literals: unconformable acu-literals: unconformable hp-octal-literals: unconformable word-continuation: obsolete # even for literals (as it added concatenation of literals by &)! +ebcdic-symbolic-characters: no not-exception-before-exception: unconformable accept-display-extensions: unconformable renames-uncommon-levels: unconformable diff --git a/configure.ac b/configure.ac index 87c68d6e6..5d2552520 100644 --- a/configure.ac +++ b/configure.ac @@ -211,7 +211,7 @@ AC_ARG_ENABLE([hardening], AC_ARG_ENABLE([experimental], [AS_HELP_STRING([--enable-experimental], [(GnuCOBOL) Enable experimental code (Developers only!)])], - [if test "$enable_experimental" = "yes"; then + [if test "$enable_experimental" = yes; then AC_DEFINE([COB_EXPERIMENTAL], [1]) fi], []) @@ -219,7 +219,7 @@ AC_ARG_ENABLE([experimental], AC_ARG_ENABLE([cobc-internal-checks], [AS_HELP_STRING([--enable-cobc-internal-checks], [(GnuCOBOL) Enable extra checks within the compiler (Developers only!)])], - [if test "$enable_cobc_internal_checks" = "yes"; then + [if test "$enable_cobc_internal_checks" = yes; then AC_DEFINE([COB_TREE_DEBUG], [1]) fi], []) @@ -227,7 +227,7 @@ AC_ARG_ENABLE([cobc-internal-checks], AC_ARG_ENABLE([debuglog], [AS_HELP_STRING([--enable-debuglog], [(GnuCOBOL) Enable internal logging code (Developers only!)])], - [if test "$enable_debuglog" = "yes"; then + [if test "$enable_debuglog" = yes; then AC_DEFINE([COB_DEBUG_LOG], [1]) fi], []) @@ -235,7 +235,7 @@ AC_ARG_ENABLE([debuglog], AC_ARG_ENABLE([param-check], [AS_HELP_STRING([--enable-param-check], [(GnuCOBOL) Enable minimum parameter check for system libraries (default no)])], - [if test "$enable_param_check" = "yes"; then + [if test "$enable_param_check" = yes; then AC_DEFINE([COB_PARAM_CHECK], [1]) fi], []) @@ -244,7 +244,7 @@ dnl FIXME: may be specified with different file version dnl AC_ARG_ENABLE([bdbdupno], dnl [AS_HELP_STRING([--enable-bdbdupno], dnl [(GnuCOBOL) Retain old BDB duplicate sequence (Incorrect on little-endian!)])], -dnl [if test "$enable_bdbdupno" = "yes"; then +dnl [if test "$enable_bdbdupno" = yes; then dnl AC_DEFINE([COB_BDB_BAD_DUPNO], [1]) dnl fi], dnl []) @@ -253,16 +253,16 @@ AC_ARG_WITH([patch-level], [AS_HELP_STRING([--with-patch-level], [(GnuCOBOL) Define a patch level (default 0), numeric, max. 8 digits])], [case $with_patch_level in - yes) AC_MSG_ERROR([[You must give --with-patch-level an argument.]]) + yes) AC_MSG_ERROR([[--with-patch-level needs an argument]]) ;; - no) AC_MSG_ERROR([[--without-patch-level not supported.]]) + no) AC_MSG_ERROR([[--without-patch-level not supported]]) ;; [[0-9]]*) if test $with_patch_level -gt 99999999; then - AC_MSG_ERROR([[Patch level must not contain more than 8 digits]]) + AC_MSG_ERROR([[patch level must not contain more than 8 digits]]) fi ;; - *) AC_MSG_ERROR([[You must use a numeric patch level]]) + *) AC_MSG_ERROR([[patch level must be numeric]]) ;; esac], [with_patch_level=0]) @@ -273,13 +273,13 @@ AC_ARG_WITH([max-call-params], [AS_HELP_STRING([--with-max-call-params], [(GnuCOBOL) Define maximum number of parameters for CALL (default 192)])], [case $with_max_call_params in - yes) AC_MSG_ERROR([[You must give --with-max-call-params an argument.]]) + yes) AC_MSG_ERROR([[--with-max-call-params needs an argument]]) ;; - no) AC_MSG_ERROR([[--without-max-call-params not supported.]]) + no) AC_MSG_ERROR([[--without-max-call-params not supported]]) ;; 16 | 36 | 56 | 76 | 96 | 192 | 252) ;; - *) AC_MSG_ERROR([[Maximum number of parameters for CALL must be one of 16/36/56/76/96/192/252]]) + *) AC_MSG_ERROR([[maximum number of parameters for CALL must be one of 16/36/56/76/96/192/252]]) ;; esac], [with_max_call_params=192]) @@ -323,7 +323,7 @@ _am_result=no ['0:target executed'], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]) - AC_MSG_ERROR([make, configured as "$MAKE", does not work])]) + AC_MSG_FAILURE([make, configured as "$MAKE", does not work])]) rm -f confmake.out confmf.mk AC_MSG_CHECKING([whether ${MAKE} supports order-only prerequisites]) @@ -345,10 +345,10 @@ _am_result=no __am_checkme=$(echo `cat confinc.out 2>/dev/null`) AS_CASE([$?:${__am_checkme}], ['0:target am__prereq. target confprereq. target am__doit. target am__prereq. target am__doit.'], - [_am_result="yes"]) + [_am_result=yes]) rm -f confinc.* confmf.mk confprereq AC_MSG_RESULT([${_am_result}]) -AM_CONDITIONAL([MAKE_HAS_PREREQ_ONLY], [test "${_am_result}" = "yes"]) +AM_CONDITIONAL([MAKE_HAS_PREREQ_ONLY], [test "${_am_result}" = yes]) curr_libs="$LIBS" @@ -383,59 +383,59 @@ AC_USE_SYSTEM_EXTENSIONS AC_ARG_VAR([COBC_CPPFLAGS], [see CPPFLAGS, but only applied during generation of cobc]) AS_IF([test "x$COBC_CPPFLAGS" != x], [ - AC_MSG_CHECKING([if compilation with COBC_CPPFLAGS works]) + AC_MSG_CHECKING([whether compilation with COBC_CPPFLAGS works]) curr_cppflags="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $COBC_CPPFLAGS" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[static int i = 1;]])], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]) - AC_MSG_ERROR([not possible to compile with COBC_CPPFLAGS="$COBC_CPPFLAGS"])]) + AC_MSG_FAILURE([cannot compile with COBC_CPPFLAGS="$COBC_CPPFLAGS"])]) CPPFLAGS="$curr_cppflags" ]) AC_ARG_VAR([LIBCOB_CPPFLAGS], [see CPPFLAGS, but only applied during generation of libcob]) AS_IF([test "x$LIBCOB_CPPFLAGS" != x], [ - AC_MSG_CHECKING([if compilation with LIBCOB_CPPFLAGS works]) + AC_MSG_CHECKING([whether compilation with LIBCOB_CPPFLAGS works]) curr_cppflags="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $LIBCOB_CPPFLAGS" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[static int i = 1;]])], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]) - AC_MSG_ERROR([not possible to compile with LIBCOB_CPPFLAGS="$LIBCOB_CPPFLAGS"])]) + AC_MSG_FAILURE([cannot compile with LIBCOB_CPPFLAGS="$LIBCOB_CPPFLAGS"])]) CPPFLAGS="$curr_cppflags" ]) AS_IF([test "x$LDFLAGS" != "x" -o "x$LIBS" != "x"], [ - AC_MSG_CHECKING([if linking with LDFLAGS / LIBS works]) + AC_MSG_CHECKING([whether linking with LDFLAGS / LIBS works]) AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[return 0;]])], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]) - AC_MSG_ERROR([not possible to link with LDFLAGS="$LDFLAGS", / LIBS="$LIBS"])]) + AC_MSG_FAILURE([cannot link with LDFLAGS="$LDFLAGS", / LIBS="$LIBS"])]) ]) curr_libs="$LIBS" AC_ARG_VAR([LIBCOB_LIBS], [see LIBS, but only applied during generation of libcob]) AS_IF([test "x$LIBCOB_LIBS" != x], [ - AC_MSG_CHECKING([if linking with LIBCOB_LIBS works]) + AC_MSG_CHECKING([whether linking with LIBCOB_LIBS works]) LIBS="$LIBS $LIBCOB_LIBS" AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[return 0;]])], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]) - AC_MSG_ERROR([not possible to link with LIBCOB_LIBS="$LIBCOB_LIBS"])]) + AC_MSG_FAILURE([cannot link with LIBCOB_LIBS="$LIBCOB_LIBS"])]) ]) AC_ARG_VAR([PROGRAMS_LIBS], [see LIBS, but only applied during generation of programs: cobc, cobcrun]) AS_IF([test "x$PROGRAMS_LIBS" != x], [ - AC_MSG_CHECKING([if linking with PROGRAMS_LIBS works]) + AC_MSG_CHECKING([whether linking with PROGRAMS_LIBS works]) LIBS="$LIBS $PROGRAMS_LIBS" AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[return 0;]])], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]) - AC_MSG_ERROR([not possible to link with PROGRAMS_LIBS="$PROGRAMS_LIBS"])]) + AC_MSG_FAILURE([cannot link with PROGRAMS_LIBS="$PROGRAMS_LIBS"])]) ]) LIBS="$curr_libs" @@ -477,8 +477,9 @@ esac AC_SUBST(DIFF_FLAGS) # Stop tests for C++ and Fortran -AC_DEFUN([AC_PROG_F77], []) AC_DEFUN([AC_PROG_CXX], []) +AC_DEFUN([AC_PROG_F77], []) + AC_PROG_LN_S AC_PROG_INSTALL @@ -525,7 +526,7 @@ AC_CACHE_CHECK([for inline keyword], gc_cv_keyword_inline, [ []) done] ) - AC_DEFINE_UNQUOTED([COB_KEYWORD_INLINE], [$gc_cv_keyword_inline]) +AC_DEFINE_UNQUOTED([COB_KEYWORD_INLINE], [$gc_cv_keyword_inline]) # Checks for library functions. @@ -543,9 +544,9 @@ AC_CACHE_CHECK([for timezone variable access], gc_cv_time_timezone, [ [gc_cv_time_timezone=no] )] ) - if test "$gc_cv_time_timezone" = yes; then +if test "$gc_cv_time_timezone" = yes; then AC_DEFINE([HAVE_TIMEZONE], [1]) - fi +fi # Check for designated initializers AC_CACHE_CHECK([for designated initializers], gc_cv_designated_inits, [ @@ -558,27 +559,27 @@ AC_CACHE_CHECK([for designated initializers], gc_cv_designated_inits, [ [gc_cv_designated_inits=no] )] ) - if test "$gc_cv_designated_inits" = yes; then +if test "$gc_cv_designated_inits" = yes; then AC_DEFINE([HAVE_DESIGNATED_INITS], [1]) - fi +fi # more things to save... AC_CACHE_SAVE # Check for the compiler used -dnl COB_USES_GCC="no" -COB_USES_GCC_NO_ICC="no" -COB_USES_ICC_ONLY="no" -COB_USES_CLANG_ONLY="no" -COB_USES_XLC_ONLY="no" -COB_USES_WATCOMC_ONLY="no" +dnl COB_USES_GCC=no +COB_USES_GCC_NO_ICC=no +COB_USES_ICC_ONLY=no +COB_USES_CLANG_ONLY=no +COB_USES_XLC_ONLY=no +COB_USES_WATCOMC_ONLY=no dnl AC_MSG_CHECKING([for __GNUC__]) dnl AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ dnl #ifndef __GNUC__ dnl # error macro not defined dnl #endif]])], -dnl [COB_USES_GCC="yes" +dnl [COB_USES_GCC=yes dnl AC_MSG_RESULT([yes])], dnl [AC_MSG_RESULT([no])]) COB_USES_GCC=$GCC @@ -590,8 +591,8 @@ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ #endif]])], [COB_USES_ICC_ONLY=yes AC_MSG_RESULT([yes])], - [if test "$COB_USES_GCC" = "yes"; then - COB_USES_GCC_NO_ICC="yes" + [if test "$COB_USES_GCC" = yes; then + COB_USES_GCC_NO_ICC=yes fi AC_MSG_RESULT([no])] ) @@ -601,7 +602,7 @@ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ #ifndef __clang__ # error macro not defined #endif]])], - [COB_USES_CLANG_ONLY="yes" + [COB_USES_CLANG_ONLY=yes AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no])]) @@ -610,7 +611,7 @@ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ #ifndef __xlc__ # error macro not defined #endif]])], - [COB_USES_XLC_ONLY="yes" + [COB_USES_XLC_ONLY=yes AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no])]) @@ -619,7 +620,7 @@ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ #ifndef __WATCOMC__ # error macro not defined #endif]])], - [COB_USES_WATCOMC_ONLY="yes" + [COB_USES_WATCOMC_ONLY=yes AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no])]) @@ -656,7 +657,7 @@ AC_MSG_NOTICE([Checks for math library ...]) # FIXME - Check for necessary math lib - in most cases they are part of the C library # for now: explicit pass them to configure via MATH_LIBS dnl if test "x$MATH_LIBS" = "x"; then -dnl if test "$COB_USES_ICC_ONLY" = "yes"; then +dnl if test "$COB_USES_ICC_ONLY" = yes; then dnl MATH_LIBS="-limf -lm" dnl else dnl curr_libs=$LIBS @@ -685,7 +686,7 @@ fi dnl Add --enable-code-coverage and test for code-coverage tools if enabled AX_CODE_COVERAGE -if test "$COB_USES_GCC_NO_ICC" != yes -a "$enable_code_coverage" = "yes"; then +if test "$COB_USES_GCC_NO_ICC" != yes -a "$enable_code_coverage" = yes; then AC_MSG_ERROR([Code coverage checks are only usable with GCC!]) fi @@ -703,13 +704,12 @@ AC_ARG_WITH([math], check (default), gmp, mpir])], [case "$with_math" in gmp | mpir | check) - USE_MATH="$with_math" ;; yes) - USE_MATH="check" + with_math=check ;; no) - AC_MSG_ERROR([Cannot build GnuCOBOL without math multiple precision library)]) + AC_MSG_ERROR([cannot build GnuCOBOL without math multiple precision library)]) ;; *) AC_MSG_ERROR([invalid value "$with_math" for --with-math, @@ -718,12 +718,12 @@ AC_ARG_WITH([math], check (use whatever library is usable)]) ;; esac], - [USE_MATH="check"]) + [with_math=check]) curr_libs=$LIBS curr_cppflags=$CPPFLAGS -AS_IF([test "$USE_MATH" = "gmp" -o "$USE_MATH" = "check"], [ +AS_IF([test "$with_math" = gmp -o "$with_math" = check], [ curr_libs="$LIBS"; curr_cppflags="$CPPFLAGS" PKG_CHECK_MODULES([GMP], [gmp], [], [ PKG_CHECK_MODULES([GMP], [libgmp], [], [# @@ -737,27 +737,27 @@ AS_IF([test "$USE_MATH" = "gmp" -o "$USE_MATH" = "check"], [ fi LIBS="$LIBS $GMP_LIBS" AC_CHECK_HEADERS([gmp.h], [ - AC_MSG_CHECKING([if linking against libgmp with "$GMP_LIBS" works]) + AC_MSG_CHECKING([whether linking against libgmp with "$GMP_LIBS" works]) AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[mpz_t integ; mpz_init (integ);]])], [AC_MSG_RESULT([yes]) curr_cppflags=$CPPFLAGS # for the include in cobc generated modules LIBCOB_LIBS="$LIBCOB_LIBS $GMP_LIBS" - USE_MATH=gmp], + with_math=gmp], [AC_MSG_RESULT([no]) - if test "$USE_MATH" = "gmp"; then + if test "$with_math" = gmp; then AC_MSG_ERROR([[GMP is required for --with-math=gmp, you may adjust GMP_LIBS]]) fi LIBS="$curr_libs"; CPPFLAGS="$curr_cppflags"] ) - ], [if test "$USE_MATH" = "gmp"; then + ], [if test "$with_math" = gmp; then AC_MSG_ERROR([gmp.h is required for --with-math=gmp, you may adjust GMP_CFLAGS]) fi LIBS="$curr_libs"; CPPFLAGS="$curr_cppflags" ]) ]) -AS_IF([test "$USE_MATH" = "mpir" -o "$USE_MATH" = "check"], [ +AS_IF([test "$with_math" = mpir -o "$with_math" = check], [ # note: currently MPIR does not ship a .pc file, but is expected to follow GMP curr_libs="$LIBS"; curr_cppflags="$CPPFLAGS" PKG_CHECK_MODULES([MPIR], [mpir], [], [# @@ -770,28 +770,28 @@ AS_IF([test "$USE_MATH" = "mpir" -o "$USE_MATH" = "check"], [ fi LIBS="$LIBS $MPIR_LIBS" AC_CHECK_HEADERS([mpir.h], [ - AC_MSG_CHECKING([if linking against libmpir with "$MPIR_LIBS" works]) + AC_MSG_CHECKING([whether linking against libmpir with "$MPIR_LIBS" works]) AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[mpz_t integ; mpz_init (integ);]])], [AC_MSG_RESULT([yes]) curr_cppflags=$CPPFLAGS # for the include in cobc generated modules LIBCOB_LIBS="$LIBCOB_LIBS $MPIR_LIBS" - USE_MATH=mpir], + with_math=mpir], [AC_MSG_RESULT([no]) - if test "$USE_MATH" = "mpir"; then + if test "$with_math" = mpir; then AC_MSG_ERROR([[MPIR is required for --with-math=mpir, you may adjust MPIR_LIBS]]) fi LIBS="$curr_libs"; CPPFLAGS="$curr_cppflags"] ) - ], [if test "$USE_MATH" = "mpir"; then + ], [if test "$with_math" = mpir; then AC_MSG_ERROR([mpir.h is required for --with-math=mpir, you may adjust MPIR_CFLAGS]) fi LIBS="$curr_libs"; CPPFLAGS="$curr_cppflags" ]) ]) -if test "$USE_MATH" = "check"; then - AC_MSG_ERROR([neither GMP nor MPIR library are found, but one of those is mandatory]) +if test "$with_math" = check; then + AC_MSG_FAILURE([neither GMP nor MPIR library are found, but one of those is mandatory]) fi AC_MSG_CHECKING([matching GMP version]) @@ -818,11 +818,11 @@ AC_RUN_IFELSE([AC_LANG_SOURCE([[ } ]])], [COB_GMP_LIB=$(./conftest$ac_exeext x)], - [AC_MSG_ERROR([Unable to extract GMP version information from gmp_version])], + [AC_MSG_ERROR([unable to extract GMP version information from gmp_version])], [AC_MSG_WARN([matching GMP version assumed])] COB_GMP_LIB="cross") if test "x$COB_GMP_LIB" = x; then - AC_MSG_ERROR([Unable to extract GMP version information (library)]) + AC_MSG_ERROR([unable to extract GMP version information (library)]) fi # get GMP version from header @@ -842,11 +842,11 @@ AC_RUN_IFELSE([AC_LANG_SOURCE([[ } ]])], [COB_GMP_HEADER=$(./conftest$ac_exeext x)], - [AC_MSG_ERROR([Unable to extract GMP version information from header])], + [AC_MSG_ERROR([unable to extract GMP version information from header])], [AC_MSG_WARN([cannot run test program while cross-compiling]) COB_GMP_HEADER="cross-compilation - assumed"]) if test "x$COB_GMP_HEADER" = x; then - AC_MSG_ERROR([Unable to extract GMP version information (header)]) + AC_MSG_ERROR([unable to extract GMP version information (header)]) fi COB_GMP_LIB_MAJOR=$(echo "$COB_GMP_LIB" | cut -d. -f1) @@ -856,13 +856,13 @@ if test "$COB_GMP_HEADER" = "$COB_GMP_LIB_MAJOR.$COB_GMP_LIB_MINOR" -o "$COB_GMP AC_MSG_RESULT([yes ($COB_GMP_HEADER)]) else AC_MSG_RESULT([no (header: $COB_GMP_HEADER / library: $COB_GMP_LIB)]) - AC_MSG_ERROR([Unable to use GMP - Please check config.log]) + AC_MSG_FAILURE([unable to use GMP]) fi LIBS="$curr_libs" CPPFLAGS="$curr_cppflags" -AC_CHECK_LIB([$USE_MATH], [__gmp_get_memory_functions], +AC_CHECK_LIB([$with_math], [__gmp_get_memory_functions], [AC_DEFINE([HAVE_MP_GET_MEMORY_FUNCTIONS], [1])], [], []) @@ -876,16 +876,16 @@ AC_ARG_WITH([xml2], [], [with_xml2=check]) -AS_IF([test "$with_xml2" = "yes" -o "$with_xml2" = "check"], [ +AS_IF([test "$with_xml2" = yes -o "$with_xml2" = check], [ PKG_CHECK_MODULES([XML2], [libxml-2.0], [], [ if test -z "${XML2_CFLAGS+x}" -o -z "${XML2_LIBS+x}"; then - AC_CHECK_PROG(xml2_config_found, xml2-config, "yes") - if test "$xml2_config_found" = "yes"; then - if test -z "${XML2_CFLAGS+x}"; then - XML2_CFLAGS="$(xml2-config --cflags)" + AC_PATH_PROG(XML2_CONFIG, xml2-config) + if test -n "$XML2_CONFIG"; then + if test -z "$XML2_CFLAGS"; then + XML2_CFLAGS="$($XML2_CONFIG --cflags)" fi - if test -z "${XML2_LIBS+x}"; then - XML2_LIBS="$(xml2-config --libs)" + if test -z "$XML2_LIBS"; then + XML2_LIBS="$($XML2_CONFIG --libs)" fi fi fi]) @@ -897,23 +897,22 @@ AS_IF([test "$with_xml2" = "yes" -o "$with_xml2" = "check"], [ XML2_LIBS="-lxml2" fi LIBS="$LIBS $XML2_LIBS" - # note: the include part is likely wrong, as PKG_CONFIG and xml2_config - # normally include _with_ "libxml", so only the header name should be - # used then - needs adjustments in both configure and libcob! - for header in xmlversion uri xmlwriter - do + # note: PKG_CONFIG and xml2-config set -I /path/to/libxml2 which contains a "libxml" folder where + # all the files we look for are included + for header in xmlwriter xmlversion uri parser tree; do AC_CHECK_HEADER([libxml/$header.h], [], - [if test "$with_xml2" = "yes"; then - AC_MSG_ERROR([Headers for libxml2 are required for --with-xml2, you may adjust XML2_CFLAGS]) - else + [if test "$with_xml2" = yes; then + AC_MSG_ERROR([headers for libxml2 are required for --with-xml2, you may adjust XML2_CFLAGS]) + else + AC_MSG_WARN([headers for libxml2 are missing, you may adjust XML2_CFLAGS]) with_xml2=not_found break - fi] + fi] ) done if test "$with_xml2" != "not_found"; then AX_CHECK_DEFINE([libxml/xmlwriter.h], [LIBXML_WRITER_ENABLED], [], - [if test "$with_xml2" = "yes"; then + [if test "$with_xml2" = yes; then AC_MSG_ERROR([libxml2 is required to be configured with xmlWriter]) else AC_MSG_WARN([libxml2 is required to be configured with xmlWriter]) @@ -922,7 +921,7 @@ AS_IF([test "$with_xml2" = "yes" -o "$with_xml2" = "check"], [ ) fi if test "$with_xml2" != "not_found"; then - AC_MSG_CHECKING([if linking against libxml2 with "$XML2_LIBS" works]) + AC_MSG_CHECKING([whether linking against libxml2 with "$XML2_LIBS" works]) AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[xmlNewTextWriterFilename (NULL, 0);]])], [AC_DEFINE([WITH_XML2], [1]) AC_MSG_RESULT([yes]) @@ -930,7 +929,7 @@ AS_IF([test "$with_xml2" = "yes" -o "$with_xml2" = "check"], [ LIBCOB_CPPFLAGS="$LIBCOB_CPPFLAGS $XML2_CFLAGS" LIBCOB_LIBS="$LIBCOB_LIBS $XML2_LIBS"], [AC_MSG_RESULT([no]) - if test "$with_xml2" = "yes"; then + if test "$with_xml2" = yes; then AC_MSG_ERROR([[xml library is required for --with-xml2, you may adjust XML2_LIBS]]) else AC_MSG_WARN([xml library not found, you may adjust XML2_LIBS]) @@ -957,7 +956,7 @@ AC_ARG_WITH([json], USE_JSON="$with_json" ;; yes) - USE_JSON="check" + USE_JSON=check ;; *) AC_MSG_ERROR([invalid value "$with_json" for --with-json, @@ -968,15 +967,15 @@ AC_ARG_WITH([json], no (disable json usage)]) ;; esac], - [USE_JSON="check"]) + [USE_JSON=check]) curr_libs="$LIBS" -AS_IF([test "$USE_JSON" = "cjson" -o "$USE_JSON" = "local" -o "$USE_JSON" = "check"], [ +AS_IF([test "$USE_JSON" = "cjson" -o "$USE_JSON" = "local" -o "$USE_JSON" = check], [ AC_MSG_NOTICE([Checks for local cJSON ...]) curr_libs="$LIBS"; curr_cppflags="$CPPFLAGS" with_cjson_local=no AS_IF([test -e ./libcob/cJSON.c], - [AC_MSG_CHECKING([if linking of ./libcob/cJSON.c works]) + [AC_MSG_CHECKING([whether linking of ./libcob/cJSON.c works]) CPPFLAGS="$curr_cppflags -I./libcob" LIBS="$LIBS $COMMON_LIBS" AC_LINK_IFELSE([ @@ -992,9 +991,9 @@ AS_IF([test "$USE_JSON" = "cjson" -o "$USE_JSON" = "local" -o "$USE_JSON" = "che ) LIBS="$curr_libs"] ) - if test "$with_cjson_local" = "no"; then + if test "$with_cjson_local" = no; then AS_IF([test -e "$srcdir/libcob/cJSON.c"], - [AC_MSG_CHECKING([if linking of "$srcdir/libcob/cJSON.c" works]) + [AC_MSG_CHECKING([whether linking of "$srcdir/libcob/cJSON.c" works]) CPPFLAGS="$curr_cppflags -I\"$srcdir/libcob\"" LIBS="$LIBS $COMMON_LIBS" AC_LINK_IFELSE([ @@ -1012,7 +1011,7 @@ AS_IF([test "$USE_JSON" = "cjson" -o "$USE_JSON" = "local" -o "$USE_JSON" = "che ) fi CPPFLAGS="$curr_cppflags" - AS_IF([test "$with_cjson_local" = "no"], [ + AS_IF([test "$with_cjson_local" = no], [ AC_MSG_NOTICE([using local cJSON: no]) if test "$with_json" = "local"; then AC_MSG_ERROR([[cJSON source is required in directory "libcob" for --with-json=local]]) @@ -1026,16 +1025,15 @@ AS_IF([test "$USE_JSON" = "cjson" -o "$USE_JSON" = "local" -o "$USE_JSON" = "che CJSON_LIBS="-lcjson" fi LIBS="$LIBS $CJSON_LIBS" - AC_CHECK_HEADERS([cJSON.h], [], - [AC_CHECK_HEADERS([cjson/cJSON.h], [], + AC_CHECK_HEADERS([cJSON.h cjson/cJSON.h], [break], [if test "$with_json" = "cjson"; then - AC_MSG_ERROR([Headers for libcjson are required for --with-json=cjson, you may adjust CJSON_CFLAGS]) + AC_MSG_ERROR([header for libcjson is required for --with-json=cjson, you may adjust CJSON_CFLAGS]) else - AC_MSG_WARN([Headers for libcjson missing, you may adjust CJSON_CFLAGS or put cJSON sources in "libcob"]) + AC_MSG_WARN([header for libcjson missing, you may adjust CJSON_CFLAGS or put cJSON sources in "libcob"]) fi] - )]) - AS_IF([test "x$ac_cv_header_cJSON_h" = "xyes" -o "x$ac_cv_header_cjson_cJSON_h" = "xyes"], [ - AC_MSG_CHECKING([if linking against libcjson with "$CJSON_LIBS" works]) + ) + AS_IF([test "x$ac_cv_header_cJSON_h" = xyes -o "x$ac_cv_header_cjson_cJSON_h" = xyes], [ + AC_MSG_CHECKING([whether linking against libcjson with "$CJSON_LIBS" works]) AC_LINK_IFELSE([AC_LANG_PROGRAM([ [#if defined HAVE_CJSON_CJSON_H #include @@ -1066,12 +1064,10 @@ AS_IF([test "$USE_JSON" = "cjson" -o "$USE_JSON" = "local" -o "$USE_JSON" = "che LIBS="$curr_libs"; CPPFLAGS="$curr_cppflags" ]) -AS_IF([test "$USE_JSON" = "json-c" -o "$USE_JSON" = "check"], [ +AS_IF([test "$USE_JSON" = "json-c" -o "$USE_JSON" = check], [ CPPFLAGS="$curr_cppflags" PKG_CHECK_MODULES([JSON_C], [json-c], [], [# ]) - # possibly set JSON_C_CFLAGS with $includedir/json-c; - # (has to consider user-setprefix --includir, ... -> left out for now) if test -n "$JSON_C_CFLAGS"; then CPPFLAGS="$CPPFLAGS $JSON_C_CFLAGS" fi @@ -1079,16 +1075,15 @@ AS_IF([test "$USE_JSON" = "json-c" -o "$USE_JSON" = "check"], [ JSON_C_LIBS="-ljson-c" fi LIBS="$LIBS $JSON_C_LIBS" - AC_CHECK_HEADERS([json.h], [], - [AC_CHECK_HEADERS([json-c/json.h], [], + AC_CHECK_HEADERS([json.h json-c/json.h], [break], [if test "$with_json" = "json-c"; then - AC_MSG_ERROR([Headers for libjson-c are required for --with-json=json-c, you may adjust JSON_C_CFLAGS]) + AC_MSG_ERROR([header for libjson-c is required for --with-json=json-c, you may adjust JSON_C_CFLAGS]) else - AC_MSG_WARN([Headers for libjson-c missing, you may adjust JSON_C_CFLAGS]) + AC_MSG_WARN([header for libjson-c missing, you may adjust JSON_C_CFLAGS]) fi] - )]) - AS_IF([test "x$ac_cv_header_json_h" = "xyes" -o "x$ac_cv_header_json_c_json_h" = "xyes"], [ - AC_MSG_CHECKING([if linking against libjson-c with "$JSON_C_LIBS" works]) + ) + AS_IF([test "x$ac_cv_header_json_h" = xyes -o "x$ac_cv_header_json_c_json_h" = xyes], [ + AC_MSG_CHECKING([whether linking against libjson-c with "$JSON_C_LIBS" works]) AC_LINK_IFELSE([AC_LANG_PROGRAM([ [#if defined (HAVE_JSON_C_JSON_H) #include @@ -1110,19 +1105,14 @@ AS_IF([test "$USE_JSON" = "json-c" -o "$USE_JSON" = "check"], [ else AC_MSG_WARN([JSON-C not found, you may adjust JSON_C_LIBS]) fi]) - ], - [if test "$USE_JSON" = "json-c"; then - AC_MSG_ERROR([Headers for libjson-c are required for --with-json-c, you may adjust JSON_C_CFLAGS]) - else - AC_MSG_WARN([Headers for libjson-c missing, you may adjust JSON_C_CFLAGS"]) - fi]) + ]) LIBS="$curr_libs"; CPPFLAGS="$curr_cppflags" ]) case "$USE_JSON" in check) if test "$with_json" = yes; then - AC_MSG_ERROR([[No applicable handler for JSON found]]) + AC_MSG_FAILURE([[no applicable handler for JSON found]]) fi USE_JSON="not_found" AC_DEFINE([WITH_JSON], ["not found"]) @@ -1147,7 +1137,7 @@ AC_ARG_WITH([dl], ;; no) ;; - *) AC_MSG_ERROR([[--with/without-dl can not have a value]]) + *) AC_MSG_ERROR([[--with/without-dl can not have an argument]]) ;; esac], [with_dl=yes]) @@ -1156,13 +1146,13 @@ AC_ARG_WITH([varseq], [AS_HELP_STRING([--with-varseq], [(GnuCOBOL) Define variable sequential format (default 0)])], [case $with_varseq in - yes) AC_MSG_ERROR([[You must give --with-varseq an argument.]]) + yes) AC_MSG_ERROR([[--with-varseq needs an argument]]) ;; - no) AC_MSG_ERROR([[--without-varseq not supported.]]) + no) AC_MSG_ERROR([[--without-varseq not supported]]) ;; [[0-3]]) ;; - *) AC_MSG_ERROR([[Invalid --with-varseq argument]]) + *) AC_MSG_ERROR([[invalid --with-varseq argument]]) ;; esac], [with_varseq=0]) @@ -1175,12 +1165,12 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[nanosleep (NULL, NULL);]])], [AC_DEFINE([HAVE_NANO_SLEEP], [1])], [AC_CHECK_LIB([rt], [nanosleep], [], [], []) - if test "x$ac_cv_lib_rt_nanosleep" = "xyes"; then + if test "x$ac_cv_lib_rt_nanosleep" = xyes; then AC_DEFINE([HAVE_NANO_SLEEP], [1]) LIBCOB_LIBS="$LIBCOB_LIBS -lrt" else AC_CHECK_LIB([posix4], [nanosleep], [], [], []) - if test "x$ac_cv_lib_posix4_nanosleep" = "xyes"; then + if test "x$ac_cv_lib_posix4_nanosleep" = xyes; then AC_DEFINE([HAVE_NANO_SLEEP], [1]) LIBCOB_LIBS="$LIBCOB_LIBS -lposix4" fi @@ -1245,7 +1235,7 @@ AC_ARG_WITH([curses], USE_CURSES="$with_curses" ;; yes) - USE_CURSES="check" + USE_CURSES=check ;; *) AC_MSG_ERROR([invalid value "$with_curses" for --with-curses, @@ -1255,75 +1245,77 @@ AC_ARG_WITH([curses], no (disable curses usage)]) ;; esac], - [USE_CURSES="check"]) + [USE_CURSES=check]) curr_libs="$LIBS" # backup current LIBS for later if test "x$CURSES_LIBS" != x; then LIBS="$CURSES_LIBS $LIBS" - AC_MSG_CHECKING([if linking initscr works with CURSES_LIBS, given as "$CURSES_LIBS"]) + AC_MSG_CHECKING([whether linking initscr works with CURSES_LIBS, given as "$CURSES_LIBS"]) AC_LINK_IFELSE([AC_LANG_PROGRAM([[ extern void *initscr (void);]], [[initscr ();]])], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]) - AC_MSG_ERROR([[Not able to link initscr with CURSES_LIBS]])]) + AC_MSG_FAILURE([[not able to link initscr with CURSES_LIBS]])]) AS_IF([test "$USE_CURSES" = check -o "$USE_CURSES" = no], [ - AC_MSG_ERROR([[explicit selection with --with-curses=ARG necessary, as CURSES_LIBS is set]]) + AC_MSG_ERROR([[explicit selection with --with-curses=ARG needed, as CURSES_LIBS is set]]) ]) LIBS=$"curr_libs" fi dnl note: when switching to $ncurses all checks are done correctly but no generation in config.h is done if test "x$CURSES_LIBS" = x; then - if test "$USE_CURSES" = "ncursesw" -o "$USE_CURSES" = "check"; then + if test "$USE_CURSES" = "ncursesw" -o "$USE_CURSES" = check; then AC_CHECK_LIB([ncursesw], [initscr], [true], [AS_IF([test "$USE_CURSES" != check], [USE_CURSES="missing_lib"])]) fi fi if test "$USE_CURSES" = "ncursesw" -o "x$ac_cv_lib_ncursesw_initscr" = xyes; then - AC_CHECK_HEADERS([ncursesw/ncurses.h], [USE_CURSES="ncursesw"], - [AC_CHECK_HEADERS([ncursesw/curses.h], [USE_CURSES="ncursesw"], - dnl note: at least OpenBSD has ncursesw only with only ncurses.h in default header directory - [AC_CHECK_HEADERS([ncurses.h], [USE_CURSES="ncursesw"], - [AS_IF([test "$USE_CURSES" != check], - [USE_CURSES="missing_header"]) ]) ]) ]) + dnl note: at least OpenBSD has ncursesw only with only ncurses.h in default header directory + AC_CHECK_HEADERS([ncursesw/ncurses.h ncursesw/curses.h ncurses.h], + [USE_CURSES="ncursesw" + break], + [AS_IF([test "$USE_CURSES" != check], + [USE_CURSES="missing_header"]) ]) AS_IF([test $USE_CURSES="ncursesw" -a "x$CURSES_LIBS" = x], [CURSES_LIBS="-l$USE_CURSES"]) fi if test "x$CURSES_LIBS" = x; then - if test "$USE_CURSES" = "ncurses" -o "$USE_CURSES" = "check"; then + if test "$USE_CURSES" = "ncurses" -o "$USE_CURSES" = check; then AC_CHECK_LIB([ncurses], [initscr], [true], [AS_IF([test "$USE_CURSES" != check], [USE_CURSES="missing_lib"])]) fi fi if test "$USE_CURSES" = "ncurses" -o "x$ac_cv_lib_ncurses_initscr" = xyes; then - AC_CHECK_HEADERS([ncurses/ncurses.h], [USE_CURSES="ncurses"], - [AC_CHECK_HEADERS([ncurses/curses.h], [USE_CURSES="ncurses"], - [AC_CHECK_HEADERS([ncurses.h], [USE_CURSES="ncurses"], - [AS_IF([test "$USE_CURSES" != check], - [USE_CURSES="missing_header"]) ]) ]) ]) + AC_CHECK_HEADERS([ncurses/ncurses.h ncurses/curses.h ncurses.h], + [USE_CURSES="ncurses" + break], + [AS_IF([test "$USE_CURSES" != check], + [USE_CURSES="missing_header"]) ]) AS_IF([test $USE_CURSES="ncurses" -a "x$CURSES_LIBS" = x], [CURSES_LIBS="-l$USE_CURSES"]) fi if test "x$CURSES_LIBS" = x; then - if test "$USE_CURSES" = "pdcurses" -o "$USE_CURSES" = "check"; then + if test "$USE_CURSES" = "pdcurses" -o "$USE_CURSES" = check; then AC_CHECK_LIB([pdcurses], [initscr], [true], [AS_IF([test "$USE_CURSES" != check], [USE_CURSES="missing_lib"])]) fi fi if test "$USE_CURSES" = "pdcurses" -o "x$ac_cv_lib_pdcurses_initscr" = xyes; then - AC_CHECK_HEADERS([pdcurses.h], [USE_CURSES="pdcurses"], - [AC_CHECK_HEADERS([curses.h], [USE_CURSES="pdcurses"], - [AS_IF([test "$USE_CURSES" != check], [USE_CURSES="missing_header"]) ]) ]) + AC_CHECK_HEADERS([pdcurses.g curses.h], + [USE_CURSES="pdcurses" + break], + [AS_IF([test "$USE_CURSES" != check], + [USE_CURSES="missing_header"]) ]) AS_IF([test $USE_CURSES="pdcurses" -a "x$CURSES_LIBS" = x], [CURSES_LIBS="-l$USE_CURSES"]) fi if test "x$CURSES_LIBS" = x; then - if test "$USE_CURSES" = "xcurses" -o "$USE_CURSES" = "check"; then + if test "$USE_CURSES" = "xcurses" -o "$USE_CURSES" = check; then # consider using xcurses-config # note: the library name is actually with an upper-case XC: AC_CHECK_LIB([XCurses], [initscr], [true], @@ -1331,16 +1323,18 @@ if test "x$CURSES_LIBS" = x; then fi fi if test "$USE_CURSES" = "xcurses" -o "x$ac_cv_lib_XCurses_initscr" = xyes; then - AC_CHECK_HEADERS([xcurses.h], [USE_CURSES="xcurses"], - [AC_CHECK_HEADERS([xcurses/curses.h], [USE_CURSES="xcurses"], - [AS_IF([test "$USE_CURSES" != check], [USE_CURSES="missing_header"]) ]) ]) + AC_CHECK_HEADERS([xcurses/curses.h xcurses.h], + [USE_CURSES="xcurses" + break], + [AS_IF([test "$USE_CURSES" != check], + [USE_CURSES="missing_header"]) ]) AS_IF([test $USE_CURSES="xcurses" -a "x$CURSES_LIBS" = x], # note: the library name is actually with an upper-case XC: [CURSES_LIBS="-lXCurses"]) fi if test "x$CURSES_LIBS" = x; then - if test "$USE_CURSES" = "curses" -o "$USE_CURSES" = "check"; then + if test "$USE_CURSES" = "curses" -o "$USE_CURSES" = check; then AC_CHECK_LIB([curses], [initscr], [true], [AS_IF([test "$USE_CURSES" != check], [USE_CURSES="missing_lib"])]) fi @@ -1361,10 +1355,10 @@ case "$USE_CURSES" in AC_DEFINE([WITH_CURSES], ["disabled"]) ;; missing_lib) - AC_MSG_ERROR([[Not able to link configured library $with_curses]]) + AC_MSG_FAILURE([[not able to link configured library $with_curses]]) ;; missing_header) - AC_MSG_ERROR([[No header found for configured library $with_curses]]) + AC_MSG_ERROR([[no header found for configured library $with_curses]]) ;; *curses*) AC_DEFINE_UNQUOTED([WITH_CURSES], ["$USE_CURSES"]) @@ -1390,7 +1384,7 @@ if test "$USE_CURSES" = "ncurses" -o "$USE_CURSES" = "ncursesw"; then []) fi -if test "$USE_CURSES" != "no" -a "$USE_CURSES" != "not_found"; then +if test "$USE_CURSES" != no -a "$USE_CURSES" != "not_found"; then AC_MSG_CHECKING([for curses color_set function]) AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #ifdef HAVE_NCURSESW_NCURSES_H @@ -1480,7 +1474,7 @@ LIBS="$curr_libs" # clean for next checks AC_ARG_WITH([seqra-extfh], [AS_HELP_STRING([--with-seqra-extfh], [(GnuCOBOL) Use external SEQ/RAN handler (obsolete)])], - [ if test "$with_seqra_extfh" = "yes"; then + [ if test "$with_seqra_extfh" = yes; then AC_DEFINE([WITH_SEQRA_EXTFH], [1]) fi ], []) @@ -1488,7 +1482,7 @@ AC_ARG_WITH([seqra-extfh], AC_ARG_WITH([cisam], [AS_HELP_STRING([--with-cisam], [(GnuCOBOL) Use CISAM for INDEXED I/O])], - [ if test "$with_cisam" = "yes"; then + [ if test "$with_cisam" = yes; then AC_CHECK_HEADERS([isam.h], [], AC_MSG_ERROR([isam.h is required for CISAM])) AC_CHECK_LIB([ifisam], [isopen], @@ -1498,11 +1492,11 @@ AC_ARG_WITH([cisam], fi ], []) -AS_IF([test "$with_cisam" != "yes"], [ +AS_IF([test "$with_cisam" != yes], [ AC_ARG_WITH([disam], [AS_HELP_STRING([--with-disam], [(GnuCOBOL) Use DISAM for INDEXED I/O])], - [ if test "$with_disam" = "yes"; then + [ if test "$with_disam" = yes; then AC_CHECK_HEADERS([disam.h], [], AC_MSG_ERROR([disam.h is required for DISAM])) @@ -1515,7 +1509,7 @@ AS_IF([test "$with_cisam" != "yes"], [ break, [], []) done - if test "$cob_got_disam" = "yes"; then + if test "$cob_got_disam" = yes; then AC_MSG_NOTICE([DISAM library found as -l$cobdisam]) else AC_MSG_ERROR([DISAM library not found]) @@ -1526,11 +1520,11 @@ AS_IF([test "$with_cisam" != "yes"], [ []) ]) -AS_IF([test "$with_cisam" != "yes" -a "$with_disam" != "yes"], [ +AS_IF([test "$with_cisam" != yes -a "$with_disam" != yes], [ AC_ARG_WITH([vbisam], [AS_HELP_STRING([--with-vbisam], [(GnuCOBOL) Use VBISAM for ISAM I/O])], - [ if test "$with_vbisam" = "yes"; then + [ if test "$with_vbisam" = yes; then AC_CHECK_HEADERS([vbisam.h], [], AC_MSG_ERROR([vbisam.h is required for VBISAM])) # note: isfullclose is available since 2.0, isopen since 1.0 @@ -1542,17 +1536,17 @@ AS_IF([test "$with_cisam" != "yes" -a "$with_disam" != "yes"], [ []) ]) -AS_IF([test "$with_cisam" != "yes" -a "$with_disam" != "yes" -a "$with_vbisam" != "yes"], [ +AS_IF([test "$with_cisam" != yes -a "$with_disam" != yes -a "$with_vbisam" != yes], [ AC_ARG_WITH([index-extfh], [AS_HELP_STRING([--with-index-extfh], [(GnuCOBOL) Use external ISAM file handler (obsolete)])], - [ if test "$with_index_extfh" = "yes"; then + [ if test "$with_index_extfh" = yes; then AC_DEFINE([WITH_INDEX_EXTFH], [1]) fi ], []) ]) -AS_IF([test "$with_cisam" != "yes" -a "$with_disam" != "yes" -a "$with_vbisam" != "yes" -a "$with_index_extfh" != "yes"], [ +AS_IF([test "$with_cisam" != yes -a "$with_disam" != yes -a "$with_vbisam" != yes -a "$with_index_extfh" != yes], [ AC_ARG_WITH([db], [AS_HELP_STRING([--with-db], [(GnuCOBOL) Use Berkeley DB >= 4.1 for ISAM I/O (default)])], @@ -1563,7 +1557,7 @@ AS_IF([test "$with_cisam" != "yes" -a "$with_disam" != "yes" -a "$with_vbisam" ! # Checks for db. AC_ARG_VAR([BDB_CFLAGS], [compiler flags necessary to preprocess/compile for Berkeley DB]) AC_ARG_VAR([BDB_LIBS], [linker flags for Berkeley DB, overriding automatic lookup]) -if test "$with_db" = "yes"; then +if test "$with_db" = yes; then AC_MSG_NOTICE([Checks for Berkeley DB ...]) curr_cppflags="$CPPFLAGS" @@ -1590,7 +1584,7 @@ if test "$with_db" = "yes"; then ]])], [COB_BDB_HEADER=$(./conftest$ac_exeext x)] [COB_BDB_HEADER_STR=$(./conftest$ac_exeext x y)], - [AC_MSG_ERROR([Unable to extract Berkeley DB version information from db.h])], + [AC_MSG_ERROR([unable to extract Berkeley DB version information from db.h])], [AC_MSG_WARN([cannot run test program while cross-compiling]) COB_BDB_HEADER="cross" COB_BDB_HEADER_STR="cross"]) @@ -1660,7 +1654,7 @@ if test "$with_db" = "yes"; then fi LIBS="$test_libs" unset test_libs - if test "$cob_got_db" = "yes"; then + if test "$cob_got_db" = yes; then AC_MSG_RESULT([yes]) if test "x$BDB_LIBS" != x; then AC_MSG_NOTICE([BDB library version $COB_BDB_HEADER linked with $BDB_LIBS]) @@ -1689,29 +1683,29 @@ if test "$with_db" = "yes"; then fi # Checks for dl/ltdl. -DEFINE_DL="no" +DEFINE_DL=no AC_MSG_CHECKING([for _WIN32]) AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ #ifndef _WIN32 # error macro not defined #endif]])], - [DEFINE_DL="yes" + [DEFINE_DL=yes AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no])]) -if test "$DEFINE_DL" = "no" -a "$with_dl" = "yes"; then - if test "x$ac_cv_header_dlfcn_h" = "xyes"; then - AC_CHECK_LIB([c], [dlopen], [DEFINE_DL="yes"], [], []) - if test "$DEFINE_DL" = "no"; then - AC_CHECK_LIB([dl], [dlopen], [DEFINE_DL="yes"], [], []) - if test "$DEFINE_DL" = "yes"; then +if test "$DEFINE_DL" = no -a "$with_dl" = yes; then + if test "x$ac_cv_header_dlfcn_h" = xyes; then + AC_CHECK_LIB([c], [dlopen], [DEFINE_DL=yes], [], []) + if test "$DEFINE_DL" = no; then + AC_CHECK_LIB([dl], [dlopen], [DEFINE_DL=yes], [], []) + if test "$DEFINE_DL" = yes; then AC_DEFINE([USE_LIBDL], [1]) LIBCOB_LIBS="$LIBCOB_LIBS -ldl" dnl AC_CHECK_LIB([dl], [dladdr], [AC_DEFINE([HAVE_DLADDR], [1])], [], []) else - AC_CHECK_LIB([dld], [dlopen], [DEFINE_DL="yes"], [], []) - if test "$DEFINE_DL" = "yes"; then + AC_CHECK_LIB([dld], [dlopen], [DEFINE_DL=yes], [], []) + if test "$DEFINE_DL" = yes; then AC_DEFINE([USE_LIBDL], [1]) LIBCOB_LIBS="$LIBCOB_LIBS -ldld" dnl AC_CHECK_LIB([dld], [dladdr], [AC_DEFINE([HAVE_DLADDR], [1])], [], []) @@ -1724,7 +1718,7 @@ if test "$DEFINE_DL" = "no" -a "$with_dl" = "yes"; then fi fi -if test "$DEFINE_DL" = "no"; then +if test "$DEFINE_DL" = no; then AC_CHECK_HEADERS([ltdl.h], [], AC_MSG_ERROR([ltdl.h is required]), []) AC_CHECK_LIB([ltdl], [lt_dlopen], [LIBCOB_LIBS="$LIBCOB_LIBS -lltdl"], @@ -1757,26 +1751,26 @@ AC_CHECK_SIZEOF(long long) AC_CHECK_SIZEOF(long) AC_CHECK_SIZEOF(void *) -AC_MSG_CHECKING([if size of long int = size of long long]) +AC_MSG_CHECKING([whether size of long int = size of long long]) AS_IF([test "$ac_cv_sizeof_long_int" = "$ac_cv_sizeof_long_long"], [AC_DEFINE([COB_LI_IS_LL], [1]) AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no])]) -AC_MSG_CHECKING([if long is 32 bits]) +AC_MSG_CHECKING([whether long is 32 bits]) AS_IF([test "$ac_cv_sizeof_long" = 4], [AC_DEFINE([COB_32_BIT_LONG], [1]) AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no])]) -AC_MSG_CHECKING([if pointer is longer than 32 bits]) +AC_MSG_CHECKING([whether pointer is longer than 32 bits]) AS_IF([test "$ac_cv_sizeof_void_p" -gt 4], - [COB_HAS_64_BIT_POINTER="yes" + [COB_HAS_64_BIT_POINTER=yes AC_DEFINE([COB_64_BIT_POINTER], [1]) AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no])]) dnl We likely don't need this and remove it before 4.0 final release dnl # Check gcc wrapv option -dnl if test "$COB_USES_GCC_NO_ICC" = "yes"; then +dnl if test "$COB_USES_GCC_NO_ICC" = yes; then dnl curr_cflags="$CFLAGS" dnl CFLAGS="$CFLAGS -fwrapv" dnl AC_MSG_CHECKING([for gcc -fwrapv option]) @@ -1868,12 +1862,12 @@ COB_EXPORT_DYN="$(eval echo $export_dynamic_flag_spec)" # FIXME: lt_prog_compiler_pic is not always correct, for example with occ COB_PIC_FLAGS=$(echo "$lt_prog_compiler_pic" | sed -e 's/^ //') -if test "$enable_cflags_setting" = "yes"; then - if test "$enable_hardening" != "yes"; then +if test "$enable_cflags_setting" = yes; then + if test "$enable_hardening" != yes; then # Remove -O2 option added by AC_PROG_CC and add -O0 - if test "$enable_debug" = "yes" -o "$enable_code_coverage" = "yes"; then + if test "$enable_debug" = yes -o "$enable_code_coverage" = yes; then CFLAGS=$(echo "$CFLAGS" | sed -e 's/ *-O@<:@0-9a-zA-Z@:>@* */ /g' -e 's/ $//' -e 's/^ //') - if test "$COB_USES_GCC" = "yes"; then + if test "$COB_USES_GCC" = yes; then CFLAGS="$CFLAGS -O0" fi fi @@ -1883,7 +1877,7 @@ fi unset enable_cflags_setting # Note: cobc.c assumed -g for all but _MSC_VER -if test "$ac_cv_prog_cc_g" = "yes"; then +if test "$ac_cv_prog_cc_g" = yes; then COB_DEBUG_FLAGS="-g" else COB_DEBUG_FLAGS="" @@ -1892,7 +1886,7 @@ fi # For debugging: add most expressive debug level if using GCC (compatible) curr_cflags="$CFLAGS" -AS_IF([test "$COB_USES_GCC" = "yes"], [ +AS_IF([test "$COB_USES_GCC" = yes], [ cob_temp_flags="-ggdb3" CFLAGS="$curr_cflags $cob_temp_flags" AC_MSG_CHECKING([for debug option $cob_temp_flags]) @@ -1928,7 +1922,7 @@ AS_IF([test "$COB_USES_GCC" = "yes"], [ ) ]) -if test "$enable_debug" = "yes"; then +if test "$enable_debug" = yes; then if test "x$curr_cflags" != "x"; then CFLAGS="$curr_cflags $COB_DEBUG_FLAGS" else @@ -1938,10 +1932,10 @@ else CFLAGS="$curr_cflags" fi -AS_IF([test "$enable_hardening" = "yes"], [ +AS_IF([test "$enable_hardening" = yes], [ AC_MSG_NOTICE([Compile with hardening options]) # needs optimization - #if test "$enable_debug" = "yes"; then + #if test "$enable_debug" = yes; then # CFLAGS="$CFLAGS -O" #fi CPPFLAGS="$CPPFLAGS -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2" @@ -1970,7 +1964,7 @@ AS_IF([test "$enable_hardening" = "yes"], [ unset cob_temp_flags ]) -AS_IF([test "$COB_USES_GCC" = "yes"], [ +AS_IF([test "$COB_USES_GCC" = yes], [ curr_cflags="$CFLAGS" AC_CACHE_CHECK([for -pipe option], gc_cv_gcc_pipe, [ CFLAGS="$CFLAGS -pipe" @@ -2008,13 +2002,13 @@ fi # compiler specific general options for COB_CFLAGS, originating from cobc.c (main) -if test "$COB_USES_ICC_ONLY" = "yes"; then +if test "$COB_USES_ICC_ONLY" = yes; then # these are deprecated... COB_CFLAGS="$COB_CFLAGS -vec-report0 -opt-report 0" -elif test "$COB_USES_WATCOMC_ONLY" = "yes"; then +elif test "$COB_USES_WATCOMC_ONLY" = yes; then # -s = no overflow checks, otherwise need to code/link a CHK routine COB_CFLAGS="$COB_CFLAGS -s -wcd=118" -elif test "$COB_USES_XLC_ONLY" = "yes"; then +elif test "$COB_USES_XLC_ONLY" = yes; then # use read-only memory for string literals and constants COB_CFLAGS="$COB_CFLAGS -qro -qroconst" # allow nonstandard usage - CHECKME where do we need this ??? @@ -2024,7 +2018,7 @@ elif test "$COB_USES_XLC_ONLY" = "yes"; then COB_CFLAGS="$COB_CFLAGS -qsuppress=1500-030" fi -if test "$COB_USES_GCC_NO_ICC" = "yes"; then +if test "$COB_USES_GCC_NO_ICC" = yes; then # comment from cobc.c: --param max-goto-duplication-insns=100000 # /* RXWRXW - gcse */ # COB_CFLAGS="$COB_CFLAGS -Wno-unused -fsigned-char -fno-gcse" @@ -2032,8 +2026,8 @@ if test "$COB_USES_GCC_NO_ICC" = "yes"; then fi # Check gcc 4 pointer sign option (at least available with "recent" clang, too) -#if test "$COB_USES_GCC_NO_ICC" = "yes"; then -if test "$COB_USES_XLC_ONLY" != "yes"; then +#if test "$COB_USES_GCC_NO_ICC" = yes; then +if test "$COB_USES_XLC_ONLY" != yes; then curr_cflags="$CFLAGS" CFLAGS="$CFLAGS -Wno-pointer-sign" AC_MSG_CHECKING([for gcc pointer sign option]) @@ -2044,7 +2038,7 @@ if test "$COB_USES_XLC_ONLY" != "yes"; then fi #fi -if test "$COB_USES_CLANG_ONLY" = "yes"; then +if test "$COB_USES_CLANG_ONLY" = yes; then # don't warn if cobc uses arguments which aren't picked up (likely because of the translation phase) COB_CFLAGS="$COB_CFLAGS -Qunused-arguments" fi @@ -2098,7 +2092,7 @@ cob_temp_flags=$(echo x$cob_temp_flags | \ if test "x$cob_temp_flags" != x; then COB_CFLAGS="$cob_temp_flags $COB_CFLAGS" fi -if test "$enable_hardening" = "yes"; then +if test "$enable_hardening" = yes; then # needs optimization COB_CFLAGS="$COB_CFLAGS -O" fi @@ -2125,26 +2119,26 @@ case $host_os in COB_CONFIG_DIR="$(cd /usr && pwd -W)/local/share/$PACKAGE_TARNAME/config" COB_COPY_DIR="$(cd /usr && pwd -W)/local/share/$PACKAGE_TARNAME/copy" fi - if test "$COB_USES_GCC" = "yes"; then + if test "$COB_USES_GCC" = yes; then COB_EXPORT_DYN="-Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--enable-auto-image-base" COB_FIX_LIBTOOL="-Wl,--enable-auto-import" fi #COB_FIX_LIB="" ;; cygwin*) - if test "$COB_USES_GCC" = "yes"; then + if test "$COB_USES_GCC" = yes; then COB_EXPORT_DYN="-Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--enable-auto-image-base" COB_FIX_LIBTOOL="-Wl,--enable-auto-import" fi #COB_FIX_LIB="" ;; darwin* | rhapsody*) - if test "$COB_USES_GCC" = "yes"; then + if test "$COB_USES_GCC" = yes; then COB_SHARED_OPT="-bundle -flat_namespace -undefined suppress" fi ;; hpux*) - if test "$COB_USES_GCC" != "yes"; then + if test "$COB_USES_GCC" != yes; then COB_SHARED_OPT="-b" AC_DEFINE([_XOPEN_SOURCE_EXTENDED], [1]) rm -f hptest* @@ -2158,7 +2152,7 @@ case $host_os in COB_CFLAGS="$COB_CFLAGS +Olit=all -w" fi - if test "$enable_debug" = "yes"; then + if test "$enable_debug" = yes; then CFLAGS="$CFLAGS +O0" else CFLAGS="$CFLAGS +O2" @@ -2169,9 +2163,9 @@ case $host_os in ;; aix*) COB_EXPORT_DYN="-Wl,-bexpfull -Wl,-brtl" - if test "$COB_USES_GCC" != "yes"; then + if test "$COB_USES_GCC" != yes; then CFLAGS="$CFLAGS -Q -qro -qroconst" - if test "$enable_debug" = "yes"; then + if test "$enable_debug" = yes; then CFLAGS="$CFLAGS -qnoopt" else CFLAGS="$CFLAGS -O2" @@ -2186,9 +2180,9 @@ case $host_os in fi ;; solaris*) - if test "$COB_USES_GCC" != "yes"; then + if test "$COB_USES_GCC" != yes; then CFLAGS="$CFLAGS -xstrconst" - if test "$enable_debug" != "yes"; then + if test "$enable_debug" != yes; then CFLAGS="$CFLAGS -xO2" fi COB_CFLAGS="$COB_CFLAGS -xstrconst" @@ -2197,12 +2191,12 @@ case $host_os in ;; esac -if test "$COB_USES_ICC_ONLY" = "yes"; then - if test "$enable_debug" != "yes"; then +if test "$COB_USES_ICC_ONLY" = yes; then + if test "$enable_debug" != yes; then CFLAGS="$CFLAGS -finline-functions" fi CFLAGS="$CFLAGS -Wall -wd1419 -vec-report0 -opt-report 0" -elif test "$COB_USES_GCC" = "yes" && test "$with_gnu_ld" = "yes"; then +elif test "$COB_USES_GCC" = yes && test "$with_gnu_ld" = yes; then curr_ldflags="$LDFLAGS" LDFLAGS="$LDFLAGS -Wl,-z,relro,-z,now,-O1" AC_MSG_CHECKING([for ld bind now option]) @@ -2211,37 +2205,37 @@ elif test "$COB_USES_GCC" = "yes" && test "$with_gnu_ld" = "yes"; then [LDFLAGS=$curr_ldflags AC_MSG_RESULT([no])]) unset curr_ldflags - if test "$enable_debug" != "yes"; then + if test "$enable_debug" != yes; then CFLAGS="$CFLAGS -finline-functions" fi CFLAGS="$CFLAGS -fsigned-char -Wall -Wwrite-strings -Wmissing-prototypes -Wno-format-y2k" fi -if test "x$lt_cv_dlopen_self" != "xyes"; then +if test "x$lt_cv_dlopen_self" != xyes; then AC_DEFINE([COB_NO_SELFOPEN], [1]) fi -if test "$with_cisam" = "yes"; then +if test "$with_cisam" = yes; then COB_HAS_ISAM=cisam -elif test "$with_disam" = "yes"; then +elif test "$with_disam" = yes; then COB_HAS_ISAM=disam -elif test "$with_vbisam" = "yes"; then +elif test "$with_vbisam" = yes; then COB_HAS_ISAM=vbisam -elif test "$with_db" = "yes"; then +elif test "$with_db" = yes; then COB_HAS_ISAM=db -elif test "$with_index_extfh" = "yes"; then +elif test "$with_index_extfh" = yes; then COB_HAS_ISAM=index_extfh else COB_HAS_ISAM=no fi -if test "$USE_CURSES" = "not_found" -o "$USE_CURSES" = "no"; then +if test "$USE_CURSES" = "not_found" -o "$USE_CURSES" = no; then COB_HAS_CURSES=no else COB_HAS_CURSES=yes fi -if test "$with_xml2" = "yes"; then +if test "$with_xml2" = yes; then COB_HAS_XML2=yes with_xml2=libxml2 else @@ -2374,14 +2368,14 @@ AC_MSG_NOTICE([ COB_EXPORT_DYN ${COB_EXPORT_DYN}]) if test "x$striplib" != x; then AC_MSG_NOTICE([ COB_STRIP_CMD ${striplib}]) fi -if test "${DEFINE_DL}" = "yes" ; then +if test "${DEFINE_DL}" = yes ; then AC_MSG_NOTICE([ Dynamic loading: System]) else AC_MSG_NOTICE([ Dynamic loading: Libtool]) fi AC_MSG_NOTICE([ Use gettext for international messages: ${USE_NLS}]) AC_MSG_NOTICE([ Use fcntl for file locking: ${ac_cv_func_fcntl}]) -AC_MSG_NOTICE([ Use math multiple precision library: ${USE_MATH}]) +AC_MSG_NOTICE([ Use math multiple precision library: ${with_math}]) case "$USE_CURSES" in not_found) AC_MSG_NOTICE([ screen I/O (no curses found): NO]) @@ -2393,23 +2387,23 @@ case "$USE_CURSES" in AC_MSG_NOTICE([ Use curses library for screen I/O: ${USE_CURSES}]) ;; esac -if test "$with_debug_log" = "yes"; then +if test "$with_debug_log" = yes; then AC_MSG_NOTICE([ Enable GnuCOBOL developer logging yes]) fi -if test "$with_seqra_extfh" = "yes"; then +if test "$with_seqra_extfh" = yes; then AC_MSG_NOTICE([ Use external SEQ/RAN file handler: yes]) AC_MSG_WARN([ Obsolete feature "OpenCOBOL-only-EXTFH" used!]) fi -if test "$with_index_extfh" = "yes"; then +if test "$with_index_extfh" = yes; then AC_MSG_NOTICE([ Use external INDEXED file handler: yes]) AC_MSG_WARN([ Obsolete feature "OpenCOBOL-only-EXTFH" used!]) -elif test "$with_cisam" = "yes"; then +elif test "$with_cisam" = yes; then AC_MSG_NOTICE([ Use CISAM for INDEXED I/O: yes]) -elif test "$with_disam" = "yes"; then +elif test "$with_disam" = yes; then AC_MSG_NOTICE([ Use DISAM for INDEXED I/O: yes]) -elif test "$with_vbisam" = "yes"; then +elif test "$with_vbisam" = yes; then AC_MSG_NOTICE([ Use VBISAM for INDEXED I/O: yes]) -elif test "$with_db" = "yes"; then +elif test "$with_db" = yes; then AC_MSG_NOTICE([ Use Berkeley DB for INDEXED I/O: yes]) else AC_MSG_NOTICE([ INDEXED I/O (no handler configured): NO]) diff --git a/libcob/ChangeLog b/libcob/ChangeLog index decb43043..911138e1c 100644 --- a/libcob/ChangeLog +++ b/libcob/ChangeLog @@ -1,10 +1,49 @@ +2023-03-03 Simon Sobisch + + * common.c, common.h: new external field + define COB_ZEROES_ALPHABETIC / + COB_ZEROES_ALPHABETIC_BYTE_LENGTH + * common.c (compare_zeroes): new function for common comparison to ZERO + * common.c (compare_character): fix issue with not comparing last bytes + +2023-02-27 Simon Sobisch + + * screenio.c (field_accept): minor refactoring to not update + COB_TERM_BUFF for ACCEPT OMITTED + +2023-02-24 Simon Sobisch + + * common.c (cob_check_beyond_exit), common.h: fix prototype to match strings + * numeric.c (cob_decimal_get_packed): removed code for "huge packed" fields + as we don't have packed fields with more than 38 digits + * numeric.c (cob_pow_10): unsigned parameter, fixing some overflows in GMP + +2023-02-24 Ron Norman + + * move.c (cob_get_s64_pic9) [COB_EBCDIC_MACHINE]: fix negative sign lookup + +2023-02-22 Simon Sobisch + + fix bug #874 DISPLAY of 9P fields (P to the left of the decimal point) + * termio.c (pretty_display_numeric): fix printing one byte after + actual data + * termio.c (display_numeric): fix printing amount of P as leading zeroes + 2023-02-21 Simon Sobisch * numeric.c (cob_decimal_set_packed): backport and extend optimization from 4.x by Ron - now skipping initial zeros and for huge fields handle 4 digits at once +2023-02-20 Simon Sobisch + + * intrinsic.c, numeric.c: explicit check result of mpz_sgn to 0/!0/1/-1 + * intrinsic.c (cob_intr_random): fix binary end for implicit seed + * intrinsic.c (numval): minor optimization for invalid numeric + * termio.c (display_numeric, pretty_display_numeric): use common + COB_FIELD_INIT instead of manually init of field named "temp"; + minor speedup in output + 2023-02-10 Simon Sobisch * numeric.c (cob_bcd_cmp, packed_is_negative, decimal_convert_scale, diff --git a/libcob/common.c b/libcob/common.c index 3fb9a9e79..7fbce2429 100644 --- a/libcob/common.c +++ b/libcob/common.c @@ -248,6 +248,13 @@ const char *COB_SPACES_ALPHABETIC = SPACE_1024; #undef SPACE_64 #undef SPACE_256 #undef SPACE_1024 +#define ZERO_16 "0000000000000000" +#define ZERO_64 ZERO_16 ZERO_16 ZERO_16 ZERO_16 +#define ZERO_256 ZERO_64 ZERO_64 ZERO_64 ZERO_64 +const char *COB_ZEROES_ALPHABETIC = ZERO_256; +#undef ZERO_16 +#undef ZERO_64 +#undef ZERO_256 struct cob_alloc_cache { struct cob_alloc_cache *next; /* Pointer to next */ @@ -1750,26 +1757,34 @@ static int compare_character (const unsigned char *data, size_t size, const unsigned char *c, size_t compare_size) { - const unsigned char *p; int ret; + + /* compare date with compare-data up to max compare-size */ if ((ret = memcmp (data, c, compare_size)) != 0) { return ret; } - p = data; - size = size - compare_size; + /* first bytes in "data" are identical to "compare-data", + so use first bytes of "data" for next comparisons, + increasing it up to the complete data-size */ + { + register const unsigned char *p; /* position to compare from */ + size -= compare_size; - while (size > compare_size) { - p = data + compare_size; - if ((ret = memcmp (p, data, compare_size)) != 0) { - return ret; + while (size > compare_size) { + p = data + compare_size; + if ((ret = memcmp (p, data, compare_size)) != 0) { + return ret; + } + size -= compare_size; + compare_size *= 2; + } + if (size > 0) { + p = data + compare_size; + return memcmp (p, data, size); } - size = size - compare_size; - compare_size *= 2; - } - if (size > 0) { - return memcmp (p, data, size); } + return 0; } @@ -1783,7 +1798,18 @@ compare_spaces (const unsigned char *data, size_t size) return compare_character (data, size, (const unsigned char *)COB_SPACES_ALPHABETIC, COB_SPACES_ALPHABETIC_BYTE_LENGTH); +} +/* compare up to 'size' characters in 'data' to zeroes */ +static int +compare_zeroes (const unsigned char *data, size_t size) +{ + if (size <= COB_ZEROES_ALPHABETIC_BYTE_LENGTH) { + return memcmp (data, COB_ZEROES_ALPHABETIC, size); + } + return compare_character (data, size, + (const unsigned char *)COB_ZEROES_ALPHABETIC, + COB_ZEROES_ALPHABETIC_BYTE_LENGTH); } /* compare content of field 'f1' to repeated content of 'f2' */ @@ -1809,10 +1835,15 @@ cob_cmp_all (cob_field *f1, cob_field *f2) /* check without collation */ if (col == NULL) { - if (f2->size == 1 - && f2->data[0] == ' ') { - /* check for IF VAR = [ALL] SPACES */ - return compare_spaces (f1->data, f1->size); + if (f2->size == 1) { + if (f2->data[0] == ' ') { + /* check for IF VAR = [ALL] SPACE[S] */ + return compare_spaces (f1->data, f1->size); + } + if (f2->data[0] == '0') { + /* check for IF VAR = [ALL] ZERO[ES] */ + return compare_zeroes (f1->data, f1->size); + } } /* check for IF VAR = ALL ... / HIGH-VALUE / ... */ if (f1->size > f2->size) { @@ -1824,7 +1855,7 @@ cob_cmp_all (cob_field *f1, cob_field *f2) /* check with collation */ if (f2->size == 1) { - /* check for IF VAR = ALL "9" */ + /* check for IF VAR = ALL "9" / IF VAR = ZERO */ return common_cmpc (data, f2->data[0], f1->size, col); } else { /* check for IF VAR = ALL "AB" ... */ @@ -4064,7 +4095,7 @@ cob_table_sort (cob_field *f, const int n) /* Run-time error checking */ void -cob_check_beyond_exit (const unsigned char *name) +cob_check_beyond_exit (const char *name) { /* possibly allow to lower this to a runtime warning later */ cob_runtime_error (_("code execution leaving %s"), name); diff --git a/libcob/common.h b/libcob/common.h index 7fe2b1008..0a85d097d 100644 --- a/libcob/common.h +++ b/libcob/common.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2012, 2014-2022 Free Software Foundation, Inc. + Copyright (C) 2002-2012, 2014-2023 Free Software Foundation, Inc. Written by Keisuke Nishida, Roger While, Simon Sobisch, Ron Norman, Edward Hart @@ -1872,7 +1872,7 @@ COB_EXPIMP void cob_check_ref_mod_minimal (const char *, const int, const int); COB_EXPIMP void cob_check_ref_mod (const int, const int, const int, const char *); -COB_EXPIMP void cob_check_beyond_exit (const unsigned char *); +COB_EXPIMP void cob_check_beyond_exit (const char *); /* Comparison functions */ @@ -1909,6 +1909,9 @@ COB_EXPIMP void cob_unstring_finish (void); COB_EXPIMP const char *COB_SPACES_ALPHABETIC; /* PIC X/A/U SPACES */ #define COB_SPACES_ALPHABETIC_BYTE_LENGTH 1024 +COB_EXPIMP const char *COB_ZEROES_ALPHABETIC; /* PIC X/A/U ZEROES */ +#define COB_ZEROES_ALPHABETIC_BYTE_LENGTH 256 + /*******************************/ /* Functions in move.c */ /*******************************/ diff --git a/libcob/intrinsic.c b/libcob/intrinsic.c index f30d14f03..1889bc309 100644 --- a/libcob/intrinsic.c +++ b/libcob/intrinsic.c @@ -556,7 +556,7 @@ calc_ref_mod (cob_field *f, const int offset, const int length) static void cob_trim_decimal (cob_decimal *d) { - if (!mpz_sgn (d->value)) { + if (mpz_sgn (d->value) == 0) { /* Value is zero */ d->scale = 0; return; @@ -594,8 +594,7 @@ cob_alloc_set_field_uint (const cob_u32_t val) cob_field_attr attr; cob_field field; - COB_ATTR_INIT (COB_TYPE_NUMERIC_BINARY, 9, - 0, 0, NULL); + COB_ATTR_INIT (COB_TYPE_NUMERIC_BINARY, 9, 0, 0, NULL); COB_FIELD_INIT (4, NULL, &attr); make_field_entry (&field); memcpy (curr_field->data, &val, sizeof(cob_u32_t)); @@ -605,7 +604,7 @@ static void cob_alloc_field (cob_decimal *d) { size_t bitnum; - size_t sign; + int negative_sign_pos; unsigned short attrsign; short size, scale; cob_field_attr attr; @@ -614,31 +613,30 @@ cob_alloc_field (cob_decimal *d) if (unlikely (d->scale == COB_DECIMAL_NAN)) { /* Check this */ cob_set_exception (COB_EC_ARGUMENT_FUNCTION); - COB_ATTR_INIT (COB_TYPE_NUMERIC_BINARY, 9, - 0, 0, NULL); + COB_ATTR_INIT (COB_TYPE_NUMERIC_BINARY, 9, 0, 0, NULL); COB_FIELD_INIT (4, NULL, &attr); make_field_entry (&field); return; } - if (mpz_sgn (d->value) < 0) { + if (mpz_sgn (d->value) == -1) { attrsign = COB_FLAG_HAVE_SIGN; - sign = 1; + negative_sign_pos = 1; } else { attrsign = 0; - sign = 0; + negative_sign_pos = 0; } cob_trim_decimal (d); bitnum = mpz_sizeinbase (d->value, 2); - if (bitnum < (33 - sign) && d->scale < 10) { + if (bitnum < (33 - negative_sign_pos) && d->scale < 10) { /* 4 bytes binary */ COB_ATTR_INIT (COB_TYPE_NUMERIC_BINARY, 9, (short)d->scale, attrsign, NULL); COB_FIELD_INIT (4, NULL, &attr); make_field_entry (&field); - } else if (bitnum < (65 - sign) && d->scale < 19) { + } else if (bitnum < (65 - negative_sign_pos) && d->scale < 19) { /* 8 bytes binary */ COB_ATTR_INIT (COB_TYPE_NUMERIC_BINARY, 20, (short)d->scale, attrsign, NULL); @@ -663,13 +661,11 @@ cob_alloc_field (cob_decimal *d) static cob_field * cob_mod_or_rem (cob_field *f1, cob_field *f2, const int func_is_rem) { - int sign; - cobglobptr->cob_exception_code = 0; cob_decimal_set_field (&d2, f1); cob_decimal_set_field (&d3, f2); - if (!mpz_sgn (d3.value)) { + if (mpz_sgn (d3.value) == 0) { /* function argument violation */ cob_set_exception (COB_EC_ARGUMENT_FUNCTION); cob_alloc_set_field_uint (0); @@ -683,16 +679,16 @@ cob_mod_or_rem (cob_field *f1, cob_field *f2, const int func_is_rem) mpz_ui_pow_ui (cob_mexp, 10UL, (cob_uli_t)-d2.scale); mpz_mul (d2.value, d2.value, cob_mexp); } else if (d2.scale > 0) { - sign = mpz_sgn (d2.value); mpz_ui_pow_ui (cob_mexp, 10UL, (cob_uli_t)d2.scale); if (func_is_rem) { /* REMAINDER function - INTEGER-PART */ mpz_tdiv_q (d2.value, d2.value, cob_mexp); } else { + const int sign = mpz_sgn (d2.value); /* MOD function - INTEGER */ mpz_tdiv_qr (d2.value, cob_mpzt, d2.value, cob_mexp); /* Check negative and has decimal places */ - if (sign < 0 && mpz_sgn (cob_mpzt)) { + if (sign == -1 && mpz_sgn (cob_mpzt) != 0) { mpz_sub_ui (d2.value, d2.value, 1UL); } } @@ -1203,7 +1199,7 @@ cob_mpf_asin (mpf_t dst_val, const mpf_t src_val) mpf_clear (dst_temp); return; } - if (!mpz_sgn (src_val)) { + if (mpz_sgn (src_val) == 0) { mpf_set_ui (dst_val, 0UL); mpf_clear (dst_temp); return; @@ -1643,19 +1639,20 @@ numval (cob_field *srcfield, cob_field *currency, const enum numval_type type) if (!digits) { /* srcfield is an empty / all zero string */ - final_buff[0] = '0'; + mpz_set_ui (d1.value, 0UL); + } else { + mpz_set_str (d1.value, (char *)final_buff, 10); + if (sign == -1) { + mpz_neg (d1.value, d1.value); + } } - mpz_set_str (d1.value, (char *)final_buff, 10); cob_free (final_buff); if (exception) { cob_set_exception (COB_EC_ARGUMENT_FUNCTION); } - if (sign == -1 && mpz_sgn (d1.value)) { - mpz_neg (d1.value, d1.value); - } d1.scale = decimal_digits; cob_alloc_field (&d1); (void)cob_decimal_get_field (&d1, curr_field, 0); @@ -3151,7 +3148,7 @@ void cob_decimal_pow (cob_decimal *pd1, cob_decimal *pd2) { cob_uli_t n; - int sign; + const int sign = mpz_sgn (pd1->value); if (unlikely (pd1->scale == COB_DECIMAL_NAN)) { return; @@ -3161,11 +3158,9 @@ cob_decimal_pow (cob_decimal *pd1, cob_decimal *pd2) return; } - sign = mpz_sgn (pd1->value); - - if (!mpz_sgn (pd2->value)) { + if (mpz_sgn (pd2->value) == 0) { /* Exponent is zero */ - if (!sign) { + if (sign == 0) { /* 0 ^ 0 */ cob_set_exception (COB_EC_SIZE_EXPONENTIATION); } @@ -3173,7 +3168,7 @@ cob_decimal_pow (cob_decimal *pd1, cob_decimal *pd2) pd1->scale = 0; return; } - if (!sign) { + if (sign == 0) { /* Value is zero */ pd1->scale = 0; return; @@ -3181,7 +3176,7 @@ cob_decimal_pow (cob_decimal *pd1, cob_decimal *pd2) cob_trim_decimal (pd2); - if (sign < 0 && pd2->scale) { + if (sign == -1 && pd2->scale) { /* Negative exponent and non-integer power */ pd1->scale = COB_DECIMAL_NAN; cob_set_exception (COB_EC_SIZE_EXPONENTIATION); @@ -3196,7 +3191,8 @@ cob_decimal_pow (cob_decimal *pd1, cob_decimal *pd2) /* Power is 1 */ return; } - if (mpz_sgn (pd2->value) < 0 && mpz_fits_slong_p (pd2->value)) { + if (mpz_sgn (pd2->value) == -1 + && mpz_fits_slong_p (pd2->value)) { /* Negative power */ mpz_abs (pd2->value, pd2->value); n = mpz_get_ui (pd2->value); @@ -3225,7 +3221,7 @@ cob_decimal_pow (cob_decimal *pd1, cob_decimal *pd2) } } - if (sign < 0) { + if (sign == -1) { mpz_abs (pd1->value, pd1->value); } cob_decimal_get_mpf (cob_mpft, pd1); @@ -3239,7 +3235,7 @@ cob_decimal_pow (cob_decimal *pd1, cob_decimal *pd2) cob_mpf_exp (cob_mpft2, cob_mpft); } cob_decimal_set_mpf (pd1, cob_mpft2); - if (sign < 0) { + if (sign == -1) { mpz_neg (pd1->value, pd1->value); } } @@ -3663,7 +3659,7 @@ cob_intr_binop (cob_field *f1, const int op, cob_field *f2) break; case '/': cobglobptr->cob_exception_code = 0; - if (!mpz_sgn (d2.value)) { + if (mpz_sgn (d2.value) == 0) { /* Divide by zero */ cob_set_exception (COB_EC_SIZE_ZERO_DIVIDE); mpz_set_ui (d1.value, 0UL); @@ -3710,19 +3706,17 @@ cob_intr_byte_length (cob_field *srcfield) cob_field * cob_intr_integer (cob_field *srcfield) { - int sign; - cob_decimal_set_field (&d1, srcfield); /* Check scale */ if (d1.scale < 0) { mpz_ui_pow_ui (cob_mexp, 10UL, (cob_uli_t)-d1.scale); mpz_mul (d1.value, d1.value, cob_mexp); } else if (d1.scale > 0) { - sign = mpz_sgn (d1.value); + const int sign = mpz_sgn (d1.value); mpz_ui_pow_ui (cob_mexp, 10UL, (cob_uli_t)d1.scale); mpz_tdiv_qr (d1.value, cob_mpzt, d1.value, cob_mexp); /* Check negative and has decimal places */ - if (sign < 0 && mpz_sgn (cob_mpzt)) { + if (sign == -1 && mpz_sgn (cob_mpzt) != 0) { mpz_sub_ui (d1.value, d1.value, 1UL); } } @@ -4192,7 +4186,8 @@ cob_intr_exception_location (void) *(curr_field->data) = ' '; } else { char buff[COB_SMALL_BUFF]; - if (cobglobptr->last_exception_section && cobglobptr->last_exception_paragraph) { + if (cobglobptr->last_exception_section + && cobglobptr->last_exception_paragraph) { snprintf (buff, (size_t)COB_SMALL_MAX, "%s; %s OF %s; %u", cobglobptr->last_exception_id, cobglobptr->last_exception_paragraph, @@ -4630,7 +4625,7 @@ cob_intr_exp (cob_field *srcfield) cobglobptr->cob_exception_code = 0; - if (!mpz_sgn (d1.value)) { + if (mpz_sgn (d1.value) == 0) { /* Power is zero */ cob_alloc_set_field_uint (1); return curr_field; @@ -4648,14 +4643,14 @@ cob_intr_exp (cob_field *srcfield) cob_field * cob_intr_exp10 (cob_field *srcfield) { - int sign; + int sign; /* no const as we need the decimal set before */ cob_decimal_set_field (&d1, srcfield); cobglobptr->cob_exception_code = 0; sign = mpz_sgn (d1.value); - if (!sign) { + if (sign == 0) { /* Power is zero */ cob_alloc_set_field_uint (1); return curr_field; @@ -4665,7 +4660,7 @@ cob_intr_exp10 (cob_field *srcfield) if (!d1.scale) { /* Integer positive/negative powers */ - if (sign < 0 && mpz_fits_sint_p (d1.value)) { + if (sign == -1 && mpz_fits_sint_p (d1.value)) { mpz_abs (d1.value, d1.value); d1.scale = mpz_get_si (d1.value); mpz_set_ui (d1.value, 1UL); @@ -4673,7 +4668,7 @@ cob_intr_exp10 (cob_field *srcfield) (void)cob_decimal_get_field (&d1, curr_field, 0); return curr_field; } - if (sign > 0 && mpz_fits_ulong_p (d1.value)) { + if (sign == 1 && mpz_fits_ulong_p (d1.value)) { mpz_ui_pow_ui (d1.value, 10UL, mpz_get_ui (d1.value)); cob_alloc_field (&d1); (void)cob_decimal_get_field (&d1, curr_field, 0); @@ -4696,7 +4691,8 @@ cob_intr_log (cob_field *srcfield) cob_decimal_set_field (&d1, srcfield); cobglobptr->cob_exception_code = 0; - if (mpz_sgn (d1.value) <= 0) { + if (mpz_sgn (d1.value) != 1) { + /* value must be > 0 */ cob_set_exception (COB_EC_ARGUMENT_FUNCTION); cob_alloc_set_field_uint (0); return curr_field; @@ -4727,7 +4723,8 @@ cob_intr_log10 (cob_field *srcfield) cob_decimal_set_field (&d1, srcfield); cobglobptr->cob_exception_code = 0; - if (mpz_sgn (d1.value) <= 0) { + if (mpz_sgn (d1.value) != 1) { + /* value must be > 0 */ cob_set_exception (COB_EC_ARGUMENT_FUNCTION); cob_alloc_set_field_uint (0); return curr_field; @@ -4808,13 +4805,14 @@ cob_intr_asin (cob_field *srcfield) d3.scale = 0; cobglobptr->cob_exception_code = 0; - if (cob_decimal_cmp (&d4, &d2) < 0 || cob_decimal_cmp (&d5, &d3) > 0) { + if (cob_decimal_cmp (&d4, &d2) < 0 + || cob_decimal_cmp (&d5, &d3) > 0) { cob_set_exception (COB_EC_ARGUMENT_FUNCTION); cob_alloc_set_field_uint (0); return curr_field; } - if (!mpz_sgn (d1.value)) { + if (mpz_sgn (d1.value) == 0) { /* Asin (0) = 0 */ cob_alloc_set_field_uint (0); return curr_field; @@ -4836,7 +4834,7 @@ cob_intr_atan (cob_field *srcfield) cobglobptr->cob_exception_code = 0; - if (!mpz_sgn (d1.value)) { + if (mpz_sgn (d1.value) == 0) { /* Atan (0) = 0 */ cob_alloc_set_field_uint (0); return curr_field; @@ -4905,7 +4903,8 @@ cob_intr_sqrt (cob_field *srcfield) cob_decimal_set_field (&d1, srcfield); cobglobptr->cob_exception_code = 0; - if (mpz_sgn (d1.value) < 0) { + if (mpz_sgn (d1.value) == -1) { + /* value must be >= 0 */ cob_set_exception (COB_EC_ARGUMENT_FUNCTION); cob_alloc_set_field_uint (0); return curr_field; @@ -5138,7 +5137,7 @@ cob_intr_numval_f (cob_field *srcfield) cob_field * cob_intr_annuity (cob_field *srcfield1, cob_field *srcfield2) { - int sign; + int sign; /* no const as we need the decimal set before */ cob_decimal_set_field (&d1, srcfield1); cob_decimal_set_field (&d2, srcfield2); @@ -5151,7 +5150,7 @@ cob_intr_annuity (cob_field *srcfield1, cob_field *srcfield2) return curr_field; } - if (!sign) { + if (sign == 0) { mpz_set_ui (d1.value, 1UL); d1.scale = 0; cob_decimal_div (&d1, &d2); @@ -5481,10 +5480,10 @@ cob_intr_random (const int params, ...) but then need a matching size to get around others...*/ #ifdef COB_64_BIT_POINTER seed = get_seconds_past_midnight () - * (((cob_s64_t)COB_MODULE_PTR) && 0xFFFFF); + * (((cob_s64_t)COB_MODULE_PTR) & 0xFFFFF); #else seed = get_seconds_past_midnight () - * (((cob_s32_t)COB_MODULE_PTR) && 0xFFFF); + * (((cob_s32_t)COB_MODULE_PTR) & 0xFFFF); #endif rand_needs_seeding = 2; #endif diff --git a/libcob/move.c b/libcob/move.c index 165656812..50072da73 100644 --- a/libcob/move.c +++ b/libcob/move.c @@ -2455,9 +2455,9 @@ cob_get_s64_pic9 (void *mem, int len) case 'R': val = val * 10 + 9; sign = -1; break; } #else - if (*p & 0xC0) { + if ((*p & 0xF0) == 0xC0) { sign = 1; - } else if (*p & 0xD0) { + } else if ((*p & 0xF0) == 0xD0) { sign = -1; } val = val * 10 + COB_D2I (*p); diff --git a/libcob/numeric.c b/libcob/numeric.c index 22aed2db1..391e324b6 100644 --- a/libcob/numeric.c +++ b/libcob/numeric.c @@ -382,7 +382,7 @@ cob_decimal_print (cob_decimal *d, FILE *fp) fprintf (fp, "(Inf)"); return; } - if (!mpz_sgn (d->value)) { + if (mpz_sgn (d->value) == 0) { fprintf (fp, "0E0"); return; } @@ -420,12 +420,19 @@ cob_decimal_print (cob_decimal *d, FILE *fp) /* Get power of 10 as mpz_t */ static COB_INLINE COB_A_INLINE void -cob_pow_10 (mpz_t mexp, int n) +cob_pow_10 (mpz_t mexp, unsigned int n) { - if (n >= 0 && n <= COB_MAX_BINARY) { + if (n <= COB_MAX_BINARY) { mpz_set (mexp, cob_mpze10[n]); } else { - mpz_ui_pow_ui (mexp, 10UL, (cob_uli_t)n); + /* needed, for example in FUNCTION RANDOM test (999) + and with extreme huge value (6499) for test + "FLOAT-DECIMALL w/o SIZE ERROR" to get huge + FD32 values with the right scale */ + /* TODO: add artificial limit with raising ON SIZE ERROR + as we otherwise run into an abort directly in GMP + for _real huge_ numbers */ + mpz_ui_pow_ui (mexp, 10UL, n); } } @@ -559,11 +566,10 @@ cob_decimal_adjust (cob_decimal *d, mpz_t max_value, int min_exp, int max_exp) static int cob_decimal_get_ieee64dec (cob_decimal *d, cob_field *f, const int opt) { - int sign; cob_u64_t expo; cob_u64_t data; + const int sign = mpz_sgn (d->value); - sign = mpz_sgn (d->value); if (sign == 0) { memset (f->data, 0, (size_t)8); return 0; @@ -679,9 +685,8 @@ cob_decimal_get_ieee128dec (cob_decimal *d, cob_field *f, const int opt) { cob_u64_t expo; cob_u64_t data[2]; - int sign; + const int sign = mpz_sgn (d->value); - sign = mpz_sgn (d->value); if (sign == 0) { memset (f->data, 0, (size_t)16); return 0; @@ -1156,10 +1161,10 @@ cob_decimal_set_packed (cob_decimal *d, cob_field *f) if ( (endp - p) > 2) { mpz_mul_ui (d->value, d->value, 10000UL); mpz_add_ui (d->value, d->value, - ((cob_uli_t)(*p >> 4U) * 1000) - + ((*p & 0x0FU) * 100) - + ((cob_uli_t)(*(p + 1) >> 4U) * 10) - + (*(p + 1) & 0x0FU)); + ( ((cob_uli_t)(*p >> 4U) * 1000) + + ((cob_uli_t)(*p & 0x0FU) * 100) + + ((cob_uli_t)(*(p + 1) >> 4U) * 10) + + (*(p + 1) & 0x0FU))); p++; nonzero = 1; continue; @@ -1200,9 +1205,6 @@ cob_decimal_get_packed (cob_decimal *d, cob_field *f, const int opt) const int sign = mpz_sgn (d->value); size_t size, diff, i; int digits; -#if 0 /* huge packed-decimal */ - char *mza; -#endif /* check for value zero (allows early exit) and handle sign */ if (sign == 0) { @@ -1216,63 +1218,30 @@ cob_decimal_get_packed (cob_decimal *d, cob_field *f, const int opt) mpz_sizeinbase, as its result is "either exact or one too big" */ digits = COB_FIELD_DIGITS (f); -#if 0 /* huge data, currently not used, as that only happens - for internal operations like intrinsic functions - which are either huge DISPLAY or native integer fields */ - if (digits > COB_MAX_BINARY) { - /* CHECKME: Is there any chance to get here? - Otherwise me should drop the check and code */ - mza = mpz_get_str (NULL, 10, d->value); - size = strlen (mza); - diff = (size_t)digits - size; - if (diff < 0) { - /* Overflow */ - cob_set_exception (COB_EC_SIZE_OVERFLOW); - - /* If the statement has ON SIZE ERROR or NOT ON SIZE ERROR, - then throw an exception */ - if (opt & COB_STORE_KEEP_ON_OVERFLOW) { - cob_gmp_free (mza); - return cobglobptr->cob_exception_code; - } + /* get divisor that would overflow */ + cob_pow_10 (cob_mexp, digits); + /* check if it is >= what we have */ + if (mpz_cmp (d->value, cob_mexp) >= 0) { + /* Overflow */ + cob_set_exception (COB_EC_SIZE_OVERFLOW); - /* numeric truncation, - move to whatever position we can store */ - q = (unsigned char *)mza + size - digits; - size = digits; - } else { - q = (unsigned char *)mza; + /* If the statement has ON SIZE ERROR or NOT ON SIZE ERROR, + then throw an exception */ + if (opt & COB_STORE_KEEP_ON_OVERFLOW) { + return cobglobptr->cob_exception_code; } + /* Other size, truncate digits, using the remainder */ + mpz_tdiv_r (cob_mexp, d->value, cob_mexp); + (void) mpz_get_str (buff, 10, cob_mexp); + size = digits; + diff = 0; } else { -#endif - /* get divisor that would overflow */ - cob_pow_10 (cob_mexp, digits); - /* check if it is >= what we have */ - if (mpz_cmp (d->value, cob_mexp) >= 0) { - /* Overflow */ - cob_set_exception (COB_EC_SIZE_OVERFLOW); - - /* If the statement has ON SIZE ERROR or NOT ON SIZE ERROR, - then throw an exception */ - if (opt & COB_STORE_KEEP_ON_OVERFLOW) { - return cobglobptr->cob_exception_code; - } - /* Other size, truncate digits, using the remainder */ - mpz_tdiv_r (cob_mexp, d->value, cob_mexp); - (void) mpz_get_str (buff, 10, cob_mexp); - size = digits; - diff = 0; - } else { - /* No overflow, so get string data and fill with zero */ - (void) mpz_get_str (buff, 10, d->value); - size = strlen (buff); - diff = (size_t)digits - size; - } - q = (unsigned char *)buff; -#if 0 /* huge packed-decimal */ - mza = NULL; + /* No overflow, so get string data and fill with zero */ + (void) mpz_get_str (buff, 10, d->value); + size = strlen (buff); + diff = (size_t)digits - size; } -#endif + q = (unsigned char *)buff; /* Store number */ data = f->data; @@ -1292,11 +1261,6 @@ cob_decimal_get_packed (cob_decimal *d, cob_field *f, const int opt) *p++ |= x; } } -#if 0 /* huge packed-decimal */ - if (mza) { - cob_gmp_free (mza); - } -#endif if (COB_FIELD_NO_SIGN_NIBBLE (f)) { return 0; @@ -1464,7 +1428,7 @@ cob_decimal_get_display (cob_decimal *d, cob_field *f, const int opt) /* check for value zero (allows early exit) and handle sign */ if (sign == 0) { memset (data, '0', fsize); - COB_PUT_SIGN (f, sign); + COB_PUT_SIGN (f, 0); return 0; } if (sign == -1) { @@ -1640,7 +1604,7 @@ cob_decimal_get_binary (cob_decimal *d, cob_field *f, const int opt) field_sign = 1; } else { field_sign = 0; - if (mpz_sgn (d->value) < 0) { + if (mpz_sgn (d->value) == -1) { mpz_abs (d->value, d->value); } } @@ -1831,8 +1795,8 @@ cob_decimal_do_round (cob_decimal *d, cob_field *f, const int opt) const int sign = mpz_sgn (d->value); const int scale = COB_FIELD_SCALE (f); - /* Nothing to do when value is 0 or when target has ge scale */ - if (!sign + /* Nothing to do when value is 0 or when target has GE scale */ + if (sign == 0 || scale >= d->scale) { return; } @@ -1847,7 +1811,7 @@ cob_decimal_do_round (cob_decimal *d, cob_field *f, const int opt) adj = d->scale - scale; cob_pow_10 (cob_mpzt, adj); mpz_tdiv_r (cob_mpzt2, d->value, cob_mpzt); - if (mpz_sgn (cob_mpzt2)) { + if (mpz_sgn (cob_mpzt2) != 0) { /* Not exact number */ if (sign == -1) { mpz_sub (d->value, d->value, cob_mpzt); @@ -1867,7 +1831,7 @@ cob_decimal_do_round (cob_decimal *d, cob_field *f, const int opt) shift_decimal (d, n); } } - if (!mpz_sgn (cob_mpzt2)) { + if (mpz_sgn (cob_mpzt2) == 0) { return; } if (sign == 1) { @@ -1880,7 +1844,7 @@ cob_decimal_do_round (cob_decimal *d, cob_field *f, const int opt) adj = d->scale - scale; cob_pow_10 (cob_mpzt, adj); mpz_tdiv_r (cob_mpzt2, d->value, cob_mpzt); - if (mpz_sgn (cob_mpzt2)) { + if (mpz_sgn (cob_mpzt2) != 0) { /* Not exact number */ if (sign == 1) { mpz_add (d->value, d->value, cob_mpzt); @@ -1891,7 +1855,7 @@ cob_decimal_do_round (cob_decimal *d, cob_field *f, const int opt) adj = d->scale - scale; cob_pow_10 (cob_mpzt, adj); mpz_tdiv_r (cob_mpzt2, d->value, cob_mpzt); - if (mpz_sgn (cob_mpzt2)) { + if (mpz_sgn (cob_mpzt2) != 0) { /* Not exact number */ if (sign == -1) { mpz_sub (d->value, d->value, cob_mpzt); @@ -1909,7 +1873,7 @@ cob_decimal_do_round (cob_decimal *d, cob_field *f, const int opt) shift_decimal (d, n); } } - if (!mpz_sgn (cob_mpzt)) { + if (mpz_sgn (cob_mpzt) == 0) { adj = mpz_tdiv_ui (d->value, 100UL); switch (adj) { case 5: @@ -2548,7 +2512,8 @@ cob_cmp_int (cob_field *f1, const int n) int cob_cmp_uint (cob_field *f1, const unsigned int n) { - int sign; + int sign; /* no const as we need the decimal set before */ + cob_decimal_set_field (&cob_d1, f1); sign = mpz_sgn (cob_d1.value); if (sign == 0) { @@ -2571,7 +2536,8 @@ cob_cmp_uint (cob_field *f1, const unsigned int n) int cob_cmp_llint (cob_field *f1, const cob_s64_t n) { - int sign; + int sign; /* no const as we need the decimal set before */ + cob_decimal_set_field (&cob_d1, f1); sign = mpz_sgn (cob_d1.value); if (sign == 0) { diff --git a/libcob/screenio.c b/libcob/screenio.c index 032ef0935..2f73807a6 100644 --- a/libcob/screenio.c +++ b/libcob/screenio.c @@ -2707,20 +2707,17 @@ field_accept (cob_field *f, const int sline, const int scolumn, cob_field *fgc, int status; chtype prompt_char; /* prompt character */ chtype default_prompt_char; +#ifdef NCURSES_MOUSE_VERSION + MEVENT mevent; +#endif + size_t size_accept = 0; /* final size to accept */ cob_field temp_field; + #if 0 /* RXWRXW - Screen update */ cob_field char_temp; unsigned char space_buff[4]; -#endif -#ifdef NCURSES_MOUSE_VERSION - MEVENT mevent; -#endif - memset (COB_TERM_BUFF, ' ', (size_t)COB_MEDIUM_MAX); - temp_field.data = COB_TERM_BUFF; - temp_field.attr = &const_alpha_attr; -#if 0 /* RXWRXW - Screen update */ char_temp.data = space_buff; char_temp.attr = &const_alpha_attr; char_temp.size = 1; @@ -2775,9 +2772,13 @@ field_accept (cob_field *f, const int sline, const int scolumn, cob_field *fgc, } p = COB_TERM_BUFF; + temp_field.data = COB_TERM_BUFF; + temp_field.attr = &const_alpha_attr; temp_field.size = size_accept; if (fattr & COB_SCREEN_UPDATE) { - cob_move (f, &temp_field); + cob_move (f, &temp_field); /* updates COB_TERM_BUFF */ + } else { + memset (COB_TERM_BUFF, ' ', size_accept); } raise_ec_on_truncation (size_accept); @@ -3359,12 +3360,16 @@ field_accept (cob_field *f, const int sline, const int scolumn, cob_field *fgc, (void)flushinp (); cob_beep (); } + field_return: pass_cursor_to_program (); handle_status (fret, ACCEPT_STATEMENT); if (f) { cob_move (&temp_field, f); cob_move_cursor (sline, right_pos + 1); +#if 0 /* possible cleanup to not "leak" input data */ + memset (COB_TERM_BUFF, ' ', size_accept); +#endif } refresh (); } diff --git a/libcob/termio.c b/libcob/termio.c index bf42350a8..a0181ca2e 100644 --- a/libcob/termio.c +++ b/libcob/termio.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2001-2012, 2014-2022 Free Software Foundation, Inc. + Copyright (C) 2001-2012, 2014-2023 Free Software Foundation, Inc. Written by Keisuke Nishida, Roger While, Simon Sobisch, Edward Hart This file is part of GnuCOBOL. @@ -64,37 +64,45 @@ static const cob_field_attr const_alpha_attr = static void display_numeric (cob_field *f, FILE *fp) { - int i; - unsigned short digits; - signed short scale; - int size; - cob_field_attr attr; - cob_field temp; + const unsigned short digits = COB_FIELD_DIGITS (f); + const signed short scale = COB_FIELD_SCALE (f); + const int has_sign = COB_FIELD_HAVE_SIGN (f) ? 1 : 0; + const int size + = digits + + ((scale < 0) ? scale : 0) /* subtract scale when negative */ + + has_sign; - digits = COB_FIELD_DIGITS (f); - scale = COB_FIELD_SCALE (f); - size = digits + (COB_FIELD_HAVE_SIGN (f) ? 1 : 0); + /* minimal validation */ if (size >= COB_MEDIUM_MAX) { fputs (_("(Not representable)"), fp); return; } - COB_ATTR_INIT (COB_TYPE_NUMERIC_DISPLAY, digits, scale, 0, NULL); - temp.size = size; - temp.data = COB_TERM_BUFF; - temp.attr = &attr; - if (COB_FIELD_HAVE_SIGN (f)) { - attr.flags = COB_FLAG_HAVE_SIGN | COB_FLAG_SIGN_SEPARATE; - if (COB_FIELD_SIGN_LEADING (f) || - COB_FIELD_TYPE (f) != COB_TYPE_NUMERIC_DISPLAY) { - attr.flags |= COB_FLAG_SIGN_LEADING; + + /* conversion to internal USAGE DISPLAY with SIGN SEPERATE */ + { + cob_field field; + cob_field_attr attr; + COB_ATTR_INIT (COB_TYPE_NUMERIC_DISPLAY, digits, COB_FIELD_SCALE (f), 0, NULL); + if (has_sign) { + attr.flags = COB_FLAG_HAVE_SIGN | COB_FLAG_SIGN_SEPARATE; + if (COB_FIELD_SIGN_LEADING (f) || + COB_FIELD_TYPE (f) != COB_TYPE_NUMERIC_DISPLAY) { + attr.flags |= COB_FLAG_SIGN_LEADING; + } } + COB_FIELD_INIT (size, COB_TERM_BUFF, &attr); + + cob_move (f, &field); } - cob_move (f, &temp); - for (i = 0; i < size; ++i) { - unsigned char chr = temp.data[i]; - if (putc (chr, fp) != chr) { - break; + /* output of data to viewport */ + { + register unsigned char *q = COB_TERM_BUFF; + const unsigned char *end = q + size; + for ( ; q < end; ++q) { + if (putc (*q, fp) != *q) { + break; + } } } } @@ -104,21 +112,24 @@ pretty_display_numeric (cob_field *f, FILE *fp) { const unsigned short digits = COB_FIELD_DIGITS (f); const signed short scale = COB_FIELD_SCALE (f); - const int size = digits + !!COB_FIELD_HAVE_SIGN (f) + !!scale; + const int has_sign = COB_FIELD_HAVE_SIGN (f) ? 1 : 0; + const int size + = digits + + ((scale > 0) ? 1 : 0) /* no decimal point -> no space for negative scales */ + + has_sign; /* Note: while we only need one pair, the double one works around a bug in old GCC versions https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53119 */ cob_pic_symbol pic[6] = {{ 0 }}; - cob_pic_symbol *p; + cob_pic_symbol *p = pic; if (size > COB_MEDIUM_MAX) { fputs (_("(Not representable)"), fp); return; } - p = pic; - if (COB_FIELD_HAVE_SIGN (f)) { + if (has_sign) { if (COB_FIELD_SIGN_SEPARATE (f) - && !COB_FIELD_SIGN_LEADING(f)) { + && !COB_FIELD_SIGN_LEADING (f)) { /* done later */ } else { p->symbol = '+'; @@ -145,9 +156,9 @@ pretty_display_numeric (cob_field *f, FILE *fp) p->times_repeated = digits; ++p; } - if (COB_FIELD_HAVE_SIGN (f)) { + if (has_sign) { if (COB_FIELD_SIGN_SEPARATE (f) - && !COB_FIELD_SIGN_LEADING(f)) { + && !COB_FIELD_SIGN_LEADING (f)) { p->symbol = '+'; p->times_repeated = 1; ++p; @@ -156,21 +167,25 @@ pretty_display_numeric (cob_field *f, FILE *fp) p->symbol = '\0'; { - unsigned char *q = COB_TERM_BUFF; - const unsigned char *end = q + size; - cob_field_attr attr; - cob_field temp; - temp.size = size; - temp.data = q; - temp.attr = &attr; - COB_ATTR_INIT (COB_TYPE_NUMERIC_EDITED, digits, scale, 0, - (const cob_pic_symbol*)pic); - - cob_move (f, &temp); - while (q != end) { - const int chr = *q++; - if (putc (chr, fp) != chr) { - break; + /* conversion to internal USAGE DISPLAY EDITED */ + { + cob_field field; + cob_field_attr attr; + COB_FIELD_INIT (size, COB_TERM_BUFF, &attr); + COB_ATTR_INIT (COB_TYPE_NUMERIC_EDITED, digits, scale, 0, + (const cob_pic_symbol*)pic); + + cob_move (f, &field); + } + + /* output of data to viewport */ + { + register unsigned char *q = COB_TERM_BUFF; + const unsigned char *end = q + size; + for ( ; q < end; ++q) { + if (putc (*q, fp) != *q) { + break; + } } } } @@ -207,12 +222,12 @@ clean_double (char *wrk) return; } - if (strcmp(wrk,"-NAN") == 0 - || strcmp(wrk,"-NaNQ") == 0 - || strcmp(wrk,"-NaN") == 0 - || strcmp(wrk,"NAN") == 0 - || strcmp(wrk,"NaNQ") == 0) { - strcpy(wrk,"NaN"); + if (strcmp (wrk,"-NAN") == 0 + || strcmp (wrk,"-NaNQ") == 0 + || strcmp (wrk,"-NaN") == 0 + || strcmp (wrk,"NAN") == 0 + || strcmp (wrk,"NaNQ") == 0) { + strcpy (wrk,"NaN"); } } diff --git a/tests/testsuite.src/configuration.at b/tests/testsuite.src/configuration.at index 1eafb6339..7f676c43d 100644 --- a/tests/testsuite.src/configuration.at +++ b/tests/testsuite.src/configuration.at @@ -499,6 +499,7 @@ test.conf: missing definitions: no definition of 'national-character-literals' no definition of 'hp-octal-literals' no definition of 'acu-literals' + no definition of 'ebcdic-symbolic-characters' no definition of 'word-continuation' no definition of 'not-exception-before-exception' no definition of 'accept-display-extensions' diff --git a/tests/testsuite.src/run_extensions.at b/tests/testsuite.src/run_extensions.at index f2c67e1d8..58d23a018 100644 --- a/tests/testsuite.src/run_extensions.at +++ b/tests/testsuite.src/run_extensions.at @@ -1742,6 +1742,7 @@ AT_CHECK([test -e TESTFILE], [0], [], []) AT_CLEANUP + AT_SETUP([CALL unusual PROGRAM-ID.]) AT_KEYWORDS([extensions]) @@ -1806,6 +1807,7 @@ AT_CHECK([$COBCRUN_DIRECT ./caller], [0], [P1P2P3P4]) AT_CLEANUP + AT_SETUP([CALL / GOBACK with LOCAL-STORAGE]) AT_KEYWORDS([extensions]) @@ -1848,7 +1850,8 @@ AT_DATA([prog_b.cob], [ AT_CHECK([$COMPILE prog_a.cob], [0], [], []) AT_CHECK([$COMPILE_MODULE prog_b.cob], [0], [], []) -AT_CHECK([$COBCRUN_DIRECT ./prog_a], [0], [entered prog_b +AT_CHECK([$COBCRUN_DIRECT ./prog_a], [0], +[entered prog_b exiting prog_b back in prog_a ], []) @@ -6196,3 +6199,43 @@ AT_CHECK([$COMPILE -freserved=EXAMINE prog.cob], [0], [], []) AT_CHECK([$COBCRUN_DIRECT ./prog], [0], [], []) AT_CLEANUP + + +AT_SETUP([GCOS literals with EBCDIC symbols (run)]) +AT_KEYWORDS([extensions]) + +AT_DATA([prog.cob], [[ + IDENTIFICATION DIVISION. + PROGRAM-ID. prog. + DATA DIVISION. + WORKING-STORAGE SECTION. + 01 X PIC X(11). + 01 T PIC 9. + 01 S USAGE COMP-1 VALUE ZERO. + PROCEDURE DIVISION. + MOVE 1 TO T + MOVE ""135,151,151"bar"195,194,234"" TO X + IF X NOT EQUAL "foobarBAZ" PERFORM SHOW. + + MOVE 2 TO T + MOVE " "135,151,151"bar"195 194"Z" TO X + IF X NOT EQUAL " foobarBAZ" PERFORM SHOW. + + MOVE 3 TO T + MOVE ' '135 151,151'bar'195,194'Z' TO X + IF X NOT EQUAL " foobarBAZ" PERFORM SHOW. + + MOVE 4 TO T + MOVE ""75,80,91"" TO X + IF X NOT EQUAL "[!]" PERFORM SHOW. + + STOP RUN S. + SHOW. + DISPLAY "EBCDIC LIT " T " FAILED: X = """ X """" + MOVE 1 TO S. +]]) + +AT_CHECK([$COMPILE -febcdic-symbolic-characters -febcdic-table=ebcdic500_latin1 prog.cob], [0], [], []) +AT_CHECK([$COBCRUN_DIRECT ./prog], [0], []) + +AT_CLEANUP diff --git a/tests/testsuite.src/run_file.at b/tests/testsuite.src/run_file.at index 913ffe705..669b4f5a1 100644 --- a/tests/testsuite.src/run_file.at +++ b/tests/testsuite.src/run_file.at @@ -3554,14 +3554,14 @@ AT_DATA([prog.cob], [ P0101. ADD 1 TO Z. END DECLARATIVES. + * some comments here + * to mimic real world programs MP01 SECTION. MP0101. OPEN INPUT TEST-FILE. PERFORM P0101. IF Z NOT = 2 - DISPLAY Z - END-DISPLAY - END-IF. + DISPLAY Z. STOP RUN. ]) @@ -3603,10 +3603,8 @@ AT_DATA([prog.cob], [ OPEN INPUT TEST-FILE. PERFORM P01 THRU P02. IF Z NOT = 3 - DISPLAY Z - END-DISPLAY - END-IF. - STOP RUN. + DISPLAY Z. + GOBACK. ]) # disabling the check for "something leaves the section" - as this is diff --git a/tests/testsuite.src/run_functions.at b/tests/testsuite.src/run_functions.at index d8b68c988..5f76ea2e1 100644 --- a/tests/testsuite.src/run_functions.at +++ b/tests/testsuite.src/run_functions.at @@ -3090,6 +3090,7 @@ AT_DATA([prog.cob], [ DATA DIVISION. WORKING-STORAGE SECTION. 01 Z USAGE BINARY-LONG SIGNED. + 01 F USAGE FLOAT-LONG. PROCEDURE DIVISION. MOVE FUNCTION SIGN ( 3.12345 ) TO Z. IF Z NOT = 1 @@ -3103,6 +3104,18 @@ AT_DATA([prog.cob], [ MOVE FUNCTION SIGN ( -3.12345 ) TO Z. IF Z NOT = -1 DISPLAY "Sign 4 " Z. + MOVE 3.12345 TO F + MOVE FUNCTION SIGN ( F ) TO Z. + IF Z NOT = 1 + DISPLAY "Sign 5 " Z. + MOVE -0.0 TO F + MOVE FUNCTION SIGN ( F ) TO Z. + IF Z NOT = 0 + DISPLAY "Sign 6 " Z. + MOVE -3.12345 TO F + MOVE FUNCTION SIGN ( F ) TO Z. + IF Z NOT = -1 + DISPLAY "Sign 7 " Z. STOP RUN. ]) diff --git a/tests/testsuite.src/run_fundamental.at b/tests/testsuite.src/run_fundamental.at index 8dfe0f0e1..3a2f978db 100644 --- a/tests/testsuite.src/run_fundamental.at +++ b/tests/testsuite.src/run_fundamental.at @@ -29,36 +29,21 @@ AT_DATA([prog.cob], [ IDENTIFICATION DIVISION. PROGRAM-ID. prog. PROCEDURE DIVISION. - DISPLAY "abc" - END-DISPLAY. - DISPLAY 123 - END-DISPLAY. - DISPLAY +123 - END-DISPLAY. - DISPLAY -123 - END-DISPLAY. - DISPLAY 12.3 - END-DISPLAY. - DISPLAY +12.3 - END-DISPLAY. - DISPLAY -12.3 - END-DISPLAY. - DISPLAY 1.23E0 - END-DISPLAY. - DISPLAY +1.23E0 - END-DISPLAY. - DISPLAY -1.23E0 - END-DISPLAY. - DISPLAY 12.3E-2 - END-DISPLAY. - DISPLAY +12.3E-2 - END-DISPLAY. - DISPLAY -12.3E-2 - END-DISPLAY. - DISPLAY B'0101' - END-DISPLAY. - DISPLAY BX'EC' - END-DISPLAY. + DISPLAY "abc". + DISPLAY 123. + DISPLAY +123. + DISPLAY -123. + DISPLAY 12.3. + DISPLAY +12.3. + DISPLAY -12.3. + DISPLAY 1.23E0. + DISPLAY +1.23E0. + DISPLAY -1.23E0. + DISPLAY 12.3E-2. + DISPLAY +12.3E-2. + DISPLAY -12.3E-2. + DISPLAY B'0101'. + DISPLAY BX'EC'. STOP RUN. ]) @@ -95,18 +80,12 @@ AT_DATA([prog.cob], [ SPECIAL-NAMES. DECIMAL-POINT IS COMMA. PROCEDURE DIVISION. - DISPLAY 12,3 - END-DISPLAY. - DISPLAY +12,3 - END-DISPLAY. - DISPLAY -12,3 - END-DISPLAY. - DISPLAY 1,23E0 - END-DISPLAY. - DISPLAY +1,23E0 - END-DISPLAY. - DISPLAY -1,23E0 - END-DISPLAY. + DISPLAY 12,3. + DISPLAY +12,3. + DISPLAY -12,3. + DISPLAY 1,23E0. + DISPLAY +1,23E0. + DISPLAY -1,23E0. STOP RUN. ]) @@ -5689,7 +5668,8 @@ AT_DATA([prog.cob], [ WORKING-STORAGE SECTION. 01 FLDX PIC X VALUE 'X'. 01 FLDXX PIC XX VALUE SPACES. - 01 FLDX500 PIC X(500) VALUE 'X5'. + 01 FLDX50 PIC X(50) VALUE 'X50'. + 01 FLDX500 PIC X(500) VALUE 'X500'. 01 FLDX32K PIC X(32000) VALUE 'X'. 01 FLD1 PIC X VALUE '1'. 01 FLD1X PIC X(32000) VALUE '1'. @@ -5972,15 +5952,46 @@ AT_DATA([prog.cob], [ ELSE DISPLAY '! "X" > ALL "XX"'. IF ALL "XX" NOT > FLDX CONTINUE ELSE DISPLAY '! ALL "XX" <= "X"'. + + *> special check for ZERO-optimization and extra spaces + MOVE ALL ZERO TO FLDX500 FLDX50 + MOVE "1" TO FLDX500 (500:1) FLDX50(50:1) + IF FLDX50 > ZERO CONTINUE + ELSE DISPLAY '! "000...01" > ZERO'. + IF FLDX50 < ZERO DISPLAY ' "000...01" < ZERO!'. + IF FLDX50 >= ZERO CONTINUE + ELSE DISPLAY '! "000...01" >= ZERO'. + IF FLDX50 <= ZERO DISPLAY ' "000...01" <= ZERO!'. + + IF ZERO < FLDX50 CONTINUE + ELSE DISPLAY '! ZERO < "000...01"'. + IF ZERO > FLDX50 DISPLAY ' ZERO > "000...01"!'. + IF ZERO <= FLDX50 CONTINUE + ELSE DISPLAY '! ZERO <= "000...01"'. + IF ZERO >= FLDX50 DISPLAY ' ZERO >= "000...01"!'. + + IF FLDX500 > ZERO CONTINUE + ELSE DISPLAY '! "000...01" > ZERO'. + IF FLDX500 < ZERO DISPLAY ' "000...01" < ZERO!'. + IF FLDX500 >= ZERO CONTINUE + ELSE DISPLAY '! "000...01" >= ZERO'. + IF FLDX500 <= ZERO DISPLAY ' "000...01" <= ZERO!'. + + IF ZERO < FLDX500 CONTINUE + ELSE DISPLAY '! ZERO < "000...01"'. + IF ZERO > FLDX500 DISPLAY ' ZERO > "000...01"!'. + IF ZERO <= FLDX500 CONTINUE + ELSE DISPLAY '! ZERO <= "000...01"'. + IF ZERO >= FLDX500 DISPLAY ' ZERO >= "000...01"!'. ]) AT_CHECK([$COMPILE prog.cob -Wno-constant-expression], [0], [], []) AT_CHECK([$COBCRUN_DIRECT ./prog], [0], [], []) -AT_CHECK([$COMPILE prog.cob -Wno-constant-expression -fno-constant-folding], [0], [], []) +AT_CHECK([$COMPILE prog.cob -Wno-constant-expression -fno-constant-folding -fno-fast-compare], [0], [], []) AT_CHECK([$COBCRUN_DIRECT ./prog], [0], [], []) -AT_CHECK([$COMPILE prog.cob -Wno-constant-expression -fno-constant-folding -fno-fast-compare], [0], [], []) +AT_CHECK([$COMPILE prog.cob -Wno-constant-expression -fno-constant-folding], [0], [], []) AT_CHECK([$COBCRUN_DIRECT ./prog], [0], [], []) AT_CLEANUP @@ -6222,3 +6233,51 @@ prog.cob:7: note: value size is 3 AT_CHECK([$COBCRUN_DIRECT ./prog], [0], [], []) AT_CLEANUP + + +AT_SETUP([DISPLAY with P fields]) +AT_KEYWORDS([runmisc pretty-display pretty-printing pretty]) + +# this test verifies that the size is correctly printed, which was buggy +# with "P on the left side of the decimal point", see bug #874 +# me make a general DISPLAY with implied digits out of this test +# and also verify no-pretty-printing result to be reasonable + +AT_DATA([prog.cob], [ + IDENTIFICATION DIVISION. + PROGRAM-ID. prog. + DATA DIVISION. + WORKING-STORAGE SECTION. + 01 P1 PIC 999 value 1. + 01 P2 PIC 9P value 0. + 01 P3 PIC V999 value .123. + 01 P4 PIC VP9 value 0. + 01 P5 PIC VPP9 value 0. + 01 P6 PIC 9P value 10. + PROCEDURE DIVISION. + display '00=' P2 '; 001=' P1 '; 00=' P2 ';' + display '.00=' P4 '; .000=' P5 '; .123=' P3 '; ' + '.00=' P4 '; .000=' P5 ';' + move P1 to P2 + move P3 to P4, P5 + display '00=' P2 '; .02=' P4 '; .003=' P5 ';' + display '10=' P6 ';' + GOBACK. +]) + +AT_CHECK([$COMPILE prog.cob], [0], [], []) +AT_CHECK([$COBCRUN_DIRECT ./prog], [0], +[00=00; 001=001; 00=00; +.00=.00; .000=.000; .123=.123; .00=.00; .000=.000; +00=00; .02=.02; .003=.003; +10=10; +], []) +AT_CHECK([$COMPILE -fno-pretty-display prog.cob], [0], [], []) +AT_CHECK([$COBCRUN_DIRECT ./prog], [0], +[00=0; 001=001; 00=0; +.00=00; .000=000; .123=123; .00=00; .000=000; +00=0; .02=02; .003=003; +10=1; +], []) + +AT_CLEANUP diff --git a/tests/testsuite.src/syn_literals.at b/tests/testsuite.src/syn_literals.at index 91a86d77b..0d7fdfd9c 100644 --- a/tests/testsuite.src/syn_literals.at +++ b/tests/testsuite.src/syn_literals.at @@ -816,7 +816,7 @@ AT_CLEANUP -AT_SETUP([Numeric literals]) +AT_SETUP([numeric literals]) AT_KEYWORDS([misc numeric-literal-length]) AT_DATA([prog.cob], [ @@ -1369,7 +1369,9 @@ AT_CLEANUP AT_SETUP([ACUCOBOL 32bit literal size]) + # ACUCOBOL literal max - the result is system dependent on size of unsigned long int +# FIXME: do not skip when expecting we pass AT_SKIP_IF([true]) AT_KEYWORDS([extensions literals]) @@ -1511,3 +1513,43 @@ prog.cob:5: error: missing terminating ' character ]) AT_CLEANUP + + +AT_SETUP([GCOS literals with EBCDIC symbols (syntax)]) +AT_KEYWORDS([extensions]) +AT_DATA([prog.cob],[ + IDENTIFICATION DIVISION. + PROGRAM-ID. prog. + PROCEDURE DIVISION. + DISPLAY ""135,151,151"bar"195,194,0"" + DISPLAY ""135,257"" + DISPLAY ""135,x,194,1"" + DISPLAY ""135,,155,"" + DISPLAY ""135 155 " " + + STOP RUN. +]) +AT_CHECK([$COMPILE -febcdic-symbolic-characters prog.cob], [1], [], +[prog.cob:5: error: character code 0 out of encoding range (1..256) +prog.cob:6: error: character code 257 out of encoding range (1..256) +prog.cob:7: error: invalid character 'x' in sequence of symbolic EBCDIC characters +prog.cob:8: error: extraneous character ',' in sequence of symbolic EBCDIC characters +prog.cob:8: error: extraneous separator ',' at end of symbolic EBCDIC characters +]) +AT_DATA([prog2.cob],[ + IDENTIFICATION DIVISION. + PROGRAM-ID. prog. + PROCEDURE DIVISION. + DISPLAY ""135,151,151"bar"195,194,234" = foobarBAZ" + STOP RUN. +]) +AT_CHECK([$COMPILE -febcdic-symbolic-characters prog2.cob], [0], [], []) +AT_CHECK([$COMPILE prog2.cob], [0], [], +[prog2.cob:5: warning: alphanumeric literal has zero length; a SPACE will be assumed +]) +AT_CHECK([$COMPILE -febcdic-symbolic-characters -febcdic-table=dummyNotThere prog2.cob], [1], [], +[libcob: error: can't open translation table 'dummyNotThere' +prog2.cob:5: error: invalid parameter: -febcdic-table +]) + +AT_CLEANUP diff --git a/tests/testsuite.src/syn_misc.at b/tests/testsuite.src/syn_misc.at index e4701a92b..787ea8f72 100644 --- a/tests/testsuite.src/syn_misc.at +++ b/tests/testsuite.src/syn_misc.at @@ -8178,3 +8178,25 @@ AT_CHECK([$COMPILE_ONLY -fformat=fixed fixed2.cob], [0], [], []) AT_CHECK([$COMPILE_ONLY -fformat=fixed domfixed.cob], [0], [], []) AT_CLEANUP + +AT_SETUP([context sensitive alias]) +AT_KEYWORDS([misc context alias]) + +AT_DATA([prog.cob], [ + IDENTIFICATION DIVISION. + PROGRAM-ID. prog. + DATA DIVISION. + WORKING-STORAGE SECTION. + 01 XX PIC 9. + 01 X CONSTANT AS XX OF XX. + PROCEDURE DIVISION. + MOVE X TO XX. + DISPLAY XX NO ADVANCING + END-DISPLAY. + STOP RUN. +]) + +AT_CHECK([$COMPILE -freserved="XX*=BYTE-LENGTH" prog.cob], [0], [], []) +AT_CHECK([$COBCRUN_DIRECT ./prog], [0], [1]) + +AT_CLEANUP