Repository navigation
Fix #3991: COBOL words keep full-width digits and hyphens (- U+FF0D / − U+2212) - #3995
Merged
Merged
Conversation
… − U+2212) #3967 let a COBOL word hold any Unicode letter, but a Japanese word also holds full-width digits (0-9) and the full-width hyphen, which SJIS 0x817C decodes to U+FF0D under cp932 and U+2212 under Python's shift_jis. Data names were cut at those characters (項目2 -> 項目, TEST−DATA1 -> TEST) and sections holding them (S−初期化, s123) were missing from function_data. - identifiers.py: WIDE_DIGITS / WIDE_HYPHENS. - cobol.py, mainframe_boundary.py (COBOL readers), file_control.py (COBOL FD / SELECT / COPY): every COBOL word class that takes 0-9 takes WIDE_DIGITS, and every one that takes the in-word '-' takes WIDE_HYPHENS, at the same positions. JCL / IDCAMS / CSD / HLASM / BMS classes are unchanged. Quantifiers unchanged. - detector._extract_name: for COBOL the full-width hyphens are name characters, so `S−初期化` is not reduced to its tail `初期化`. - tests: data names, sections, callees, both decodings of 0x817C from a cp932-encoded file, spaced minus stays arithmetic, and a structural check that every cobol.py word class carries the wide characters. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EC8FWfn3aPmsUPnRgKNVup
Contributor
This was referenced Sep 29, 2026
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.
Fixes #3991 (follow-up to #3955 / #3967).
Problem
#3967 made the COBOL name classes accept Unicode letters, but Japanese COBOL words also contain full-width digits
0-9(U+FF10-FF19) and the full-width hyphen. Shift-JIS byte pair 0x817C decodes to-U+FF0D under cp932 and to−U+2212 under Python'sshift_jis. Data names were cut at those characters (項目2->項目,TEST−DATA1andTEST−RECORD1both ->TEST). Sections containing them (S−初期化,S-終了,s123) were missing from function_data.Fix
identifiers.py: newWIDE_DIGITS(U+FF10-FF19) andWIDE_HYPHENS(U+FF0D, U+2212). They are built withchr()so the source has no look-alike glyphs (ruff RUF001).languages/cobol.py,core/mainframe_boundary.py(the COBOL readers),core/file_control.py(COBOL FD/SELECT/COPY): every COBOL word class that accepts0-9now also acceptsWIDE_DIGITS. Every class that accepts the in-word-now also acceptsWIDE_HYPHENS, in the same positions. A wide hyphen follows the same placement rules as-, and both(?<![...-])word-boundary guards now include the wide forms. JCL, IDCAMS, CSD, HLASM and BMS classes are unchanged. No quantifier changed: the classes are wider, but the bounds are the same, so ReDoS safety is unchanged.detector._extract_name: for COBOL, the full-width hyphens are name characters. Before, the regex capturedS−初期化correctly, but name normalisation split it and kept only初期化.A − B, which COBOL arithmetic requires) is still two words. Literals are untouched.Tests (
tests/core_engine/test_national_names.py)TEST−DATA1/TEST−RECORD1no longer collide (REDEFINES target included).read_sourceasshift_jis(U+2212) and ascp932(U+FF0D), and both give whole names.0-9/-also takesWIDE_DIGITS/WIDE_HYPHENS. The existing NATIONAL-splice test now allows the wide constants afterNATIONAL.Verification
項目2, O−文字列, WK-03, 横浜-1and主処理, ASCII-SEC, S−初期化, s123, S-終了.crucible_check.py: full_precision PASS, zero_dependency PASS. The golden masters do not change, so there is no re-bless. The crucible has no full-width COBOL words.ground_truth_ledger.py check: ledger clean (0 open defects).--ci: no new findings. The changed files passruff format.opensourcecobol4j fresh estate (#3806), independent Unicode-aware reading vs the master DB
The one remaining "missing" entry per suite comes from the analyzer, not the engine. In
003-long-field-name/prog.cob, the data name項目ABCDEFGH01234…sits alone on its own line as the operand ofMOVE "Unicode" TO(and ofDISPLAY). The analyzer's paragraph regex reads it as a paragraph header. It is a data item, and it is now recorded whole in record_data. The refract → cobol-to-java →mvn compileresults are unchanged from the baseline scan: cobol_utf8, i18n_sjis and i18n_utf8 compile. jp-compat still fails with the same 20 pre-existingcannot find symbol: class TestFileDTOerrors as the baseline scan. Those errors are unrelated to this change.🤖 Generated with Claude Code
https://claude.ai/code/session_01EC8FWfn3aPmsUPnRgKNVup