TUESDAY, SEPTEMBER 29, 2026
cobol
Cobol: Add OPTIONAL argument to posix-errno function
The Cobol posix-errno function now accepts an optional argument to set the errno value.
The posix-errno function in libgcobol has been extended to include an optional argument. This allows applications to explicitly set the errno value. If a new value is provided, errno is updated, and the previous value is returned, offering more control over error handling.
In Details
This commit adds an OPTIONAL argument to posix_errno in libgcobol. Previously, it only provided access to the current errno value. The new functionality allows explicit setting of errno if the optional argument is not omitted, returning the old value. This enhances error management capabilities within Cobol programs.
For Context
- errno
- A standard C macro that holds the error number of the last executed library function. It's a global integer variable used to indicate specific error conditions.
- libgcobol
- The runtime library for the GNU COBOL compiler, providing essential functions and services for COBOL programs.
- OPTIONAL argument
- In COBOL, an optional parameter in a procedure or function that does not need to be supplied when the procedure is called. If not supplied, a default or null value is used.