8000 hegel-cpp v0.13.1: generators::text with an alphabet doesn't restrict the generated characters · Issue #146 · hegeldev/hegel-cpp · GitHub
[go: up one dir, main page]

Skip to content

hegel-cpp v0.13.1: generators::text with an alphabet doesn't restrict the generated characters #146

Open

Description

@hrvojem

Summary
TextParams::alphabet is documented as a "fixed set of allowed characters", but strings drawn with it contain characters outside the set. build_text_handle (src/generators.cpp) implements alphabet as an empty category list plus include_characters. string_generator_text (src/engine.cpp:343) passes categories.data() to the engine, and data() of an empty std::vector is nullptr with libstdc++, which the engine reads as "no category restriction".

Reproduction

auto s = tc.draw(gs::text({.alphabet = std::string("ab ~.-_%")}));
// drawn: "/" (not in the alphabet)
auto k = tc.draw(gs::text({.alphabet = std::string(" \tabcXYZ-")}));
// drawn: ":" (not in the alphabet)

Suggested fix
Pass a non-null pointer for an empty category list, or add an explicit "no categories" flag to the C ABI.

Seen with hegel-cpp v0.13.1 fetched by CMake, on Linux (Ubuntu 24.04, GCC 13.3, libstdc++).

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0