From: Bryan Duxbury Date: Thu, 22 Apr 2010 21:21:46 +0000 (+0000) Subject: THRIFT-611. Under Windows when compiling using MinGW, includes are incorrectly resol... X-Git-Tag: 0.3.0~32 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=0137af6bf1e37762db319a08d2d6921d6897e21f;p=common%2Fthrift.git THRIFT-611. Under Windows when compiling using MinGW, includes are incorrectly resolved due to '/' <-> '\' havoc. This patch ensures the proper slashes are used based on the platform. git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@937070 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/compiler/cpp/src/main.cc b/compiler/cpp/src/main.cc index 507aaeeb..2c83690b 100644 --- a/compiler/cpp/src/main.cc +++ b/compiler/cpp/src/main.cc @@ -191,6 +191,15 @@ char *saferealpath(const char *path, char *resolved_path) { CharLowerBuff(buf, len); strcpy(resolved_path, buf); } + + // Replace backslashes with forward slashes so the + // rest of the code behaves correctly. + size_t resolved_len = strlen(resolved_path); + for (size_t i = 0; i < resolved_len; i++) { + if (resolved_path[i] == '\\') { + resolved_path[i] = '/'; + } + } return resolved_path; #else return realpath(path, resolved_path);