mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
ruby.c: compare with EXEEXT
* ruby.c (open_load_file): compare with EXEEXT instead of hard coded name, and do not match with mere EXEEXT. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56386 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
18d0bf952a
commit
3ef1149bbe
2 changed files with 11 additions and 4 deletions
|
@ -1,4 +1,7 @@
|
|||
Mon Oct 10 12:40:04 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
Mon Oct 10 12:40:54 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* ruby.c (open_load_file): compare with EXEEXT instead of hard
|
||||
coded name, and do not match with mere EXEEXT.
|
||||
|
||||
* ruby.c (open_load_file): open in binary mode if available, as
|
||||
parser deals with EOLs.
|
||||
|
|
10
ruby.c
10
ruby.c
|
@ -1865,10 +1865,11 @@ static VALUE
|
|||
open_load_file(VALUE fname_v, int *xflag)
|
||||
{
|
||||
const char *fname = StringValueCStr(fname_v);
|
||||
long flen = RSTRING_LEN(fname_v);
|
||||
VALUE f;
|
||||
int e;
|
||||
|
||||
if (RSTRING_LEN(fname_v) == 1 && fname[0] == '-') {
|
||||
if (flen == 1 && fname[0] == '-') {
|
||||
f = rb_stdin;
|
||||
}
|
||||
else {
|
||||
|
@ -1889,9 +1890,12 @@ open_load_file(VALUE fname_v, int *xflag)
|
|||
#endif
|
||||
MODE_TO_LOAD;
|
||||
#if defined DOSISH || defined __CYGWIN__
|
||||
# define isdirsep(x) ((x) == '/' || (x) == FILE_ALT_SEPARATOR)
|
||||
{
|
||||
const char *ext = strrchr(fname, '.');
|
||||
if (ext && STRCASECMP(ext, ".exe") == 0) {
|
||||
static const char exeext[] = EXEEXT;
|
||||
enum {extlen = sizeof(exeext)-1};
|
||||
if (flen > extlen && !isdirsep(fname[flen-extlen-1]) &&
|
||||
STRNCASECMP(fname+flen-extlen, exeext, extlen) == 0) {
|
||||
*xflag = 1;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue