Skip to content

COBOL unit reader (cobol_graveyard_finder): non-ASCII paragraph/section names and names starting END- are not units #4026

Closed

Description

@squid-protocol

Found by the COBOL coverage tool (#4023) on the opensourcecobol4j fresh estate (#3806). A traced GnuCOBOL run enters paragraphs and sections that cobol_graveyard_finder's unit reader does not see. The reader is used by the refractor's dead-paragraph masking, cobol_dag_architect, cobol_microservice_slicer and the answer-key tooling, so those units are also missing from procedure_units / reachable_units: they are neither counted nor judged dead or alive.

1. Non-ASCII unit names are not units

_NAME = r"[A-Z0-9][A-Z0-9\-]*" is ASCII only, so a Japanese or full-width paragraph/section header is not a header:

>>> unit_header('       S-INIT SECTION.')
'S-INIT'
>>> unit_header('       S−初期化       SECTION.')
None

The same _NAME sits in _PERFORM, _GO_TO, _ALTER and _CICS_LABEL, so a PERFORM S−初期化 is not followed either.

On the estate: 7 of 127 programs in cobol_utf8 and 6 of 112 in i18n_sjis declare non-ASCII units. Examples: 005-section-name (S−初期化, S−終了), 008-section-and-paragraph-name (P-初期化), 115-japanese-word-section-variable (東京ラベル, 神奈川−1ラベル, ...). No pinned mainframe corpus is affected, so the ledger should not move. Note U+3000 (the full-width space, #3956) must stay a separator, not a name character.

2. A paragraph whose name starts with END- is not a unit

_NOT_A_PARAGRAPH = END-[A-Z0-9\-]+|... rejects any END-... name as a scope terminator, but END-IPROC1. in Area A is a legal paragraph name. jp-compat 033-sort-status-break-with-no-sort-status-in-pgm:

       IPROC1               SECTION.
       BEGIN-IPROC1.
          READ INPUT-FILE1 AT END GO TO END-IPROC1.
       ...
       END-IPROC1.

unit_header(' END-IPROC1.') returns None. Only the reserved scope terminators (END-IF, END-PERFORM, ...) should be excluded.

Done when

Both shapes read as units (tests in the finder's suite). The coverage tool's unread list (tests/tools/cobol_coverage.py autotest) is empty on those cases. Logged in tests/cobol_mainframe/field_testing.json (#4023's PR).

🤖 Generated with Claude Code

Activity

  1. added
    bug
    legacy-modernization
    on Sep 29, 2026
  2. added 3 commits that reference this issue on Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buglegacy-modernization

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions