| 2407 | } |
| 2408 | |
| 2409 | static bool cbm_expand_user_path(const char *home_dir, const char *value, char *out, |
| 2410 | size_t out_sz) { |
| 2411 | if (!home_dir || !home_dir[0] || !value || !value[0] || !out || out_sz == 0U) { |
| 2412 | return false; |
| 2413 | } |
| 2414 | int written = -1; |
| 2415 | if (strcmp(value, "~") == 0) { |
| 2416 | written = snprintf(out, out_sz, "%s", home_dir); |
| 2417 | } else if (value[0] == '~' && (value[1] == '/' || value[1] == '\\')) { |
| 2418 | written = snprintf(out, out_sz, "%s/%s", home_dir, value + 2); |
| 2419 | } else if (value[0] == '/' || (isalpha((unsigned char)value[0]) && value[1] == ':' && |
| 2420 | (value[2] == '/' || value[2] == '\\'))) { |
| 2421 | written = snprintf(out, out_sz, "%s", value); |
| 2422 | } |
| 2423 | return written >= 0 && (size_t)written < out_sz; |
| 2424 | } |
| 2425 | |
| 2426 | static void cbm_env_home_dir(const char *env_name, const char *home_dir, const char *fallback, |
| 2427 | char *out, size_t out_sz) { |
no outgoing calls
no test coverage detected