Commit Graph

3 Commits

Author SHA1 Message Date
James K. Lowden
d8e3ddc319 cobol: Correct libgcobol install directory and add components.
Set libgcobol/Makefile.am to define libdir and libsubdir the way libada does.
Reorganize libgcobol/compat directory to group by emulation, not component.
Move orphan gcc/udf/stored-char-length.cbl to the compat directory.
Introduce new POSIX bindings.

gcc/cobol/ChangeLog:
	PR cobol/122702
	* Make-lang.in: Move stored-char-length.cbl to libgcobol.

libgcobol/ChangeLog:
	PR cobol/122702
	* Makefile.am: Set libdir and libsubdir per libada example.
	* Makefile.in: Regenerate.
	* compat/README.md: Revise per new directory structure.
	* compat/gnu/lib/CBL_ALLOC_MEM.cbl: Moved from compat/lib/gnu.
	* compat/gnu/lib/CBL_CHECK_FILE_EXIST.cbl: Moved from compat/lib/gnu.
	* compat/gnu/lib/CBL_DELETE_FILE.cbl: Moved from compat/lib/gnu.
	* compat/gnu/lib/CBL_FREE_MEM.cbl: Moved from compat/lib/gnu.
	* compat/gnu/udf/stored-char-length.cbl: New file.
	* compat/lib/gnu/CBL_ALLOC_MEM.cbl: Moved to compat/gnu/lib.
	* compat/lib/gnu/CBL_CHECK_FILE_EXIST.cbl: Moved to compat/gnu/lib.
	* compat/lib/gnu/CBL_DELETE_FILE.cbl: Moved to compat/gnu/lib.
	* compat/lib/gnu/CBL_FREE_MEM.cbl: Moved to compat/gnu/lib.
	* posix/cpy/psx-open.cpy: New file.
	* posix/shim/open.cc: New file.
	* posix/shim/stat.h: Add mode & flag bits for open.cc
	* posix/udf/posix-lseek.cbl: New file.
	* posix/udf/posix-open.cbl: New file.
	* posix/udf/posix-read.cbl: New file.
	* posix/udf/posix-write.cbl: New file.
	* xmlparse.cc: Quell context_t initialization-order warning.
2025-11-17 18:25:50 -05:00
James K. Lowden
08e9df2546 cobol: Introduce vendor-compatibility layer as user-defined functions.
Install COBOL UDFs in a target directory that includes the GCC version
in its path, to permit side-by-side installation. Support compat
library with COBOL POSIX bindings; support those binding with C
functions in libgcobol as needed.

Changes to the compiler to support POSIX binding and testing.

Include developer conveniences -- Makefiles, bin/ and t/ directories --
to ensure UDFs compile and return reasonable results.  These are
not installed and do not affect how libgcobol is built.

gcc/cobol/ChangeLog:

	* cdf.y: Install literals in symbol table.
	* genapi.cc (parser_alphabet): Use std::string for currency.
	(initialize_the_data): Rely on constructor.
	(parser_file_add): Better #pragma message.
	(parser_exception_file): Return early if not generating code.
	* parse.y: Allow library programs to act as functions.
	* parse_ante.h (dialect_proscribed): Standardize message.
	(intrinsic_call_2): Correct s/fund/func/ misspelling.
	* scan.l: Comment.
	* symbols.cc (symbols_update): Add unreachable assertion.
	(symbol_field_parent_set): Reduce error to debug message.
	(cdf_literalize): Declare.
	(symbol_table_init): Insert CDF constants as literals.
	* symbols.h (cbl_dialect_str): Provide string values for enum.
	(is_working_storage): Remove function.
	(struct cbl_field_data_t): Add manhandle_initial for Numeric Edited.
	(struct cbl_field_t): Initialize name to zeros.
	(struct cbl_section_t): Delete unused attr() function.
	(symbol_unique_index): Declare.
	* token_names.h: Regenerate.
	* util.cc (cdf_literalize): Construct a cbl_field_t from a CDF literal.
	(symbol_unique_index): Supply "globally" unique number for a program.

libgcobol/ChangeLog:

	* Makefile.am: Move UDF-support to posix/shim, add install targets
	* Makefile.in: Regenerate
	* charmaps.cc (__gg__currency_signs): Use std::string.
	* charmaps.h: Include string and vector headers.
	(class charmap_t): Use std::string and vector for currency.
	* config.h.in: Regenerate.
	* configure: Regenerate.
	* configure.ac: Check for libxml2.
	* intrinsic.cc (numval_c): Constify.
	* libgcobol.cc (struct program_state): Use std::string and vector.
	(__gg__inspect_format_2): Add debug messages.
	* libgcobol.h (__gg__get_default_currency_string): Constify.
	* valconv.cc (expand_picture): Use std::string and vector.
	(__gg__string_to_numeric_edited): Use std::string and vector.
	(__gg__currency_sign_init): Use std::string and vector.
	(__gg__currency_sign): Use std::string and vector.
	* xmlparse.cc (xml_push_parse): Reformat.
	* posix/stat.cc: Removed.
	* posix/stat.h: Removed.
	* .gitignore: New file.
	* compat/README.md: New file.
	* compat/lib/gnu/CBL_ALLOC_MEM.cbl: New file.
	* compat/lib/gnu/CBL_CHECK_FILE_EXIST.cbl: New file.
	* compat/lib/gnu/CBL_DELETE_FILE.cbl: New file.
	* compat/lib/gnu/CBL_FREE_MEM.cbl: New file.
	* compat/t/Makefile: New file.
	* compat/t/smoke.cbl: New file.
	* posix/README.md: New file.
	* posix/bin/Makefile: New file for UDF-developer.
	* posix/bin/headers: New file.
	* posix/bin/scrape.awk: New file.
	* posix/bin/sizeofs.c: New file.
	* posix/bin/udf-gen: New file.
	* posix/cpy/posix-errno.cbl: New file.
	* posix/cpy/statbuf.cpy: New file.
	* posix/cpy/tm.cpy: New file.
	* posix/errno.cc: Removed.
	* posix/localtime.cc: Removed.
	* posix/shim/stat.cc: New file.
	* posix/shim/stat.h: New file.
	* posix/t/Makefile: New file.
	* posix/t/errno.cbl: New file.
	* posix/t/exit.cbl: New file.
	* posix/t/localtime.cbl: New file.
	* posix/t/stat.cbl: New file.
	* posix/tm.h: Removed.
	* posix/udf/posix-exit.cbl: New file.
	* posix/udf/posix-localtime.cbl: New file.
	* posix/udf/posix-mkdir.cbl: New file.
	* posix/udf/posix-stat.cbl: New file.
	* posix/udf/posix-unlink.cbl: New file.
