Skip to content

#3831: CobolRecords reads only ASCII digits, and gains NUMVAL - #3854

Merged
squid-protocol merged 2 commits into
mainfrom
claude/gitgalaxy-tours-globe-hs3tmf-3831
Sep 27, 2026
Merged

squid-protocol merged 2 commits into
mainfrom
claude/gitgalaxy-tours-globe-hs3tmf-3831

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Closes #3831

What changed

All changes are in the generated CobolRecords runtime (cobol_to_java_repository_forge.COBOL_RECORDS_JAVA) and one port-ticket rule.

  • ASCII digits only.
    • zoned() checked its digits with Character::isDigit, and decimal() passed text straight to new BigDecimal(String). Both accept Arabic-Indic, Devanagari and full-width digits.
    • Every text parse now goes through isAsciiDigits (0–9), and anything else throws NumberFormatException. 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 throw StringIndexOutOfBoundsException.
  • numval(String text, char decimalPoint): COBOL's FUNCTION NUMVAL.
    • Accepts leading/trailing spaces, one leading (+/-) or trailing (+/-/CR/DB) sign with optional spaces, and ASCII digits with at most one decimal point.
    • decimalPoint is , in a DECIMAL-POINT IS COMMA program, so numval("1,5", ',') is 1.5 and numval("1.5", ',') is invalid.
    • numval(text) defaults to .. decimal(value, decimalPoint) reads text through numval; decimal(value) keeps ..
  • Port tickets: a new rule says to read numeric text (screen fields, NUMVAL, PARMs) only through CobolRecords.numval(text, decimalPoint), never Integer.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 as TODO(#3827). numval(text, decimalPoint) is the runtime helper that wiring will call; java_target.py is untouched.

Verification

  • New tests/cobol_mainframe/test_cobol_records_digits.py compiles the generated CobolRecords with the local JDK (21) and runs 24 probes: Arabic-Indic / full-width / Devanagari digits through numval, decimal and zoned all take the invalid-data path; valid signs, CR/DB and decimal-comma cases are covered. The test is skipped without a JDK.
  • Full suite: 12160 passed, 34 skipped, 9 xfailed, 3 xpassed.
  • 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

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
@squid-protocol squid-protocol added this to the GitGalaxy Tours the Globe milestone Sep 27, 2026 — with Claude
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit 54c5719 into main Sep 27, 2026
37 checks passed
@squid-protocol
squid-protocol deleted the claude/gitgalaxy-tours-globe-hs3tmf-3831 branch September 27, 2026 01:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Java runtime accepts non-ASCII digits as numbers (Arabic-Indic, Devanagari, full-width) where COBOL NUMERIC/NUMVAL would not

2 participants