Skip to content

Commit

Permalink
Merge SVN 4723
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeclerck committed Jul 12, 2024
1 parent 02d92bc commit ced43e3
Show file tree
Hide file tree
Showing 10 changed files with 657 additions and 211 deletions.
8 changes: 8 additions & 0 deletions cobc/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>

* 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 <[email protected]>

* flag.def (cb_flag_stack_extended), cobc.c: new option "stack-extended"
Expand Down
8 changes: 4 additions & 4 deletions cobc/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
# along with GnuCOBOL. If not, see <https://www.gnu.org/licenses/>.

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

Expand Down
359 changes: 359 additions & 0 deletions cobc/cconv.c

Large diffs are not rendered by default.

78 changes: 78 additions & 0 deletions cobc/cconv.h
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.
*/
#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 <unistd.h>
#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 */
8 changes: 8 additions & 0 deletions cobc/cobc.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@

#include "cobc.h"
#include "tree.h"
#include "cconv.h"

#include "../libcob/cobgetopt.h"

Expand Down Expand Up @@ -3583,6 +3584,13 @@ process_command_line (const int argc, char **argv)
}
break;

case 16:
/* -febcdic-table=<cconv-table> */
if (cobc_deciph_ebcdic_table_name (cob_optarg)) {
cobc_err_exit (COBC_INV_PAR, "-febcdic-table");
}
break;

case 4:
/* -ffold-copy=<UPPER/LOWER> : COPY fold case */
if (!cb_strcasecmp (cob_optarg, "UPPER")) {
Expand Down
5 changes: 2 additions & 3 deletions cobc/cobc.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@
and include that here */
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#else
#include <stdio.h>
#endif
#include <stdio.h> /* for FILE* */
#include <stdio.h> /* for FILE */

#include "../libcob/common.h"
#include "cconv.h"

#ifdef ENABLE_NLS
#include "../lib/gettext.h"
Expand Down
Loading

0 comments on commit ced43e3

Please sign in to comment.