diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-02-10 01:23:47 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-02-10 01:23:47 +0000 |
commit | 9da6b8dfdd14e2afe66ffeed86e5456469b1fb19 (patch) | |
tree | 1fd30270acf3d05487a109f7bbeff9cd0d8c3c9e /mjit.c | |
parent | b30b1c13addd4cdfeefb57a1b9e6cdf4be0f66b6 (diff) | |
download | ruby-9da6b8dfdd14e2afe66ffeed86e5456469b1fb19.tar.gz |
mjit.c: chomp suffix first
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62339 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'mjit.c')
-rw-r--r-- | mjit.c | 17 |
1 files changed, 11 insertions, 6 deletions
@@ -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"); } |