Skip to content

unportable-code: nested COPY REPLACING #412

@GitMensch

Description

@GitMensch

DD-ENTITY is included with REPLACING as follows (one of the examples):

01 LK-ENTITY.
COPY DD-ENTITY REPLACING LEADING ==ENTITY== BY ==LK-ENTITY==.

but has itself another REPLACING:

COPY DD-INVENTORY-SLOT REPLACING LEADING ==PREFIX== BY ==ENTITY-ITEM==.

Old standards actually said that there is no COPY allowed at all as soon as REPLACING and GnuCOBOL does support it, but it is one of the show-stoppers to compile CobolCraft with other compilers.

For reference here the current WIP for that rule in 2026 standard:

If the REPLACING phrase is specified, the library text shall not contain a COPY statement with the REPLACING phrase [...]. It can contain a COPY statement (and nested COPY statements) without the REPLACING phrase. The REPLACING phrase applies to all library text that is included by a COPY statement and all nested COPY statements.

So... what can we do? We can move that replacement one step down by using in either the copybook or outside it (possibly with REPLACE LAST OFF) a REPLACE statement (those are handled after all copybooks are included and their content replaced according to the REPLACING clause, if any..

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions