summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-02-10 01:23:47 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-02-10 01:23:47 +0000
commit9da6b8dfdd14e2afe66ffeed86e5456469b1fb19 (patch)
tree1fd30270acf3d05487a109f7bbeff9cd0d8c3c9e
parentb30b1c13addd4cdfeefb57a1b9e6cdf4be0f66b6 (diff)
mjit.c: chomp suffix first
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62339 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--mjit.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/mjit.c b/mjit.c
index fa12a3f7d6..3755bd32cd 100644
--- a/mjit.c
+++ b/mjit.c
@@ -786,16 +786,21 @@ convert_unit_to_func(struct rb_mjit_unit *unit)
/* -include-pch is used for Clang */
if (mjit_opts.cc == MJIT_CC_GCC) {
const char *s = pch_file;
+ const char *e = s + strlen(s);
+ static const char suffix[] = ".gch";
+
fprintf(f, "#include \"");
+ /* chomp .gch suffix */
+ if (e > s+sizeof(suffix)-1 && strcmp(e-sizeof(suffix)+1, suffix) == 0) {
+ e -= sizeof(suffix)-1;
+ }
/* print pch_file except .gch */
- for (; strcmp(s, ".gch") != 0; s++) {
+ for (; s < e; s++) {
switch(*s) {
- case '\\':
- fprintf(f, "\\%c", *s);
- break;
- default:
- fprintf(f, "%c", *s);
+ case '\\': case '"':
+ fputc('\\', f);
}
+ fputc(*s, f);
}
fprintf(f, "\"\n");
}