2025-11-12 19:49:39 -05:00
Robert Dubner
b20c6458fa cobol: Implement the XML PARSE statement.
These changes implement the XML PARSE statement as described in the IBM
specification.

A repair to exception handling is included.  Up until now, an exception
after a successful file operation wasn't handled properly.

A repair to value declarations for BINARY / COMP / COMP-4 / COMP-5
values now allows them to have digits to the right of the implied
decimal point.  Processing of the "S" PICTURE character has been
normalized as well.

Co-Authored-By: James K. Lowden <jklowden@cobolworx.com>
Co-Authored-By: Robert Dubner <rdubner@symas.com>

gcc/cobol/ChangeLog:

	* Make-lang.in: Incorporate new token_names.h file.
	* cdf.y: Modify tokens.
	* gcobol.1: Document XML PARSE statement
	* genapi.cc (parser_enter_program): Verify that every goto has a
	matching label.
	(parser_end_program): Likewise.
	(parser_alphabet): Refine handling codeset encodings.
	(parser_alphabet_use): Likewise.
	(label_fetch): Moved from later in the source code.
	(parser_xml_parse): New routine for XML PARSE.
	(parser_xml_on_exception): Likewise.
	(parser_xml_not_exception): Likewise.
	(parser_xml_end): Likewise.
	(parser_label_label): Verify goto/label matching.
	(parser_label_goto): Likewise.
	(parser_entry): Minor change to SHOW_PARSE report.
	* genapi.h (parser_alphabet): Set parameter to const.
	(parser_xml_parse): Declare new function.
	(parser_xml_on_exception): Likewise.
	(parser_xml_not_exception): Likewise.
	(parser_xml_end): Likewise.
	(parser_label_addr): Likewise.
	* parse.y: label_pair_t structure; locale processing; new token
	processing for alphabets and XML PARSE.
	* parse_ante.h (name_of): Return field->name when initial is NULL.
	(new_tempnumeric): Make signable_e optional.
	(ast_save_locale): New function.
	(data_division_ready): Warning for "no alphabet".
	* scan.l: Repair interpretation of BINARY, COMP, COMP-4, and
	COMP-5.
	* scan_ante.h (struct bint_t): Likewise.
	* scan_post.h (current_tokens_t::tokenset_t::tokenset_t):
	Include token_names.h.
	* symbols.cc (symbols_alphabet_set): Revert to prior alphabet
	determination.
	(symbol_table_init): New XML special registers.
	(new_temporary): Make signable_e controllable, not fixed.
	* symbols.h (__gg__encoding_iconv_valid): New declaration.
	(enum cbl_label_type_t): New LblXml label type.
	(struct cbl_xml_parse_t):
	(struct cbl_label_t): Implement XML PARSE.
	(new_temporary): Incorporate boolean for signable_e.
	(symbol_elem_of): Change label field type handling.
	(cbl_section_of): Likewise.
	(cbl_field_of): Likewise.
	(cbl_label_of): Likewise.
	(cbl_special_name_of):  Likewise.
	(cbl_alphabet_of):  Likewise.
	(cbl_file_of):  Likewise.
	* token_names.h: New file.
	* util.cc (gcc_location_set_impl): Improve location_t calculations
	when entering and leaving COPYBOOKs.

libgcobol/ChangeLog:

	* Makefile.am: Changes for XML PARSE and POSIX functions.
	* Makefile.in: Likewise.
	* charmaps.cc: Augment encodings[] table with "supported" boolean.
	(__gg__encoding_iconv_name): Modify how encodings are identified.
	(encoding_descr): Likewise.
	(__gg__encoding_iconv_valid): Likewise.
	* common-defs.h (callback_t): Define function pointer.
	* constants.cc: Use named cbl_attr_e constants instead of magic
	numbers.; New definitions for XML special registers.
	* encodings.h (struct encodings_t): Declare "supported" boolean.
	* libgcobol.cc (format_for_display_internal): Use std::ptrdiff_t.
	(__gg__alphabet_use): Add case for iconv_CP1252_e.
	(default_exception_handler): Repair exception handling after a
	successful file operation.
	* posix/errno.cc: New file.
	* posix/localtime.cc: New file.
	* posix/stat.cc: New file.
	* posix/stat.h: New file.
	* posix/tm.h: New file.
	* xmlparse.cc: New file to support XML PARSE statement.

gcc/testsuite/ChangeLog:

	* cobol.dg/typo-1.cob: New test for squiggles and carets.
2025-10-23 11:28:53 -04:00