Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2016-07-31 02:54:05 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2016-07-31 03:02:28 +0300
commitb2e16c57002aed98dc433e84f4c3f8206b29b1c3 (patch)
tree2b784aded08a8ff812c45c23f5bc4a03d359b91b
parent01d5d2853bbbf07e4b64082e60fbb6d53799ed94 (diff)
Fix Cycles OpenCL compile error on Windows.
-rw-r--r--intern/cycles/util/util_path.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/intern/cycles/util/util_path.cpp b/intern/cycles/util/util_path.cpp
index 800dfa273bd..f23f2cb0168 100644
--- a/intern/cycles/util/util_path.cpp
+++ b/intern/cycles/util/util_path.cpp
@@ -728,6 +728,17 @@ bool path_remove(const string& path)
return remove(path.c_str()) == 0;
}
+static string line_directive(const string& path, int line)
+{
+ string escaped_path = path;
+ string_replace(escaped_path, "\"", "\\\"");
+ string_replace(escaped_path, "\'", "\\\'");
+ string_replace(escaped_path, "\?", "\\\?");
+ string_replace(escaped_path, "\\", "\\\\");
+ return string_printf("#line %d \"%s\"", line, escaped_path.c_str());
+}
+
+
string path_source_replace_includes(const string& source, const string& path)
{
/* Our own little c preprocessor that replaces #includes with the file
@@ -759,14 +770,10 @@ string path_source_replace_includes(const string& source, const string& path)
text = path_source_replace_includes(
text, path_dirname(filepath));
text = path_source_replace_includes(text, path);
- line = token.replace(0, n_end + 1, "\n" + text + "\n");
-
- /* Line directives for better error messages. */
- line = string_printf("#line %d \"%s\"\n",
- (int)0, filepath.c_str())
- + line
- + string_printf("\n#line %d \"%s\"",
- (int)i, path.c_str());
+ /* Use line directives for better error messages. */
+ line = line_directive(filepath, 1)
+ + token.replace(0, n_end + 1, "\n" + text + "\n")
+ + line_directive(path, i);
}
}
}