Implement 15 missing intrinsic functions to complete COBOL function support #706
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements 15 previously missing intrinsic functions in opensource COBOL 4J, significantly expanding the runtime library's COBOL compatibility. The implementation adds support for validation functions, data conversion functions, and comparison utilities that are essential for complete COBOL standard compliance.
Functions Implemented
Validation Functions
TEST-NUMVAL
- Tests whether a string contains valid numeric dataTEST-NUMVAL-C
- Tests numeric validity with currency symbol supportTEST-NUMVAL-F
- Tests floating-point numeric format validityTEST-DATE-YYYYMMDD
- Validates date format (was already implemented)TEST-DAY-YYYYDDD
- Validates day format (was already implemented)Data Conversion Functions
NUMVAL-F
- Converts floating-point format strings to numeric valuesBOOLEAN-OF-INTEGER
- Converts integer values to boolean representationINTEGER-OF-BOOLEAN
- Converts boolean fields to integer valuesCHAR-NATIONAL
- Returns national characters for ordinal positionsDISPLAY-OF
- Converts national/Unicode data to display formatNATIONAL-OF
- Converts display data to national character formatComparison Functions
LOCALE-COMPARE
- Performs locale-aware string comparisonSTANDARD-COMPARE
- Performs standard ASCII-based string comparisonField Limit Functions
HIGHEST-ALGEBRAIC
- Returns the maximum representable value for a field typeLOWEST-ALGEBRAIC
- Returns the minimum representable value for a field typeException Handling Functions
EXCEPTION-FILE-N
- Returns exception file information in national formatEXCEPTION-LOCATION-N
- Returns exception location in national formatTechnical Details
All implementations follow the established patterns in the codebase:
CobolFieldAttribute
makeFieldEntry()
andcurrField
The function table in
cobj/reserved.c
has been updated to mark these functions as implemented with their corresponding Java method names.Testing
The code compiles successfully and integrates with the existing runtime without breaking changes. All new functions handle error conditions gracefully and return appropriate default values when invalid input is encountered.
Note: The constants
PI
andE
are handled as compile-time constants by the compiler rather than runtime functions, so they remain marked withNULL
routines as intended.Fixes #634.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.