зеркало из https://github.com/github/ruby.git
* file.c (file_expand_path): set external encoding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
23bb4d7898
Коммит
0ae6c7f816
|
@ -1,4 +1,6 @@
|
|||
Sat Apr 12 03:12:16 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
Sat Apr 12 03:13:38 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* file.c (file_expand_path): set external encoding.
|
||||
|
||||
* file.c (rb_file_s_basename, rb_file_s_dirname, rb_file_s_extname):
|
||||
copy encoding.
|
||||
|
|
12
file.c
12
file.c
|
@ -2551,6 +2551,11 @@ rb_path_end(const char *path)
|
|||
buflen = RSTRING_LEN(result),\
|
||||
pend = p + buflen)
|
||||
|
||||
#define SET_EXTERNAL_ENCODING() (\
|
||||
(void)(extenc || (extenc = rb_default_external_encoding())),\
|
||||
rb_enc_associate(result, extenc),\
|
||||
rb_enc_check(fname, result))
|
||||
|
||||
static int is_absolute_path(const char*);
|
||||
|
||||
static VALUE
|
||||
|
@ -2559,6 +2564,7 @@ file_expand_path(VALUE fname, VALUE dname, VALUE result)
|
|||
char *s, *buf, *b, *p, *pend, *root;
|
||||
long buflen, dirlen;
|
||||
int tainted;
|
||||
rb_encoding *extenc = 0;
|
||||
|
||||
FilePathValue(fname);
|
||||
s = StringValuePtr(fname);
|
||||
|
@ -2586,6 +2592,7 @@ file_expand_path(VALUE fname, VALUE dname, VALUE result)
|
|||
#endif
|
||||
s++;
|
||||
tainted = 1;
|
||||
SET_EXTERNAL_ENCODING();
|
||||
}
|
||||
else {
|
||||
#ifdef HAVE_PWD_H
|
||||
|
@ -2641,6 +2648,7 @@ file_expand_path(VALUE fname, VALUE dname, VALUE result)
|
|||
BUFCHECK(dirlen > buflen);
|
||||
strcpy(buf, dir);
|
||||
free(dir);
|
||||
SET_EXTERNAL_ENCODING();
|
||||
}
|
||||
p = chompdirsep(skiproot(buf));
|
||||
s += 2;
|
||||
|
@ -2660,6 +2668,7 @@ file_expand_path(VALUE fname, VALUE dname, VALUE result)
|
|||
BUFCHECK(dirlen > buflen);
|
||||
strcpy(buf, dir);
|
||||
free(dir);
|
||||
SET_EXTERNAL_ENCODING();
|
||||
}
|
||||
#if defined DOSISH || defined __CYGWIN__
|
||||
if (isdirsep(*s)) {
|
||||
|
@ -2749,13 +2758,14 @@ file_expand_path(VALUE fname, VALUE dname, VALUE result)
|
|||
|
||||
if (tainted) OBJ_TAINT(result);
|
||||
rb_str_set_len(result, p - buf);
|
||||
rb_enc_check(fname, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_file_expand_path(VALUE fname, VALUE dname)
|
||||
{
|
||||
return file_expand_path(fname, dname, rb_str_new(0, MAXPATHLEN + 2));
|
||||
return file_expand_path(fname, dname, rb_usascii_str_new(0, MAXPATHLEN + 2));
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Загрузка…
Ссылка в новой задаче