MCPcopy Create free account
hub / github.com/build-cpp/cmkr / escape_project_name

Function escape_project_name

src/cmake_generator.cpp:177–188  ·  view source on GitHub ↗

CMake target name rules: https://cmake.org/cmake/help/latest/policy/CMP0037.html [A-Za-z0-9_.+\-] TOML bare keys: non-empty strings composed only of [A-Za-z0-9_-] We replace all non-TOML bare key characters with _

Source from the content-addressed store, hash-verified

175// TOML bare keys: non-empty strings composed only of [A-Za-z0-9_-]
176// We replace all non-TOML bare key characters with _
177static std::string escape_project_name(const std::string &name) {
178 std::string escaped;
179 escaped.reserve(name.length());
180 for (auto ch : name) {
181 if ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9') || ch == '_' || ch == '-') {
182 escaped += ch;
183 } else {
184 escaped += '_';
185 }
186 }
187 return escaped;
188}
189
190static void generate_gitfile(const char *gitfile, const std::vector<std::string> &desired_lines) {
191 // Reference: https://github.com/github/linguist/blob/master/docs/overrides.md#summary

Callers 1

generate_projectFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected