ruby-changes:50221
From: nobu <ko1@a...>
Date: Sat, 10 Feb 2018 10:23:53 +0900 (JST)
Subject: [ruby-changes:50221] nobu:r62339 (trunk): mjit.c: chomp suffix first
nobu 2018-02-10 10:23:47 +0900 (Sat, 10 Feb 2018) New Revision: 62339 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62339 Log: mjit.c: chomp suffix first Modified files: trunk/mjit.c Index: mjit.c =================================================================== --- mjit.c (revision 62338) +++ mjit.c (revision 62339) @@ -786,16 +786,21 @@ convert_unit_to_func(struct rb_mjit_unit https://github.com/ruby/ruby/blob/trunk/mjit.c#L786 /* -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"); } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/