You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
hegel-cpp v0.13.1: generators::text with an alphabet doesn't restrict the generated characters #146
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