diff --git a/cobc/ChangeLog b/cobc/ChangeLog index c32ed1846..29ba7a811 100644 --- a/cobc/ChangeLog +++ b/cobc/ChangeLog @@ -195,6 +195,14 @@ from copy_children, copy_into_field_recursive * tree.c (build_sum_counter): fix reference to sum counter +2022-09-30 Nicolas Berthier + + * codegen.c, cconv.h, cconv.c: extract EBCDIC & ASCII conversion tables + to a dedicated module + * codegen.c: factorize functions for outputting conversion tables + * flag.def, help.c: add -febcdic-table flag to customize EBCDIC + translation + 2022-09-30 Simon Sobisch * flag.def (cb_flag_stack_extended), cobc.c: new option "stack-extended" diff --git a/cobc/Makefile.am b/cobc/Makefile.am index 0a978778c..84df8504f 100644 --- a/cobc/Makefile.am +++ b/cobc/Makefile.am @@ -20,10 +20,10 @@ # along with GnuCOBOL. If not, see . bin_PROGRAMS = cobc -cobc_SOURCES = cobc.c cobc.h ppparse.y pplex.c parser.y scanner.c config.c \ - reserved.c error.c tree.c tree.h field.c typeck.c codegen.c help.c \ - sqlxfdgen.c \ - config.def flag.def warning.def codeoptim.def ppparse.def codeoptim.c +cobc_SOURCES = cobc.c cobc.h ppparse.y pplex.c parser.y scanner.c \ + config.c reserved.c error.c tree.c tree.h cconv.c cconv.h \ + field.c typeck.c codegen.c help.c sqlxfdgen.c config.def \ + flag.def warning.def codeoptim.def ppparse.def codeoptim.c #cobc_SOURCES = cobc.c cobc.h ppparse.y pplex.l parser.y scanner.l config.c diff --git a/cobc/cconv.c b/cobc/cconv.c new file mode 100644 index 000000000..865636fcf --- /dev/null +++ b/cobc/cconv.c @@ -0,0 +1,359 @@ +/* + Copyright (C) 2022 Free Software Foundation, Inc. Written by Keisuke + Nishida, Roger While, Simon Sobisch, Edwart Hart, Ron Norman, Nicolas + Berthier + + This file is part of GnuCOBOL. + + The GnuCOBOL compiler is free software: you can redistribute it + and/or modify it under the terms of the GNU General Public License + as published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + GnuCOBOL is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GnuCOBOL. If not, see . +*/ +#include "cconv.h" +#include "cobc.h" /* for cb_strcasecmp */ + +/* TODO: Maybe use iconv or gconv before extending to other character sets while + using standard naming scheme? Note, however, that specifications for GCOS7 + Bull variant(s) for those libraries might not be implemented yet. */ + +/* "default" EBCDIC to ASCII table; this table was copied from + `codegen.c:output_ebcdic_to_ascii_table`. There are many "EBCDIC-*" variants + out there [1]. This one is thought to be as encoded by MF. + + Hints: + + 0x5B (ASCII '[') is at index 173 (0xAD), which does appear to correspond to + some conversion irregularities [2]. + + However following [3], we should find the same ASCII character 0x5B further + below at index 186 (0xBA); yet there we find 0xAA. + + [1] https://www.rfc-editor.org/rfc/rfc1345 + [2] https://www.ibm.com/docs/en/iis/11.3?topic=tables-conversion-table-irregularities + [3] https://www.ibm.com/docs/en/cobol-zos/6.1?topic=sequences-ebcdic-collating-sequence +*/ +const cob_u8_t cob_ebcdic_ascii[256] = { + 0x00, 0x01, 0x02, 0x03, 0xEC, 0x09, 0xCA, 0x7F, + 0xE2, 0xD2, 0xD3, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x10, 0x11, 0x12, 0x13, 0xEF, 0xC5, 0x08, 0xCB, + 0x18, 0x19, 0xDC, 0xD8, 0x1C, 0x1D, 0x1E, 0x1F, + 0xB7, 0xB8, 0xB9, 0xBB, 0xC4, 0x0A, 0x17, 0x1B, + 0xCC, 0xCD, 0xCF, 0xD0, 0xD1, 0x05, 0x06, 0x07, + 0xD9, 0xDA, 0x16, 0xDD, 0xDE, 0xDF, 0xE0, 0x04, + 0xE3, 0xE5, 0xE9, 0xEB, 0x14, 0x15, 0x9E, 0x1A, + 0x20, 0xC9, 0x83, 0x84, 0x85, 0xA0, 0xF2, 0x86, + 0x87, 0xA4, 0xD5, 0x2E, 0x3C, 0x28, 0x2B, 0xB3, + 0x26, 0x82, 0x88, 0x89, 0x8A, 0xA1, 0x8C, 0x8B, + 0x8D, 0xE1, 0x21, 0x24, 0x2A, 0x29, 0x3B, 0x5E, + 0x2D, 0x2F, 0xB2, 0x8E, 0xB4, 0xB5, 0xB6, 0x8F, + 0x80, 0xA5, 0x7C, 0x2C, 0x25, 0x5F, 0x3E, 0x3F, + 0xBA, 0x90, 0xBC, 0xBD, 0xBE, 0xF3, 0xC0, 0xC1, + 0xC2, 0x60, 0x3A, 0x23, 0x40, 0x27, 0x3D, 0x22, + 0xC3, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0xAE, 0xAF, 0xC6, 0xC7, 0xC8, 0xF1, + 0xF8, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, + 0x71, 0x72, 0xA6, 0xA7, 0x91, 0xCE, 0x92, 0xA9, + 0xE6, 0x7E, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, + 0x79, 0x7A, 0xAD, 0xA8, 0xD4, 0x5B, 0xD6, 0xD7, + 0x9B, 0x9C, 0x9D, 0xFA, 0x9F, 0xB1, 0xB0, 0xAC, + 0xAB, 0xFC, 0xAA, 0xFE, 0xE4, 0x5D, 0xBF, 0xE7, + 0x7B, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, + 0x48, 0x49, 0xE8, 0x93, 0x94, 0x95, 0xA2, 0xED, + 0x7D, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, + 0x51, 0x52, 0xEE, 0x96, 0x81, 0x97, 0xA3, 0x98, + 0x5C, 0xF0, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, + 0x59, 0x5A, 0xFD, 0xF5, 0x99, 0xF7, 0xF6, 0xF9, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0xDB, 0xFB, 0x9A, 0xF4, 0xEA, 0xFF +}; + +/* ASCII to "default" (likely MF) EBCDIC conversion table. */ +const cob_u8_t cob_ascii_ebcdic[256] = { + 0x00, 0x01, 0x02, 0x03, 0x37, 0x2D, 0x2E, 0x2F, + 0x16, 0x05, 0x25, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x10, 0x11, 0x12, 0x13, 0x3C, 0x3D, 0x32, 0x26, + 0x18, 0x19, 0x3F, 0x27, 0x1C, 0x1D, 0x1E, 0x1F, + 0x40, 0x5A, 0x7F, 0x7B, 0x5B, 0x6C, 0x50, 0x7D, + 0x4D, 0x5D, 0x5C, 0x4E, 0x6B, 0x60, 0x4B, 0x61, + 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, + 0xF8, 0xF9, 0x7A, 0x5E, 0x4C, 0x7E, 0x6E, 0x6F, + 0x7C, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, + 0xC8, 0xC9, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, + 0xD7, 0xD8, 0xD9, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, + 0xE7, 0xE8, 0xE9, 0xAD, 0xE0, 0xBD, 0x5F, 0x6D, + 0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, + 0x97, 0x98, 0x99, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, + 0xA7, 0xA8, 0xA9, 0xC0, 0x6A, 0xD0, 0xA1, 0x07, + 0x68, 0xDC, 0x51, 0x42, 0x43, 0x44, 0x47, 0x48, + 0x52, 0x53, 0x54, 0x57, 0x56, 0x58, 0x63, 0x67, + 0x71, 0x9C, 0x9E, 0xCB, 0xCC, 0xCD, 0xDB, 0xDD, + 0xDF, 0xEC, 0xFC, 0xB0, 0xB1, 0xB2, 0x3E, 0xB4, + 0x45, 0x55, 0xCE, 0xDE, 0x49, 0x69, 0x9A, 0x9B, + 0xAB, 0x9F, 0xBA, 0xB8, 0xB7, 0xAA, 0x8A, 0x8B, + 0xB6, 0xB5, 0x62, 0x4F, 0x64, 0x65, 0x66, 0x20, + 0x21, 0x22, 0x70, 0x23, 0x72, 0x73, 0x74, 0xBE, + 0x76, 0x77, 0x78, 0x80, 0x24, 0x15, 0x8C, 0x8D, + 0x8E, 0x41, 0x06, 0x17, 0x28, 0x29, 0x9D, 0x2A, + 0x2B, 0x2C, 0x09, 0x0A, 0xAC, 0x4A, 0xAE, 0xAF, + 0x1B, 0x30, 0x31, 0xFA, 0x1A, 0x33, 0x34, 0x35, + 0x36, 0x59, 0x08, 0x38, 0xBC, 0x39, 0xA0, 0xBF, + 0xCA, 0x3A, 0xFE, 0x3B, 0x04, 0xCF, 0xDA, 0x14, + 0xE1, 0x8F, 0x46, 0x75, 0xFD, 0xEB, 0xEE, 0xED, + 0x90, 0xEF, 0xB3, 0xFB, 0xB9, 0xEA, 0xBB, 0xFF +}; + + +/* EBCDIC GCOS7 8-bit to ASCII conversion table. */ +const cob_u8_t cob_gcos7ebcdic_ascii[256] = { + 0x00, 0x01, 0x02, 0x03, 0x9C, 0x09, 0x86, 0x7F, + 0x97, 0x8D, 0x8E, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x10, 0x11, 0x12, 0x13, 0x9D, 0x85, 0x08, 0x87, + 0x18, 0x19, 0x92, 0x8F, 0x1C, 0x1D, 0x1E, 0x1F, + 0x80, 0x81, 0x82, 0x83, 0x84, 0x0A, 0x17, 0x1B, + 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x05, 0x06, 0x07, + 0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04, + 0x98, 0x99, 0x9A, 0x9B, 0x14, 0x15, 0x9E, 0x1A, + 0x20, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, + 0xA7, 0xA8, 0x5B, 0x2E, 0x3C, 0x28, 0x2B, 0x21, + 0x26, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, + 0xB0, 0xB1, 0x5D, 0x24, 0x2A, 0x29, 0x3B, 0x5E, + 0x2D, 0x2F, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, + 0xB8, 0xB9, 0x7C, 0x2C, 0x25, 0x5F, 0x3E, 0x3F, + 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xC0, 0xC1, + 0xC2, 0x60, 0x3A, 0x23, 0x40, 0x27, 0x3D, 0x22, + 0xC3, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, + 0xCA, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, + 0x71, 0x72, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, + 0xD1, 0x7E, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, + 0x79, 0x7A, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, + 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, + 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, + 0x7B, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, + 0x48, 0x49, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, + 0x7D, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, + 0x51, 0x52, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, + 0x5C, 0x9F, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, + 0x59, 0x5A, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF +}; + +/* ASCII to GCOS7 EBCDIC conversion table. */ +const cob_u8_t cob_ascii_gcos7ebcdic[256] = { + 0x00, 0x01, 0x02, 0x03, 0x37, 0x2D, 0x2E, 0x2F, + 0x16, 0x05, 0x25, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x10, 0x11, 0x12, 0x13, 0x3C, 0x3D, 0x32, 0x26, + 0x18, 0x19, 0x3F, 0x27, 0x1C, 0x1D, 0x1E, 0x1F, + 0x40, 0x4F, 0x7F, 0x7B, 0x5B, 0x6C, 0x50, 0x7D, + 0x4D, 0x5D, 0x5C, 0x4E, 0x6B, 0x60, 0x4B, 0x61, + 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, + 0xF8, 0xF9, 0x7A, 0x5E, 0x4C, 0x7E, 0x6E, 0x6F, + 0x7C, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, + 0xC8, 0xC9, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, + 0xD7, 0xD8, 0xD9, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, + 0xE7, 0xE8, 0xE9, 0x4A, 0xE0, 0x5A, 0x5F, 0x6D, + 0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, + 0x97, 0x98, 0x99, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, + 0xA7, 0xA8, 0xA9, 0xC0, 0x6A, 0xD0, 0xA1, 0x07, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x15, 0x06, 0x17, + 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x09, 0x0A, 0x1B, + 0x30, 0x31, 0x1A, 0x33, 0x34, 0x35, 0x36, 0x08, + 0x38, 0x39, 0x3A, 0x3B, 0x04, 0x14, 0x3E, 0xE1, + 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, + 0x49, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, + 0x58, 0x59, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, + 0x76, 0x77, 0x78, 0x80, 0x8A, 0x8B, 0x8C, 0x8D, + 0x8E, 0x8F, 0x90, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, + 0x9F, 0xA0, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, + 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, + 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, + 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xDA, 0xDB, + 0xDC, 0xDD, 0xDE, 0xDF, 0xEA, 0xEB, 0xEC, 0xED, + 0xEE, 0xEF, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF +}; + +/* EBCDIC GCOS7 8-bit to "default" EBCDIC conversion table. + + This is basically the composition of cob_gcos7ebcdic_ascii and the "inverse" + of cob_ebcdic_ascii. +*/ +const cob_u8_t cob_gcos7ebcdic_ebcdic[256] = { + 0x00, 0x01, 0x02, 0x03, 0xB1, 0x05, 0x47, 0x07, + 0xDD, 0x58, 0x63, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x10, 0x11, 0x12, 0x13, 0xB2, 0x44, 0x16, 0x48, + 0x18, 0x19, 0x9E, 0x67, 0x1C, 0x1D, 0x1E, 0x1F, + 0x68, 0xDC, 0x51, 0x42, 0x43, 0x25, 0x26, 0x27, + 0x52, 0x53, 0x54, 0x57, 0x56, 0x2D, 0x2E, 0x2F, + 0x71, 0x9C, 0x32, 0xCB, 0xCC, 0xCD, 0xDB, 0x37, + 0xDF, 0xEC, 0xFC, 0xB0, 0x3C, 0x3D, 0x3E, 0x3F, + 0x40, 0x45, 0x55, 0xCE, 0xDE, 0x49, 0x69, 0x9A, + 0x9B, 0xAB, 0xAD, 0x4B, 0x4C, 0x4D, 0x4E, 0x5A, + 0x50, 0x9F, 0xBA, 0xB8, 0xB7, 0xAA, 0x8A, 0x8B, + 0xB6, 0xB5, 0xBD, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, + 0x60, 0x61, 0x62, 0x4F, 0x64, 0x65, 0x66, 0x20, + 0x21, 0x22, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, + 0x70, 0x23, 0x72, 0x73, 0x74, 0xBE, 0x76, 0x77, + 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, + 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + 0x88, 0x89, 0x24, 0x15, 0x8C, 0x8D, 0x8E, 0x41, + 0x06, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, + 0x98, 0x99, 0x17, 0x28, 0x29, 0x9D, 0x2A, 0x2B, + 0x2C, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, + 0xA8, 0xA9, 0x09, 0x0A, 0xAC, 0x4A, 0xAE, 0xAF, + 0x1B, 0x30, 0x31, 0xFA, 0x1A, 0x33, 0x34, 0x35, + 0x36, 0x59, 0x08, 0x38, 0xBC, 0x39, 0xA0, 0xBF, + 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, + 0xC8, 0xC9, 0xCA, 0x3A, 0xFE, 0x3B, 0x04, 0xCF, + 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, + 0xD8, 0xD9, 0xDA, 0x14, 0xE1, 0x8F, 0x46, 0x75, + 0xE0, 0xB4, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, + 0xE8, 0xE9, 0xFD, 0xEB, 0xEE, 0xED, 0x90, 0xEF, + 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, + 0xF8, 0xF9, 0xB3, 0xFB, 0xB9, 0xEA, 0xBB, 0xFF +}; + +/* ASCII to "default" (?) EBCDIC conversion table (restricted) */ +const cob_u8_t cob_ascii_alt_ebcdic[256] = { + 0x00, 0x01, 0x02, 0x03, 0x1D, 0x19, 0x1A, 0x1B, + 0x0F, 0x04, 0x16, 0x06, 0x07, 0x08, 0x09, 0x0A, + 0x0B, 0x0C, 0x0D, 0x0E, 0x1E, 0x1F, 0x1C, 0x17, + 0x10, 0x11, 0x20, 0x18, 0x12, 0x13, 0x14, 0x15, + 0x21, 0x27, 0x3A, 0x36, 0x28, 0x30, 0x26, 0x38, + 0x24, 0x2A, 0x29, 0x25, 0x2F, 0x2C, 0x22, 0x2D, + 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, + 0x7B, 0x7C, 0x35, 0x2B, 0x23, 0x39, 0x32, 0x33, + 0x37, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, + 0x5E, 0x5F, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, + 0x67, 0x68, 0x69, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, + 0x70, 0x71, 0x72, 0x7D, 0x6A, 0x7E, 0x7F, 0x31, + 0x34, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, + 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, + 0x4A, 0x4B, 0x4C, 0x4E, 0x4F, 0x50, 0x51, 0x52, + 0x53, 0x54, 0x55, 0x56, 0x2E, 0x60, 0x4D, 0x05, + 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, + 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, + 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, + 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, + 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, + 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, + 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, + 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, + 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, + 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, + 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, + 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, + 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, + 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF +}; + +/* IBM EBCDIC to ASCII conversion table (restricted) + + cf https://www.ibm.com/docs/en/iis/11.3?topic=tables-ebcdic-ascii; + Irregularities not accounted for */ +const cob_u8_t cob_ibmebcdic_ascii[256] = { + 0x00, 0x01, 0x02, 0x03, 0x1A, 0x09, 0x1A, 0x7F, + 0x1A, 0x1A, 0x1A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x10, 0x11, 0x12, 0x13, 0x1A, 0x1A, 0x08, 0x1A, + 0x18, 0x19, 0x1A, 0x1A, 0x1C, 0x1D, 0x1E, 0x1F, + 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x0A, 0x17, 0x1B, + 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x05, 0x06, 0x07, + 0x1A, 0x1A, 0x16, 0x1A, 0x1A, 0x1A, 0x1A, 0x04, + 0x1A, 0x1A, 0x1A, 0x1A, 0x14, 0x15, 0x1A, 0x1A, + 0x20, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, + 0x1A, 0x1A, 0x5B, 0x2E, 0x3C, 0x28, 0x2B, 0x21, + 0x26, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, + 0x1A, 0x1A, 0x5D, 0x24, 0x2A, 0x29, 0x3B, 0x5E, + 0x2D, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, + 0x1A, 0x1A, 0x7C, 0x2C, 0x25, 0x5F, 0x3E, 0x3F, + 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, + 0x1A, 0x60, 0x3A, 0x23, 0x40, 0x27, 0x3D, 0x22, + 0x1A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, + 0x1A, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, + 0x71, 0x72, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, + 0x1A, 0x7E, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, + 0x79, 0x7A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, + 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, + 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, + 0x7B, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, + 0x48, 0x49, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, + 0x7D, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, + 0x51, 0x52, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, + 0x5C, 0x1A, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, + 0x59, 0x5A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A +}; + +/* ASCII to IBM EBCDIC conversion table (restricted) + + cf https://www.ibm.com/docs/en/iis/11.3?topic=tables-ascii-ebcdic; + Irregularities not accounted for */ +const cob_u8_t cob_ascii_ibmebcdic[256] = { + 0x00, 0x01, 0x02, 0x03, 0x1A, 0x09, 0x1A, 0x7F, + 0x1A, 0x1A, 0x1A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x10, 0x11, 0x12, 0x13, 0x3C, 0x3D, 0x32, 0x26, + 0x18, 0x19, 0x3F, 0x27, 0x1C, 0x1D, 0x1E, 0x1F, + 0x40, 0x4F, 0x7F, 0x7B, 0x5B, 0x6C, 0x50, 0x7D, + 0x4D, 0x5D, 0x5C, 0x4E, 0x6B, 0x60, 0x4B, 0x61, + 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, + 0xF8, 0xF9, 0x7A, 0x5E, 0x4C, 0x7E, 0x6E, 0x6F, + 0x7C, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, + 0xC8, 0xC9, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, + 0xD7, 0xD8, 0xD9, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, + 0xE7, 0xE8, 0xE9, 0x4A, 0xE0, 0x5A, 0x5F, 0x6D, + 0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, + 0x97, 0x98, 0x99, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, + 0xA7, 0xA8, 0xA9, 0xC0, 0x6A, 0xD0, 0xA1, 0x07, + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F +}; + +enum ebcdic_table cb_ebcdic_table = CB_EBCDIC_DEFAULT; + +/* Decipher character conversion table names */ +int cobc_deciph_ebcdic_table_name (const char *name) +{ + if (! cb_strcasecmp (name, "DEFAULT")) { + cb_ebcdic_table = CB_EBCDIC_DEFAULT; + } else if (! cb_strcasecmp (name, "RESTRICTED-GC")) { + cb_ebcdic_table = CB_EBCDIC_RESTRICTED_GC; + } else if (! cb_strcasecmp (name, "IBM")) { + cb_ebcdic_table = CB_EBCDIC_IBM; + } else if (! cb_strcasecmp (name, "GCOS")) { + cb_ebcdic_table = CB_EBCDIC_GCOS; + } else { + return 1; + } + return 0; +} diff --git a/cobc/cconv.h b/cobc/cconv.h new file mode 100644 index 000000000..bb81160ec --- /dev/null +++ b/cobc/cconv.h @@ -0,0 +1,78 @@ +/* + Copyright (C) 2022 Free Software Foundation, Inc. Written by Keisuke + Nishida, Roger While, Simon Sobisch, Edwart Hart, Ron Norman, Nicolas + Berthier + + This file is part of GnuCOBOL. + + The GnuCOBOL compiler is free software: you can redistribute it + and/or modify it under the terms of the GNU General Public License + as published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + GnuCOBOL is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GnuCOBOL. If not, see . +*/ +#ifndef CB_CCONV_H +#define CB_CCONV_H + +/* FIXME: inclusion of unistd.h is required for size_t. As in cobc.h, this may + require an additional installed header. */ +#include "config.h" +#ifdef HAVE_UNISTD_H +#include +#endif +#include "../libcob/common.h" + +/* "default" (likely MF) EBCDIC to ASCII conversion table */ +extern const cob_u8_t cob_ebcdic_ascii[256]; + +/* ASCII to "default" (likely MF) EBCDIC conversion table */ +extern const cob_u8_t cob_ascii_ebcdic[256]; + +/* EBCDIC GCOS7 8-bit to ASCII conversion table: + + https://support.bull.com/ols/product/system/gcos7/gcos7-com/g7-dps7000/doc-com/docf/g/47X257TN27-oct2009/47A205UL04.pdf, + p627. Note one page is missing from this documentation, but the full table + can be found in the French version. */ +extern const cob_u8_t cob_gcos7ebcdic_ascii[256]; + +/* EBCDIC GCOS7 8-bit to "default" EBCDIC conversion table */ +extern const cob_u8_t cob_gcos7ebcdic_ebcdic[256]; + +/* ASCII (8-bit) to EBCDIC GCOS7 conversion table */ +extern const cob_u8_t cob_ascii_gcos7ebcdic[256]; + +/* Restricted conversions: */ + +/* ASCII to EBCDIC conversion table (restricted) */ +extern const cob_u8_t cob_ascii_alt_ebcdic[256]; + +/* IBM EBCDIC to ASCII conversion table (restricted) + + cf https://www.ibm.com/docs/en/iis/11.3?topic=tables-ebcdic-ascii */ +extern const cob_u8_t cob_ibmebcdic_ascii[256]; + +/* ASCII to IBM EBCDIC conversion table (restricted) + + cf https://www.ibm.com/docs/en/iis/11.3?topic=tables-ascii-ebcdic */ +extern const cob_u8_t cob_ascii_ibmebcdic[256]; + +/* All supported conversions */ +enum ebcdic_table { + CB_EBCDIC_DEFAULT, + CB_EBCDIC_RESTRICTED_GC, + CB_EBCDIC_IBM, + CB_EBCDIC_GCOS, +}; + +extern enum ebcdic_table cb_ebcdic_table; + +int cobc_deciph_ebcdic_table_name (const char *const); + +#endif /* CB_CCONV_H */ diff --git a/cobc/cobc.c b/cobc/cobc.c index d6266ecc9..1a387a7a6 100644 --- a/cobc/cobc.c +++ b/cobc/cobc.c @@ -61,6 +61,7 @@ #include "cobc.h" #include "tree.h" +#include "cconv.h" #include "../libcob/cobgetopt.h" @@ -3583,6 +3584,13 @@ process_command_line (const int argc, char **argv) } break; + case 16: + /* -febcdic-table= */ + if (cobc_deciph_ebcdic_table_name (cob_optarg)) { + cobc_err_exit (COBC_INV_PAR, "-febcdic-table"); + } + break; + case 4: /* -ffold-copy= : COPY fold case */ if (!cb_strcasecmp (cob_optarg, "UPPER")) { diff --git a/cobc/cobc.h b/cobc/cobc.h index 7e6fc354b..3c4f8e23d 100644 --- a/cobc/cobc.h +++ b/cobc/cobc.h @@ -28,12 +28,11 @@ and include that here */ #ifdef HAVE_UNISTD_H #include -#else -#include #endif -#include /* for FILE* */ +#include /* for FILE */ #include "../libcob/common.h" +#include "cconv.h" #ifdef ENABLE_NLS #include "../lib/gettext.h" diff --git a/cobc/codegen.c b/cobc/codegen.c index 4405f77a5..73b71aac9 100644 --- a/cobc/codegen.c +++ b/cobc/codegen.c @@ -177,9 +177,11 @@ static unsigned int needs_exit_prog = 0; static unsigned int needs_unifunc = 0; static unsigned int need_save_exception = 0; static unsigned int gen_nested_tab = 0; +static unsigned int gen_default_ebcdic = 0; static unsigned int gen_alt_ebcdic = 0; static unsigned int gen_ebcdic_ascii = 0; -static unsigned int gen_full_ebcdic = 0; +static unsigned int gen_ibm_ebcdic = 0; +static unsigned int gen_gcos7_ebcdic = 0; static unsigned int gen_native = 0; static unsigned int gen_custom = 0; static unsigned int gen_figurative = 0; @@ -820,7 +822,7 @@ static int chk_field_multi_values (struct cb_field *f) { struct cb_field *fc; - if (f->values + if (f->values && CB_CHAIN (f->values)) { return 1; } @@ -1275,7 +1277,7 @@ output_data (cb_tree x) struct cb_field *f = CB_FIELD (r->value); int did_check = 0; - if (r->check + if (r->check && !gen_init_working && in_cond && inside_check == 0) { @@ -1395,7 +1397,7 @@ output_data (cb_tree x) output_index (r->offset); } - if (r->check + if (r->check && did_check) { --inside_check; output(")"); /* End expression */ @@ -2905,7 +2907,7 @@ output_local_field_cache (struct cb_program *prog) output_newline (); } if (f->storage == CB_STORAGE_REPORT - && f->flag_occurs + && f->flag_occurs && f->occurs_max > 1) { /* generate sub-fields and a comment each */ output_emit_field (cb_build_field_reference (f, NULL), NULL); @@ -2953,7 +2955,7 @@ output_local_fields (struct cb_program *prog) } output_local_field_cache (prog); - + /* Output variable size/location parameters */ for (l = prog->parameter_list; l; l = CB_CHAIN (l)) { f = cb_code_field (CB_VALUE (l)); @@ -3159,156 +3161,158 @@ output_literals_figuratives_and_constants (void) /* Collating tables */ +enum cb_cconv_dir { OF_ASCII, TO_ASCII }; +static const char * +colseq_table_name (const enum ebcdic_table table_name, + const enum cb_cconv_dir direction, + const unsigned int field) +{ + /* FIXME: assumes !COB_EBCDIC_MACHINE */ + /* FIXME: record direction as well, so we know better what tables and + fields to output later on; for now only OF_ASCII is recorded. */ + switch (table_name) { + case CB_EBCDIC_DEFAULT: + default: + gen_default_ebcdic |= field ? 2 : 1; + return direction == OF_ASCII + ? "cob_ascii_ebcdic" + : "cob_ebcdic_ascii"; + case CB_EBCDIC_RESTRICTED_GC: + gen_alt_ebcdic |= field ? 2 : 1; + if (direction == TO_ASCII) { + /* TODO: define inverse conversion */ + cobc_err_msg ("Unexpected conversion from " + "restricted EBCDIC to ASCII!"); + COBC_ABORT (); + } + return "cob_a2e"; + case CB_EBCDIC_IBM: + gen_ibm_ebcdic |= field ? 2 : 1; + return direction == OF_ASCII + ? "cob_ascii_ibmebcdic" + : "cob_ibmebcdic_ascii"; + case CB_EBCDIC_GCOS: + gen_gcos7_ebcdic |= field ? 2 : 1; + return direction == OF_ASCII + ? "cob_ascii_gcos7ebcdic" + : "cob_gcos7ebcdic_ascii"; + } +} + +/* Outputs conversion from given table, or a native conversion (identity) when + omitted (if table == NULL). */ +static void +output_colseq_table (const char * const table_name, + const cob_u8_t table[256]) +{ + int i; + output_storage ("static const unsigned char\t%s[256] = {", table_name); + for (i = 0; i < 256; i++) { + output_storage ("%s%#04x,", + i % 8 == 0 ? "\n\t" : " ", + table ? table[i] : i); + } + output_storage ("\n};\n"); +} + +static void +output_colseq_table_field (const char * table_name) +{ + const int i = lookup_attr (COB_TYPE_ALPHANUMERIC, 0, 0, 0, NULL, 0); + output_storage ("static cob_field f_%s = { 256, (cob_u8_ptr)%s, &%s%d };\n", + table_name, table_name, CB_PREFIX_ATTR, i); +} + +static void +output_default_ebcdic_table (void) +{ + const char * table_name; + + if (!gen_default_ebcdic) { + return; + } + + table_name = colseq_table_name (CB_EBCDIC_DEFAULT, OF_ASCII, 0); + output_storage ("\n/* ASCII to EBCDIC table */\n"); + output_colseq_table (table_name, cob_ascii_ebcdic); + if (gen_default_ebcdic > 1) { + output_colseq_table_field (table_name); + } + output_storage ("\n"); + +} + static void output_alt_ebcdic_table (void) { + const char * table_name; + if (!gen_alt_ebcdic) { return; } + table_name = colseq_table_name (CB_EBCDIC_RESTRICTED_GC, OF_ASCII, 0); output_storage ("\n/* ASCII to EBCDIC translate table (restricted) */\n"); - output_storage ("static const unsigned char\tcob_a2e[256] = {\n"); - /* Restricted table */ - output_storage ("\t0x00, 0x01, 0x02, 0x03, 0x1D, 0x19, 0x1A, 0x1B,\n"); - output_storage ("\t0x0F, 0x04, 0x16, 0x06, 0x07, 0x08, 0x09, 0x0A,\n"); - output_storage ("\t0x0B, 0x0C, 0x0D, 0x0E, 0x1E, 0x1F, 0x1C, 0x17,\n"); - output_storage ("\t0x10, 0x11, 0x20, 0x18, 0x12, 0x13, 0x14, 0x15,\n"); - output_storage ("\t0x21, 0x27, 0x3A, 0x36, 0x28, 0x30, 0x26, 0x38,\n"); - output_storage ("\t0x24, 0x2A, 0x29, 0x25, 0x2F, 0x2C, 0x22, 0x2D,\n"); - output_storage ("\t0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A,\n"); - output_storage ("\t0x7B, 0x7C, 0x35, 0x2B, 0x23, 0x39, 0x32, 0x33,\n"); - output_storage ("\t0x37, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D,\n"); - output_storage ("\t0x5E, 0x5F, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,\n"); - output_storage ("\t0x67, 0x68, 0x69, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F,\n"); - output_storage ("\t0x70, 0x71, 0x72, 0x7D, 0x6A, 0x7E, 0x7F, 0x31,\n"); - output_storage ("\t0x34, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41,\n"); - output_storage ("\t0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49,\n"); - output_storage ("\t0x4A, 0x4B, 0x4C, 0x4E, 0x4F, 0x50, 0x51, 0x52,\n"); - output_storage ("\t0x53, 0x54, 0x55, 0x56, 0x2E, 0x60, 0x4D, 0x05,\n"); - output_storage ("\t0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,\n"); - output_storage ("\t0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F,\n"); - output_storage ("\t0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,\n"); - output_storage ("\t0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F,\n"); - output_storage ("\t0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7,\n"); - output_storage ("\t0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF,\n"); - output_storage ("\t0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7,\n"); - output_storage ("\t0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF,\n"); - output_storage ("\t0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,\n"); - output_storage ("\t0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF,\n"); - output_storage ("\t0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7,\n"); - output_storage ("\t0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF,\n"); - output_storage ("\t0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7,\n"); - output_storage ("\t0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,\n"); - output_storage ("\t0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7,\n"); - output_storage ("\t0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF\n"); - output_storage ("};\n"); + output_colseq_table (table_name, cob_ascii_alt_ebcdic); + if (gen_alt_ebcdic > 1) { + output_colseq_table_field (table_name); + } output_storage ("\n"); } static void -output_full_ebcdic_table (void) +output_ibm_ebcdic_table (void) { - int i; + const char * table_name; - if (!gen_full_ebcdic) { + if (!gen_ibm_ebcdic) { return; } - output_storage ("\n/* ASCII to EBCDIC table */\n"); - output_storage ("static const unsigned char\tcob_ascii_ebcdic[256] = {\n"); - output_storage ("\t0x00, 0x01, 0x02, 0x03, 0x37, 0x2D, 0x2E, 0x2F,\n"); - output_storage ("\t0x16, 0x05, 0x25, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,\n"); - output_storage ("\t0x10, 0x11, 0x12, 0x13, 0x3C, 0x3D, 0x32, 0x26,\n"); - output_storage ("\t0x18, 0x19, 0x3F, 0x27, 0x1C, 0x1D, 0x1E, 0x1F,\n"); - output_storage ("\t0x40, 0x5A, 0x7F, 0x7B, 0x5B, 0x6C, 0x50, 0x7D,\n"); - output_storage ("\t0x4D, 0x5D, 0x5C, 0x4E, 0x6B, 0x60, 0x4B, 0x61,\n"); - output_storage ("\t0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7,\n"); - output_storage ("\t0xF8, 0xF9, 0x7A, 0x5E, 0x4C, 0x7E, 0x6E, 0x6F,\n"); - output_storage ("\t0x7C, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,\n"); - output_storage ("\t0xC8, 0xC9, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6,\n"); - output_storage ("\t0xD7, 0xD8, 0xD9, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6,\n"); - output_storage ("\t0xE7, 0xE8, 0xE9, 0xAD, 0xE0, 0xBD, 0x5F, 0x6D,\n"); - output_storage ("\t0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,\n"); - output_storage ("\t0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96,\n"); - output_storage ("\t0x97, 0x98, 0x99, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,\n"); - output_storage ("\t0xA7, 0xA8, 0xA9, 0xC0, 0x6A, 0xD0, 0xA1, 0x07,\n"); - output_storage ("\t0x68, 0xDC, 0x51, 0x42, 0x43, 0x44, 0x47, 0x48,\n"); - output_storage ("\t0x52, 0x53, 0x54, 0x57, 0x56, 0x58, 0x63, 0x67,\n"); - output_storage ("\t0x71, 0x9C, 0x9E, 0xCB, 0xCC, 0xCD, 0xDB, 0xDD,\n"); - output_storage ("\t0xDF, 0xEC, 0xFC, 0xB0, 0xB1, 0xB2, 0x3E, 0xB4,\n"); - output_storage ("\t0x45, 0x55, 0xCE, 0xDE, 0x49, 0x69, 0x9A, 0x9B,\n"); - output_storage ("\t0xAB, 0x9F, 0xBA, 0xB8, 0xB7, 0xAA, 0x8A, 0x8B,\n"); - output_storage ("\t0xB6, 0xB5, 0x62, 0x4F, 0x64, 0x65, 0x66, 0x20,\n"); - output_storage ("\t0x21, 0x22, 0x70, 0x23, 0x72, 0x73, 0x74, 0xBE,\n"); - output_storage ("\t0x76, 0x77, 0x78, 0x80, 0x24, 0x15, 0x8C, 0x8D,\n"); - output_storage ("\t0x8E, 0x41, 0x06, 0x17, 0x28, 0x29, 0x9D, 0x2A,\n"); - output_storage ("\t0x2B, 0x2C, 0x09, 0x0A, 0xAC, 0x4A, 0xAE, 0xAF,\n"); - output_storage ("\t0x1B, 0x30, 0x31, 0xFA, 0x1A, 0x33, 0x34, 0x35,\n"); - output_storage ("\t0x36, 0x59, 0x08, 0x38, 0xBC, 0x39, 0xA0, 0xBF,\n"); - output_storage ("\t0xCA, 0x3A, 0xFE, 0x3B, 0x04, 0xCF, 0xDA, 0x14,\n"); - output_storage ("\t0xE1, 0x8F, 0x46, 0x75, 0xFD, 0xEB, 0xEE, 0xED,\n"); - output_storage ("\t0x90, 0xEF, 0xB3, 0xFB, 0xB9, 0xEA, 0xBB, 0xFF\n"); - output_storage ("};\n"); + table_name = colseq_table_name (CB_EBCDIC_IBM, OF_ASCII, 0); + output_storage ("\n/* ASCII to IBM EBCDIC translate table (restricted) */\n"); + output_colseq_table (table_name, cob_ascii_ibmebcdic); + if (gen_ibm_ebcdic > 1) { + output_colseq_table_field (table_name); + } + output_storage ("\n"); +} - if (gen_full_ebcdic > 1) { - i = lookup_attr (COB_TYPE_ALPHANUMERIC, 0, 0, 0, NULL, 0); - output_storage ("static cob_field f_ascii_ebcdic = { 256, (cob_u8_ptr)cob_ascii_ebcdic, &%s%d };\n", - CB_PREFIX_ATTR, i); +static void +output_gcos7_ebcdic_table (void) +{ + const char * table_name; + + if (!gen_gcos7_ebcdic) { + return; } + table_name = colseq_table_name (CB_EBCDIC_GCOS, OF_ASCII, 0); + output_storage ("\n/* ASCII to EBCDIC GCOS7 translate table */\n"); + output_colseq_table (table_name, cob_ascii_gcos7ebcdic); + if (gen_gcos7_ebcdic > 1) { + output_colseq_table_field (table_name); + } output_storage ("\n"); - } static void output_ebcdic_to_ascii_table (void) { - int i; + const char * table_name; if (!gen_ebcdic_ascii) { return; } + table_name = colseq_table_name (CB_EBCDIC_DEFAULT, TO_ASCII, 0); output_storage ("\n/* EBCDIC to ASCII table */\n"); - output_storage ("static const unsigned char\tcob_ebcdic_ascii[256] = {\n"); - output_storage ("\t0x00, 0x01, 0x02, 0x03, 0xEC, 0x09, 0xCA, 0x7F,\n"); - output_storage ("\t0xE2, 0xD2, 0xD3, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,\n"); - output_storage ("\t0x10, 0x11, 0x12, 0x13, 0xEF, 0xC5, 0x08, 0xCB,\n"); - output_storage ("\t0x18, 0x19, 0xDC, 0xD8, 0x1C, 0x1D, 0x1E, 0x1F,\n"); - output_storage ("\t0xB7, 0xB8, 0xB9, 0xBB, 0xC4, 0x0A, 0x17, 0x1B,\n"); - output_storage ("\t0xCC, 0xCD, 0xCF, 0xD0, 0xD1, 0x05, 0x06, 0x07,\n"); - output_storage ("\t0xD9, 0xDA, 0x16, 0xDD, 0xDE, 0xDF, 0xE0, 0x04,\n"); - output_storage ("\t0xE3, 0xE5, 0xE9, 0xEB, 0x14, 0x15, 0x9E, 0x1A,\n"); - output_storage ("\t0x20, 0xC9, 0x83, 0x84, 0x85, 0xA0, 0xF2, 0x86,\n"); - output_storage ("\t0x87, 0xA4, 0xD5, 0x2E, 0x3C, 0x28, 0x2B, 0xB3,\n"); - output_storage ("\t0x26, 0x82, 0x88, 0x89, 0x8A, 0xA1, 0x8C, 0x8B,\n"); - output_storage ("\t0x8D, 0xE1, 0x21, 0x24, 0x2A, 0x29, 0x3B, 0x5E,\n"); - output_storage ("\t0x2D, 0x2F, 0xB2, 0x8E, 0xB4, 0xB5, 0xB6, 0x8F,\n"); - output_storage ("\t0x80, 0xA5, 0x7C, 0x2C, 0x25, 0x5F, 0x3E, 0x3F,\n"); - output_storage ("\t0xBA, 0x90, 0xBC, 0xBD, 0xBE, 0xF3, 0xC0, 0xC1,\n"); - output_storage ("\t0xC2, 0x60, 0x3A, 0x23, 0x40, 0x27, 0x3D, 0x22,\n"); - output_storage ("\t0xC3, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,\n"); - output_storage ("\t0x68, 0x69, 0xAE, 0xAF, 0xC6, 0xC7, 0xC8, 0xF1,\n"); - output_storage ("\t0xF8, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70,\n"); - output_storage ("\t0x71, 0x72, 0xA6, 0xA7, 0x91, 0xCE, 0x92, 0xA9,\n"); - output_storage ("\t0xE6, 0x7E, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,\n"); - output_storage ("\t0x79, 0x7A, 0xAD, 0xA8, 0xD4, 0x5B, 0xD6, 0xD7,\n"); - output_storage ("\t0x9B, 0x9C, 0x9D, 0xFA, 0x9F, 0xB1, 0xB0, 0xAC,\n"); - output_storage ("\t0xAB, 0xFC, 0xAA, 0xFE, 0xE4, 0x5D, 0xBF, 0xE7,\n"); - output_storage ("\t0x7B, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,\n"); - output_storage ("\t0x48, 0x49, 0xE8, 0x93, 0x94, 0x95, 0xA2, 0xED,\n"); - output_storage ("\t0x7D, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50,\n"); - output_storage ("\t0x51, 0x52, 0xEE, 0x96, 0x81, 0x97, 0xA3, 0x98,\n"); - output_storage ("\t0x5C, 0xF0, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,\n"); - output_storage ("\t0x59, 0x5A, 0xFD, 0xF5, 0x99, 0xF7, 0xF6, 0xF9,\n"); - output_storage ("\t0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,\n"); - output_storage ("\t0x38, 0x39, 0xDB, 0xFB, 0x9A, 0xF4, 0xEA, 0xFF\n"); - output_storage ("};\n"); + output_colseq_table (table_name, cob_ebcdic_ascii); if (gen_ebcdic_ascii > 1) { - i = lookup_attr (COB_TYPE_ALPHANUMERIC, 0, 0, 0, NULL, 0); - output_storage ("static cob_field f_ebcdic_ascii = { 256, (cob_u8_ptr)cob_ebcdic_ascii, &%s%d };\n", - CB_PREFIX_ATTR, i); + output_storage ("static cob_field f_ebcdic_ascii = { 256, (cob_u8_ptr)%s, &%s%d };\n", + table_name, CB_PREFIX_ATTR, + lookup_attr (COB_TYPE_ALPHANUMERIC, 0, 0, 0, NULL, 0)); } output_storage ("\n"); @@ -3318,52 +3322,17 @@ output_ebcdic_to_ascii_table (void) static void output_native_table (void) { - int i; - if (!gen_native) { return; } output_storage ("\n/* NATIVE table */\n"); - output_storage ("static const unsigned char\tcob_native[256] = {\n"); - output_storage ("\t0, 1, 2, 3, 4, 5, 6, 7,\n"); - output_storage ("\t8, 9, 10, 11, 12, 13, 14, 15,\n"); - output_storage ("\t16, 17, 18, 19, 20, 21, 22, 23,\n"); - output_storage ("\t24, 25, 26, 27, 28, 29, 30, 31,\n"); - output_storage ("\t32, 33, 34, 35, 36, 37, 38, 39,\n"); - output_storage ("\t40, 41, 42, 43, 44, 45, 46, 47,\n"); - output_storage ("\t48, 49, 50, 51, 52, 53, 54, 55,\n"); - output_storage ("\t56, 57, 58, 59, 60, 61, 62, 63,\n"); - output_storage ("\t64, 65, 66, 67, 68, 69, 70, 71,\n"); - output_storage ("\t72, 73, 74, 75, 76, 77, 78, 79,\n"); - output_storage ("\t80, 81, 82, 83, 84, 85, 86, 87,\n"); - output_storage ("\t88, 89, 90, 91, 92, 93, 94, 95,\n"); - output_storage ("\t96, 97, 98, 99, 100, 101, 102, 103,\n"); - output_storage ("\t104, 105, 106, 107, 108, 109, 110, 111,\n"); - output_storage ("\t112, 113, 114, 115, 116, 117, 118, 119,\n"); - output_storage ("\t120, 121, 122, 123, 124, 125, 126, 127,\n"); - output_storage ("\t128, 129, 130, 131, 132, 133, 134, 135,\n"); - output_storage ("\t136, 137, 138, 139, 140, 141, 142, 143,\n"); - output_storage ("\t144, 145, 146, 147, 148, 149, 150, 151,\n"); - output_storage ("\t152, 153, 154, 155, 156, 157, 158, 159,\n"); - output_storage ("\t160, 161, 162, 163, 164, 165, 166, 167,\n"); - output_storage ("\t168, 169, 170, 171, 172, 173, 174, 175,\n"); - output_storage ("\t176, 177, 178, 179, 180, 181, 182, 183,\n"); - output_storage ("\t184, 185, 186, 187, 188, 189, 190, 191,\n"); - output_storage ("\t192, 193, 194, 195, 196, 197, 198, 199,\n"); - output_storage ("\t200, 201, 202, 203, 204, 205, 206, 207,\n"); - output_storage ("\t208, 209, 210, 211, 212, 213, 214, 215,\n"); - output_storage ("\t216, 217, 218, 219, 220, 221, 222, 223,\n"); - output_storage ("\t224, 225, 226, 227, 228, 229, 230, 231,\n"); - output_storage ("\t232, 233, 234, 235, 236, 237, 238, 239,\n"); - output_storage ("\t240, 241, 242, 243, 244, 245, 246, 247,\n"); - output_storage ("\t248, 249, 250, 251, 252, 253, 254, 255\n"); - output_storage ("};\n"); + output_colseq_table ("cob_native", NULL); if (gen_native > 1) { - i = lookup_attr (COB_TYPE_ALPHANUMERIC, 0, 0, 0, NULL, 0); output_storage ("static cob_field f_native = { 256, (cob_u8_ptr)cob_native, &%s%d };\n", - CB_PREFIX_ATTR, i); + CB_PREFIX_ATTR, + lookup_attr (COB_TYPE_ALPHANUMERIC, 0, 0, 0, NULL, 0)); } output_storage ("\n"); @@ -3373,8 +3342,10 @@ output_native_table (void) static void output_collating_tables (void) { + output_default_ebcdic_table (); output_alt_ebcdic_table (); - output_full_ebcdic_table (); + output_ibm_ebcdic_table (); + output_gcos7_ebcdic_table (); output_ebcdic_to_ascii_table (); output_native_table (); } @@ -4314,13 +4285,7 @@ output_param (cb_tree x, int id) output ("NULL"); } #else - if (cb_flag_alt_ebcdic) { - gen_alt_ebcdic = 1; - output ("cob_a2e"); - } else { - gen_full_ebcdic = 1; - output ("cob_ascii_ebcdic"); - } + output ("%s", colseq_table_name (cb_ebcdic_table, OF_ASCII, 0)); #endif break; case CB_ALPHABET_CUSTOM: @@ -4456,8 +4421,7 @@ output_param (cb_tree x, int id) gen_native = 2; output ("&f_native"); #else - gen_full_ebcdic = 2; - output ("&f_ascii_ebcdic"); + output ("&f_%s", colseq_table_name (cb_ebcdic_table, OF_ASCII, 1)); #endif break; case CB_ALPHABET_CUSTOM: @@ -5210,7 +5174,7 @@ deduce_initialize_type (struct cb_initialize *p, struct cb_field *f, return INITIALIZE_ONE; } - if (p->var + if (p->var && CB_REFERENCE_P (p->var) && CB_REFERENCE (p->var)->offset) { /* Reference modified item */ @@ -5957,7 +5921,7 @@ output_initialize_occurs (struct cb_initialize *p, cb_tree x) f = cb_code_field (x); if (f->flag_occurs - && f->occurs_max > 1 + && f->occurs_max > 1 && f->children == NULL) simple_occurs = 1; else @@ -5980,7 +5944,7 @@ output_initialize_occurs (struct cb_initialize *p, cb_tree x) } } if (idx > 0 - && (!p->flag_init_statement + && (!p->flag_init_statement || (simple_occurs && p->val == cb_true)) && !f->depending && (f->children == NULL || f->values)) { @@ -6206,8 +6170,8 @@ output_initialize (struct cb_initialize *p) return; } /* Check for non-standard OCCURS */ - if ((f->level == 1 || f->level == 77) - && f->flag_occurs + if ((f->level == 1 || f->level == 77) + && f->flag_occurs && !p->flag_init_statement) { cb_tree x; switch (type) { @@ -10100,26 +10064,14 @@ output_file_initialization (struct cb_file *f) const char *alph_write, *alph_read; switch (f->code_set->alphabet_type) { case CB_ALPHABET_ASCII: - if (cb_flag_alt_ebcdic) { - alph_read = "cob_a2e"; - gen_alt_ebcdic = 1; - } else { - alph_read = "cob_ascii_ebcdic"; - gen_full_ebcdic = 1; - } - alph_write = "cob_ebcdic_ascii"; + alph_read = colseq_table_name (cb_ebcdic_table, OF_ASCII, 0); + alph_write = colseq_table_name (cb_ebcdic_table, TO_ASCII, 0); gen_ebcdic_ascii = 1; break; case CB_ALPHABET_EBCDIC: - alph_read = "cob_ebcdic_ascii"; + alph_read = colseq_table_name (cb_ebcdic_table, TO_ASCII, 0); + alph_write = colseq_table_name (cb_ebcdic_table, OF_ASCII, 0); gen_ebcdic_ascii = 1; - if (cb_flag_alt_ebcdic) { - alph_write = "cob_a2e"; - gen_alt_ebcdic = 1; - } else { - alph_write = "cob_ascii_ebcdic"; - gen_full_ebcdic = 1; - } break; /* case CB_ALPHABET_CUSTOM: */ default: @@ -10587,8 +10539,8 @@ output_report_field_cmt (struct cb_field *f) { struct cb_field *s; - if (f->report_source - || f->report_control + if (f->report_source + || f->report_control || (f->report_flag & COB_REPORT_PRESENT)) { output_local("\t\t/* "); if(f->report_source_txt) { @@ -10630,7 +10582,7 @@ output_report_one_field (struct cb_report *r, struct cb_field *f, int idx, int o if (f->report_field_name != NULL) sprintf (field_name,"%s%d",CB_PREFIX_REPORT_FIELD,++report_field_id); - while (idx == 0 + while (idx == 0 || idx <= occ) { if (idx <= 1) { if (f->report_field_name == NULL) { @@ -10698,7 +10650,7 @@ output_report_one_field (struct cb_report *r, struct cb_field *f, int idx, int o } else { value = CB_VALUE (f->values); } - } else if (f->report_source + } else if (f->report_source && CB_LITERAL_P (f->report_source)) { value = f->report_source; } @@ -10871,7 +10823,7 @@ output_report_def_fields (int bgn, int id, struct cb_field *f, struct cb_report int k, max, pos = 1; for (k = 0; k < idx; k++) { p = pftbl [k]; - if ( p + if ( p && (p->report_flag & COB_REPORT_LINE)) { break; } @@ -14269,9 +14221,11 @@ codegen_init (struct cb_program *prog, const char *translate_name) buff[pos] = 0; output_name = cobc_check_string (buff); } + gen_default_ebcdic = 0; gen_alt_ebcdic = 0; + gen_ibm_ebcdic = 0; + gen_gcos7_ebcdic = 0; gen_ebcdic_ascii = 0; - gen_full_ebcdic = 0; gen_native = 0; gen_figurative = 0; non_nested_count = 0; @@ -14445,7 +14399,8 @@ codegen_internal (struct cb_program *prog, const int subsequent_call) output_newline (); } - if (gen_native || gen_full_ebcdic + if (((gen_native | gen_default_ebcdic | gen_alt_ebcdic | + gen_ibm_ebcdic | gen_gcos7_ebcdic) > 1) || gen_ebcdic_ascii || prog->alphabet_name_list) { (void)lookup_attr (COB_TYPE_ALPHANUMERIC, 0, 0, 0, NULL, 0); } diff --git a/cobc/flag.def b/cobc/flag.def index 218e3c847..700da86a7 100644 --- a/cobc/flag.def +++ b/cobc/flag.def @@ -89,9 +89,16 @@ CB_FLAG_NQ (0, "ec", 14, CB_FLAG_NQ (0, "no-ec", 15, _(" -fno-ec=\tdisable code generation for ")) +CB_FLAG_NQ (1, "ebcdic-table", 16, /* cf cconv.h for all available tables */ + _(" -febcdic-table=[DEFAULT|RESTRICTED-GC|IBM|GCOS]\tdefine EBCDIC translation table:\n" + " * default: translation to extended ASCII as per MF\n" + " * restricted-gc: translation from restricted ASCII only\n" + " * ibm: translation to restricted ASCII as per IBM" + " * gcos: translation to extended ASCII as per GCOS7")) + /* Binary flags */ -CB_FLAG (cb_flag_sql_xfd, 1, "sql", +CB_FLAG (cb_flag_sql_xfd, 1, "sql", _(" -fsql process the XFD directives")) /* Flags with suppressed help */ @@ -103,9 +110,6 @@ CB_FLAG (cb_flag_winmain, 0, "winmain", CB_FLAG (cb_flag_computed_goto, 0, "computed-goto", _(" -fcomputed-goto generate computed goto C statements")) -CB_FLAG (cb_flag_alt_ebcdic, 0, "alternate-ebcdic", - _(" -falternate-ebcdic use restricted ASCII to EBCDIC translate")) - CB_FLAG (cb_flag_extra_brace, 0, "extra-brace", _(" -fextra-brace generate extra braces in C source")) diff --git a/tests/testsuite.src/configuration.at b/tests/testsuite.src/configuration.at index 051209aa7..e566972d8 100644 --- a/tests/testsuite.src/configuration.at +++ b/tests/testsuite.src/configuration.at @@ -887,3 +887,24 @@ wide.cob:9: warning: optional period used AT_CHECK([$COMPILE_ONLY -ftext-column=80 wide.cob], [0], [], []) AT_CLEANUP + + +AT_SETUP([cobc configuration: ebcdic-table]) +AT_KEYWORDS([configuration misc ebcdic]) + +AT_DATA([prog.cob], [ + IDENTIFICATION DIVISION. + PROGRAM-ID. prog. + PROCEDURE DIVISION. + STOP RUN. +]) + +AT_CHECK([$COBC -febcdic-table=default prog.cob], [0], [], []) +AT_CHECK([$COBC -febcdic-table=restricted-gc prog.cob], [0], [], []) +AT_CHECK([$COBC -febcdic-table=ibm prog.cob], [0], [], []) +AT_CHECK([$COBC -febcdic-table=gcos prog.cob], [0], [], []) +AT_CHECK([$COBC -febcdic-table=unknown prog.cob], [1], [], +[cobc: error: invalid parameter: -febcdic-table +]) + +AT_CLEANUP diff --git a/tests/testsuite.src/run_misc.at b/tests/testsuite.src/run_misc.at index ba6864cc2..f204b7528 100644 --- a/tests/testsuite.src/run_misc.at +++ b/tests/testsuite.src/run_misc.at @@ -1736,7 +1736,7 @@ AT_DATA([prog.cob], [ DATA DIVISION. WORKING-STORAGE SECTION. - 01 TESTHEX PIC X(10) VALUE X'C17BD6F2F0F1F8404040'. + 01 TESTHEX PIC X(10) VALUE X'C17BD6F2F0F1F8406A5A'. procedure division. sample-main. @@ -1750,7 +1750,21 @@ AT_DATA([prog.cob], [ AT_CHECK([$COMPILE prog.cob], [0], [], []) AT_CHECK([$COBCRUN_DIRECT ./prog], [0], -[Converted: "A#O2018 "], []) +[Converted: "A#O2018 |!"], []) + +# For characters above IBM (with irregularities) and GCOS should match: +AT_CHECK([$COMPILE prog.cob -febcdic-table=ibm -o prog-ibm], [0], [], []) +AT_CHECK([$COBCRUN_DIRECT ./prog-ibm], [0], +[Converted: "A#O2018 |@:>@"], []) # prefix is actually "|]" (escaped for m4 preproc) + +AT_CHECK([$COMPILE prog.cob -febcdic-table=gcos -o prog-gcos], [0], [], []) +AT_CHECK([$COBCRUN_DIRECT ./prog-gcos], [0], +[Converted: "A#O2018 |@:>@"], []) # prefix is actually "|]" (escaped for m4 preproc) + +# FIXME: This really does not convert to anything close to ASCII; +# what's this table supposed to encode? +# AT_CHECK([$COMPILE prog.cob -febcdic-table=restricted-gc -o prog-rgc], [0], [], []) +# AT_CHECK([$COBCRUN_DIRECT ./prog-rgc], [0], []) AT_CLEANUP