code simplification (#1244)

Based on #1242, I don't think this is required but it does remove that
issue and checking on compiler explore it does simplify the generated
code.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Philip Top
2025-10-27 06:17:19 -07:00
committed by GitHub
parent 8ddadd7cea
commit bfffd37e1f
2 changed files with 6 additions and 4 deletions

View File

@@ -17,7 +17,11 @@ and a potential segmentation fault from specially crafted config files
- Fixed incorrect inclusion of definition for extra validators [#1238][]
- Fixed fuzz generated failure from crafted files introduced in recent release
[#1238][]
- Removed some usage of static const std::string in inline function that had
potential memory issues when CLI11 is used with shared libraries, this likely
isn't a bug but the fix did result in smaller code size so was kept. [#1244][]
[#1244]: https://github.com/CLIUtils/CLI11/pull/1244
[#1238]: https://github.com/CLIUtils/CLI11/pull/1238
[#1239]: https://github.com/CLIUtils/CLI11/pull/1239

View File

@@ -165,14 +165,12 @@ CLI11_INLINE bool valid_name_string(const std::string &str);
/// Verify an app name
inline bool valid_alias_name_string(const std::string &str) {
static const std::string badChars{'\n', '\0'};
return (str.find_first_of(badChars) == std::string::npos);
return ((str.find_first_of('\n') == std::string::npos) && (str.find_first_of('\0') == std::string::npos));
}
/// check if a string is a container segment separator (empty or "%%")
inline bool is_separator(const std::string &str) {
static const std::string sep("%%");
return (str.empty() || str == sep);
return (str.empty() || (str.size() == 2 && str[0] == '%' && str[1] == '%'));
}
/// Verify that str consists of letters only