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 _
| 175 | // TOML bare keys: non-empty strings composed only of [A-Za-z0-9_-] |
| 176 | // We replace all non-TOML bare key characters with _ |
| 177 | static 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 | |
| 190 | static 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 |