| 116 | } |
| 117 | |
| 118 | static void progress_tool_name(const char *tool_name, char out[CBM_SZ_64]) { |
| 119 | size_t offset = 0; |
| 120 | if (tool_name) { |
| 121 | for (; tool_name[offset] && offset + 1 < CBM_SZ_64; offset++) { |
| 122 | unsigned char ch = (unsigned char)tool_name[offset]; |
| 123 | bool safe = (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || |
| 124 | (ch >= '0' && ch <= '9') || ch == '_' || ch == '-'; |
| 125 | if (!safe) { |
| 126 | offset = 0; |
| 127 | break; |
| 128 | } |
| 129 | out[offset] = (char)ch; |
| 130 | } |
| 131 | } |
| 132 | if (offset == 0) { |
| 133 | (void)snprintf(out, CBM_SZ_64, "%s", "tool"); |
| 134 | } else { |
| 135 | out[offset] = '\0'; |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | void cbm_cli_progress_start(FILE *out, const char *tool_name) { |
| 140 | FILE *stream = out ? out : stderr; |
no outgoing calls
no test coverage detected