Skip to content

Terminate-String word is unsafe #1

@MaxBarraclough

Description

@MaxBarraclough

ANS Forth forbids modification of strings returned by the S" word (a.k.a. s-quote). (See also this discussion, ctrl-f for shall not alter.) This means that the Terminate-String word is non-compliant. More specifically, its intended use, in combination with S", is non-compliant.

I think the standard-compliant solution is to use the S\" word instead, where the \z sequence generates a null character, like '\0' in C, suitable for termination.

See also this StackOverflow thread, although he uses \0 rather than \z, which doesn't seem right.

From what I can see, ANS Forth offers no similar words for producing mutable strings. Perhaps a copy-based approach could also be made to work.

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