Skip to content

Commit 5da3619

Browse files
Kenogiulianobelinassi
authored andcommitted
Disable wordexp on Windows where it is unavailable
The wordexp() function is a POSIX extension not available on Windows. This patch conditionally compiles wordexp usage only on non-Windows platforms. On Windows, the path is used as-is without shell expansion, since Windows does not support tilde expansion in the same way as POSIX systems. Changes: - Wrap #include <wordexp.h> with #ifndef _WIN32 - Add platform-specific constructor implementations - Windows version simply stores the path without expansion
1 parent e818417 commit 5da3619

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

libcextract/Parser.hh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
#include <string.h>
2121
#include <errno.h>
2222
#include <stdexcept>
23+
#ifndef _WIN32
2324
#include <wordexp.h>
25+
#endif
2426

2527
class Parser
2628
{
@@ -32,6 +34,7 @@ public:
3234

3335
Parser(const char *path)
3436
{
37+
#ifndef _WIN32
3538
/* Expand shell characters like '~' in paths. */
3639
wordexp_t exp_result;
3740
wordexp(path, &exp_result, 0);
@@ -41,6 +44,10 @@ public:
4144

4245
/* Release expansion object. */
4346
wordfree(&exp_result);
47+
#else
48+
/* wordexp is not available on Windows, use path as-is */
49+
parser_path = std::string(path);
50+
#endif
4451
}
4552

4653
// Some parsers work on files

0 commit comments

Comments
 (0)