| 2276 | } |
| 2277 | |
| 2278 | static bool cbm_expand_user_path(const char *home_dir, const char *value, char *out, |
| 2279 | size_t out_sz) { |
| 2280 | if (!home_dir || !home_dir[0] || !value || !value[0] || !out || out_sz == 0U) { |
| 2281 | return false; |
| 2282 | } |
| 2283 | int written = -1; |
| 2284 | if (strcmp(value, "~") == 0) { |
| 2285 | written = snprintf(out, out_sz, "%s", home_dir); |
| 2286 | } else if (value[0] == '~' && (value[1] == '/' || value[1] == '\\')) { |
| 2287 | written = snprintf(out, out_sz, "%s/%s", home_dir, value + 2); |
| 2288 | } else if (value[0] == '/' || (isalpha((unsigned char)value[0]) && value[1] == ':' && |
| 2289 | (value[2] == '/' || value[2] == '\\'))) { |
| 2290 | written = snprintf(out, out_sz, "%s", value); |
| 2291 | } |
| 2292 | return written >= 0 && (size_t)written < out_sz; |
| 2293 | } |
| 2294 | |
| 2295 | static void cbm_env_home_dir(const char *env_name, const char *home_dir, const char *fallback, |
| 2296 | char *out, size_t out_sz) { |
no outgoing calls
no test coverage detected