| 2226 | } |
| 2227 | |
| 2228 | static bool cbm_expand_user_path(const char *home_dir, const char *value, char *out, |
| 2229 | size_t out_sz) { |
| 2230 | if (!home_dir || !home_dir[0] || !value || !value[0] || !out || out_sz == 0U) { |
| 2231 | return false; |
| 2232 | } |
| 2233 | int written = -1; |
| 2234 | if (strcmp(value, "~") == 0) { |
| 2235 | written = snprintf(out, out_sz, "%s", home_dir); |
| 2236 | } else if (value[0] == '~' && (value[1] == '/' || value[1] == '\\')) { |
| 2237 | written = snprintf(out, out_sz, "%s/%s", home_dir, value + 2); |
| 2238 | } else if (value[0] == '/' || (isalpha((unsigned char)value[0]) && value[1] == ':' && |
| 2239 | (value[2] == '/' || value[2] == '\\'))) { |
| 2240 | written = snprintf(out, out_sz, "%s", value); |
| 2241 | } |
| 2242 | return written >= 0 && (size_t)written < out_sz; |
| 2243 | } |
| 2244 | |
| 2245 | static void cbm_env_home_dir(const char *env_name, const char *home_dir, const char *fallback, |
| 2246 | char *out, size_t out_sz) { |
no outgoing calls
no test coverage detected