diff --git a/cobc/cobc.c b/cobc/cobc.c index 915353ed4..215b0a95c 100644 --- a/cobc/cobc.c +++ b/cobc/cobc.c @@ -4218,6 +4218,10 @@ process_command_line (const int argc, char **argv) cb_flag_alt_ebcdic ? "alternate" : "default"); } + if (cob_load_collation (cb_ebcdic_table, ebcdic_to_ascii, ascii_to_ebcdic) < 0) { + cobc_err_exit (_("invalid parameter: %s"), "-febcdic-table"); + } + /* Exit on missing options */ #ifdef COB_INTERNAL_XREF if (cb_listing_xref && !cb_listing_outputfile) { diff --git a/cobc/codegen.c b/cobc/codegen.c index 3003d52bf..412bed512 100644 --- a/cobc/codegen.c +++ b/cobc/codegen.c @@ -2652,12 +2652,6 @@ output_colseq_table_field (const char * field_name, const char * table_name) static void output_collating_tables (void) { - - /* Load the collating tables if needed */ - if (gen_ascii_ebcdic || gen_ebcdic_ascii) { - load_collating_tables (); - } - if (gen_native) { output_storage ("\n/* NATIVE table */\n"); output_colseq_table ("cob_native", NULL); diff --git a/cobc/scanner.l b/cobc/scanner.l index 878e660e9..dd7e21c52 100644 --- a/cobc/scanner.l +++ b/cobc/scanner.l @@ -1347,10 +1347,6 @@ 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++] = (char)c; @@ -1367,20 +1363,7 @@ scan_ebcdic_char (int c) #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 '?'; - } + return ebcdic_to_ascii[c]; #endif } diff --git a/cobc/tree.c b/cobc/tree.c index 906027052..0abdf764f 100644 --- a/cobc/tree.c +++ b/cobc/tree.c @@ -2193,8 +2193,8 @@ cb_build_program (struct cb_program *last_program, const int nest_level) p->decimal_point = '.'; p->currency_symbol = '$'; p->numeric_separator = ','; - p->low_value = '\0'; - p->high_value = '\xff'; + p->low_value = 0; + p->high_value = 255; if (cb_call_extfh) { p->extfh = cobc_parse_strdup (cb_call_extfh); } diff --git a/cobc/typeck.c b/cobc/typeck.c index 0b579c02b..cf084923b 100644 --- a/cobc/typeck.c +++ b/cobc/typeck.c @@ -3745,19 +3745,6 @@ get_value (cb_tree x) } } -void -load_collating_tables (void) -{ - static int coltab_loaded = 0; - if (coltab_loaded) { - return; - } - if (cob_load_collation (cb_ebcdic_table, ebcdic_to_ascii, ascii_to_ebcdic) < 0) { - cobc_err_exit (_("invalid parameter: %s"), "-febcdic-table"); - } - coltab_loaded = 1; -} - static int cb_validate_collating (struct cb_program *prog, cb_tree collating_sequence) { @@ -3776,33 +3763,40 @@ cb_validate_collating (struct cb_program *prog, cb_tree collating_sequence) #ifdef COB_EBCDIC_MACHINE if (CB_ALPHABET_NAME (x)->alphabet_type == CB_ALPHABET_ASCII) { - load_collating_tables (); prog->low_value = ascii_to_ebcdic[0x00]; prog->high_value = ascii_to_ebcdic[0xff]; #else if (CB_ALPHABET_NAME (x)->alphabet_type == CB_ALPHABET_EBCDIC) { - load_collating_tables (); prog->low_value = ebcdic_to_ascii[0x00]; prog->high_value = ebcdic_to_ascii[0xff]; #endif } else if (CB_ALPHABET_NAME (x)->alphabet_type == CB_ALPHABET_CUSTOM) { - prog->low_value = (unsigned char)CB_ALPHABET_NAME (x)->low_val_char; - prog->high_value = (unsigned char)CB_ALPHABET_NAME (x)->high_val_char; + if (CB_ALPHABET_NAME (x)->alphabet_target == CB_ALPHABET_ALPHANUMERIC) { + prog->low_value = (unsigned char)CB_ALPHABET_NAME (x)->low_val_char; + prog->high_value = (unsigned char)CB_ALPHABET_NAME (x)->high_val_char; + } else { + /* TODO: LOW/HIGH-VALUE for national */ + } } else { return 0; } - if (prog->low_value) { - cb_low = cb_build_alphanumeric_literal ("\0", (size_t)1); - CB_LITERAL(cb_low)->data[0] = prog->low_value; - CB_LITERAL(cb_low)->all = 1; - } + if (CB_ALPHABET_NAME (x)->alphabet_target == CB_ALPHABET_ALPHANUMERIC) { + if (prog->low_value) { + cb_low = cb_build_alphanumeric_literal ("\0", (size_t)1); + CB_LITERAL(cb_low)->data[0] = prog->low_value; + CB_LITERAL(cb_low)->all = 1; + } - if (prog->high_value != 255){ - cb_high = cb_build_alphanumeric_literal ("\0", (size_t)1); - CB_LITERAL(cb_high)->data[0] = prog->high_value; - CB_LITERAL(cb_high)->all = 1; + if (prog->high_value != 255){ + cb_high = cb_build_alphanumeric_literal ("\0", (size_t)1); + CB_LITERAL(cb_high)->data[0] = prog->high_value; + CB_LITERAL(cb_high)->all = 1; + } + } else { + /* TODO: LOW/HIGH-VALUE for national */ } + return 0; } @@ -3855,7 +3849,6 @@ validate_alphabet (cb_tree alphabet) register int *entry = ap->values; for (n = 0; n < COB_MAX_CHAR_ALPHANUMERIC + 1; n++) { #ifdef COB_EBCDIC_MACHINE - load_collating_tables (); *entry = (int)ascii_to_ebcdic[n]; #else *entry = n; @@ -3880,7 +3873,6 @@ validate_alphabet (cb_tree alphabet) #ifdef COB_EBCDIC_MACHINE *entry = n; #else - load_collating_tables (); *entry = (int)ebcdic_to_ascii[n]; #endif entry++; diff --git a/tests/testsuite.src/run_misc.at b/tests/testsuite.src/run_misc.at index 67eb1fb92..727bf0475 100644 --- a/tests/testsuite.src/run_misc.at +++ b/tests/testsuite.src/run_misc.at @@ -4009,6 +4009,12 @@ AT_KEYWORDS([runmisc default-colseq]) AT_DATA([prog.cob], [ IDENTIFICATION DIVISION. PROGRAM-ID. prog. + ENVIRONMENT DIVISION. + CONFIGURATION SECTION. + OBJECT-COMPUTER. x86, + PROGRAM COLLATING SEQUENCE IS alpha-ebcdic. + SPECIAL-NAMES. + ALPHABET alpha-ebcdic IS EBCDIC. DATA DIVISION. WORKING-STORAGE SECTION. 01 TAB. @@ -4029,7 +4035,7 @@ AT_DATA([prog.cob], [ STOP RUN. ]) -AT_CHECK([$COMPILE -febcdic-table=ebcdic500_latin1 -fdefault-colseq=EBCDIC prog.cob], [0], [], []) +AT_CHECK([$COMPILE -febcdic-table=ebcdic500_latin1 prog.cob], [0], [], []) AT_CHECK([$COBCRUN_DIRECT ./prog], [0], [], []) AT_CLEANUP diff --git a/tests/testsuite.src/syn_literals.at b/tests/testsuite.src/syn_literals.at index f4d8f8a5d..ea9d3d7da 100644 --- a/tests/testsuite.src/syn_literals.at +++ b/tests/testsuite.src/syn_literals.at @@ -1556,7 +1556,7 @@ AT_CHECK([$COMPILE prog2.cob], [0], [], ]) 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 +cobc: error: invalid parameter: -febcdic-table ]) AT_CLEANUP