It seems every COBOL compiler includes a library of functions intended to make the COBOL programer's life easier. All of them, as we demonstrate here, can be written in COBOL. They are supplied in COBOL form, not as a library. The user is free to compile them into a utility library.
Some of the functions defined here require runtime support from libgcobol.
At the time of this writing, the functions of greatest concern are those that are defined by Rocket Software (formerly MicroFocus) and emulated by GnuCOBOL. Those are implemented in libgcobol/compat/gnu/lib. Any calls they would otherwise make to the C library are effected through COBOL POSIX bindings supplied by libgcobol/posix/udf/posix-close.cbl.
As an aid to the developer, a simple example of how these functions are used is found in libgcobol/compat/t/smoke.cbl. It may by compiled using libgcobol/compat/t/Makefile.
If posix-FUNC.cbl calls a shim function, it must COPY psx-FUNC to get the required definitions. We ensure the names and values defined in the copybook match those used by the shim.
Of the MF functions, those needed immediately are
Done, not tested:
Not written:
We want to write DejaGnu tests that will be activated by
$ make -C gcc check-cobol
The library has been renamed from libcompat to libgcobol_compat_gnu. It is now automatically injected by the gcobol and gcobc front-ends based on the path to the installation prefix.
Tests have been implemented for the following functions:
CBL_ALLOC_MEMCBL_FREE_MEMCBL_CHECK_FILE_EXISTCBL_CREATE_FILECBL_DELETE_FILECBL_OPEN_FILECBL_CLOSE_FILECBL_WRITE_FILECBL_READ_FILEcbltypes.cpy and cblproto.cpy can be now COPYed by programs. As of today, cbltypes.cpy only defines the cblt-fileexist-buf data type. On the other hand, cblproto.cpy provides function prototypes for all of the MF functions currently supported by the library.