|
15 | 15 | #include "xeus-cpp/xinterpreter.hpp"
|
16 | 16 | #include "xeus-cpp/xmagics.hpp"
|
17 | 17 |
|
| 18 | +#include <cstdlib> // for std::getenv |
18 | 19 | #include <cstring> // for std::strlen
|
19 | 20 | #include <sstream> // for std::istringstream
|
20 | 21 | #include <string> // for std::getline
|
@@ -364,25 +365,23 @@ __get_cxx_version ()
|
364 | 365 | // Add the standard include path
|
365 | 366 | Cpp::AddIncludePath((xeus::prefix_path() + "/include/").c_str());
|
366 | 367 |
|
367 |
| - // Get include paths from environment variable |
| 368 | + // Get include paths from environment variable and use empty string if not set |
368 | 369 | const char* non_standard_paths = std::getenv("XEUS_SEARCH_PATH");
|
369 |
| - if (!non_standard_paths) { |
| 370 | + if (!non_standard_paths) |
370 | 371 | non_standard_paths = "";
|
371 |
| - } |
372 | 372 |
|
373 |
| - if (std::strlen(non_standard_paths) > 0) |
374 |
| - { |
375 |
| - // Split the paths by colon ':' and add each one |
376 |
| - std::istringstream stream(non_standard_paths); |
377 |
| - std::string path; |
378 |
| - while (std::getline(stream, path, ':')) |
379 |
| - { |
380 |
| - if (!path.empty()) |
381 |
| - { |
382 |
| - Cpp::AddIncludePath(path.c_str()); |
383 |
| - } |
384 |
| - } |
385 |
| - } |
| 373 | +#ifdef _WIN32 |
| 374 | + const char path_separator = ';'; |
| 375 | +#else |
| 376 | + const char path_separator = ':'; |
| 377 | +#endif |
| 378 | + |
| 379 | + // Split and add each non-empty path |
| 380 | + std::istringstream stream(non_standard_paths); |
| 381 | + std::string path; |
| 382 | + while (std::getline(stream, path, path_separator)) |
| 383 | + if (!path.empty()) |
| 384 | + Cpp::AddIncludePath(path.c_str()); |
386 | 385 | }
|
387 | 386 |
|
388 | 387 | void interpreter::init_preamble()
|
|
0 commit comments