|
6 | 6 | // #include <string.h> |
7 | 7 | // #include <unistd.h> |
8 | 8 |
|
9 | | -#include <glob.h> |
| 9 | +#include <filesystem> |
10 | 10 |
|
11 | 11 | #include <fstream> |
12 | 12 | #include <iostream> |
@@ -1250,14 +1250,17 @@ static int ssh_config_parse_line(const char *targethost, |
1250 | 1250 | if (p) { |
1251 | 1251 | char *filename = ssh_path_expand_tilde(p); |
1252 | 1252 | if (filename) { |
1253 | | - glob_t g; |
1254 | 1253 | if (strchr(filename, '*') || strchr(filename, '?')) { |
1255 | | - if (glob(filename, 0, NULL, &g) == 0) { |
1256 | | - for (size_t i = 0; i < g.gl_pathc; ++i) { |
1257 | | - local_parse_file(targethost, options, g.gl_pathv[i], parsing, |
1258 | | - seen); |
| 1254 | + std::string dir = fs::path(filename).parent_path().string(); |
| 1255 | + std::string pattern = fs::path(filename).filename().string(); |
| 1256 | + std::regex pattern_regex( |
| 1257 | + std::regex_replace(std::regex_replace(pattern, std::regex(R"(\.)"), R"(\.)"), |
| 1258 | + std::regex(R"(\*)"), ".*") |
| 1259 | + ); |
| 1260 | + for (const auto& entry : fs::directory_iterator(dir.empty() ? "." : dir)) { |
| 1261 | + if (std::regex_match(entry.path().filename().string(), pattern_regex)) { |
| 1262 | + local_parse_file(targethost, options, entry.path().string().c_str(), parsing, seen); |
1259 | 1263 | } |
1260 | | - globfree(&g); |
1261 | 1264 | } |
1262 | 1265 | } else { |
1263 | 1266 | local_parse_file(targethost, options, filename, parsing, seen); |
|
0 commit comments