Repository navigation
#3831: CobolRecords reads only ASCII digits, and gains NUMVAL - #3854
Merged
Merged
Conversation
Java's parsers take any Unicode decimal digit: new BigInteger("١٢"),
new BigDecimal("12") and Integer.parseInt("१२") all give 12, where COBOL's
NUMERIC test and NUMVAL reject them. CobolRecords.zoned() checked its digits
with Character::isDigit and decimal() handed text straight to BigDecimal.
- zoned() and every text parse now check 0-9 themselves; a multi-byte
character in a zoned field is invalid data (it used to throw an index error).
- numval(text, decimalPoint): COBOL's FUNCTION NUMVAL -- spaces, one leading
or trailing sign (+ - CR DB), at most one decimal point, which is ',' in a
DECIMAL-POINT IS COMMA program. decimal(value, decimalPoint) reads text
through it; decimal(value) keeps '.'.
- The port tickets tell a port to read numeric text only through numval.
Closes #3831
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018whc9Ptg89vdP8tCsHGVhP
…s-globe-hs3tmf-3831
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #3831
What changed
All changes are in the generated
CobolRecordsruntime (cobol_to_java_repository_forge.COBOL_RECORDS_JAVA) and one port-ticket rule.zoned()checked its digits withCharacter::isDigit, anddecimal()passed text straight tonew BigDecimal(String). Both accept Arabic-Indic, Devanagari and full-width digits.isAsciiDigits(0–9), and anything else throwsNumberFormatException. That is the runtime's existing invalid-data path ("an error, not a zero").zoned()also rejects a field whose text decodes to fewer characters than its bytes (a multi-byte character). That case used to throwStringIndexOutOfBoundsException.numval(String text, char decimalPoint): COBOL'sFUNCTION NUMVAL.+/-) or trailing (+/-/CR/DB) sign with optional spaces, and ASCII digits with at most one decimal point.decimalPointis,in aDECIMAL-POINT IS COMMAprogram, sonumval("1,5", ',')is 1.5 andnumval("1.5", ',')is invalid.numval(text)defaults to..decimal(value, decimalPoint)reads text throughnumval;decimal(value)keeps..CobolRecords.numval(text, decimalPoint), neverInteger.parseInt/new BigDecimal(String).The generated Java source stays pure ASCII: the digit scripts are named in the Javadoc, not written out.
Not wired here:
culture.decimal_point(from #3819, which just merged) marks its generated-code wiring asTODO(#3827).numval(text, decimalPoint)is the runtime helper that wiring will call;java_target.pyis untouched.Verification
tests/cobol_mainframe/test_cobol_records_digits.pycompiles the generatedCobolRecordswith the local JDK (21) and runs 24 probes: Arabic-Indic / full-width / Devanagari digits throughnumval,decimalandzonedall take the invalid-data path; valid signs, CR/DB and decimal-comma cases are covered. The test is skipped without a JDK.tests/tools/crucible_check.py: PASS in both modes, no golden-master change.tests/ruff_audit.py --ci/tests/mypy_audit.py --ci: no new findings.tests/tools/unicode_gauntlet.py --corpus keyword-rosetta --ci: exit 0 (581/934, merged with current main).No mainframe-estate defect to log in
field_testing.json: the audit and synthetic probes found this, not a pinned or private estate, and that log requires an estate.🤖 Generated with Claude Code
https://claude.ai/code/session_018whc9Ptg89vdP8tCsHGVhP
Generated by Claude Code