Skip to content
Snippets Groups Projects
Verified Commit b2fe84b1 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Macroprocessor: under Windows, trim trailing slashes and backslashes in the...

Macroprocessor: under Windows, trim trailing slashes and backslashes in the value of “@#includepath”

This is a  workaround for a GCC/MinGW bug present in version 10.2
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88881), that affects
gcc-mingw-w64 in Debian “Bullseye” 11. It is fixed in GCC 10.3, and thus should
be fixed in Debian “Bookworm” 12.

Ref. Madysson/estimation-codes#11

(cherry picked from commit 3d894b3a)
parent 1683baee
Branches
No related tags found
No related merge requests found
/*
* Copyright © 2019-2021 Dynare Team
* Copyright © 2019-2022 Dynare Team
*
* This file is part of Dynare.
*
......@@ -98,7 +98,20 @@ IncludePath::interpret(ostream &output, Environment &env, vector<filesystem::pat
StringPtr msp = dynamic_pointer_cast<String>(expr->eval(env));
if (!msp)
throw StackTrace("File name does not evaluate to a string");
#ifdef _WIN32
/* Trim trailing slashes and backslashes in the path. This is a
workaround for a GCC/MinGW bug present in version 10.2
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88881, that affects
gcc-mingw-w64 in Debian “Bullseye” 11. It is fixed in GCC 10.3, and
thus should be fixed in Debian “Bookworm” 12.
See Madysson/estimation-codes#11. */
string ipstr = static_cast<string>(*msp);
while (ipstr.size() > 1 && (ipstr.back() == '/' || ipstr.back() == '\\'))
ipstr.pop_back();
path ip{ipstr};
#else
path ip = static_cast<string>(*msp);
#endif
if (!is_directory(ip))
throw StackTrace(ip.string() + " does not evaluate to a valid directory");
if (!exists(ip))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment