1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

mjit.c: chomp suffix first

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62339 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2018-02-10 01:23:47 +00:00
parent b30b1c13ad
commit 9da6b8dfdd

17
mjit.c
View file

@ -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");
}