aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-07-11 16:52:26 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-07-11 16:52:26 +0200
commit39d36c3be269de1d80c162f76021750858e1f60c (patch)
treecf0deee4fc365429bd87b105aea4b1e992cc8e01
parente3839b800a9ab1bc4824b742ccaef7ce3d59c291 (diff)
Escape Windows path backslashes in synthesized .rc file
-rw-r--r--build2/cxx/link.cxx20
1 files changed, 18 insertions, 2 deletions
diff --git a/build2/cxx/link.cxx b/build2/cxx/link.cxx
index 34dc8d9..3fbcc07 100644
--- a/build2/cxx/link.cxx
+++ b/build2/cxx/link.cxx
@@ -1040,9 +1040,25 @@ namespace build2
ofdstream os (pr.out_fd);
os.exceptions (ofdstream::badbit | ofdstream::failbit);
- // 1 is resource ID, 24 is RT_MANIFEST.
+ // 1 is resource ID, 24 is RT_MANIFEST. We also need to escape
+ // Windows path backslashes.
//
- os << "1 24 \"" << mf << "\"" << endl;
+ os << "1 24 \"";
+
+ const string& s (mf.string ());
+ for (size_t i (0), j;; i = j + 1)
+ {
+ j = s.find ('\\', i);
+ os.write (s.c_str () + i,
+ (j == string::npos ? s.size () : j) - i);
+
+ if (j == string::npos)
+ break;
+
+ os.write ("\\\\", 2);
+ }
+
+ os << "\"" << endl;
os.close ();
}