Bug #12652 » 0001-For-Dir.home-encode-passed-user.patch
file.c | ||
---|---|---|
3181 | 3181 |
VALUE |
3182 | 3182 |
rb_home_dir_of(VALUE user, VALUE result) |
3183 | 3183 |
{ |
3184 |
const char *dir, *username = RSTRING_PTR(user); |
|
3185 | 3184 |
#ifdef HAVE_PWD_H |
3186 |
struct passwd *pwPtr = getpwnam(username);
|
|
3185 |
struct passwd *pwPtr; |
|
3187 | 3186 |
#else |
3188 | 3187 |
extern char *getlogin(void); |
3189 | 3188 |
const char *pwPtr = 0; |
3190 | 3189 |
# define endpwent() ((void)0) |
3190 |
#endif |
|
3191 |
const char *dir, *username = RSTRING_PTR(user); |
|
3192 |
rb_encoding *enc = rb_enc_get(user); |
|
3193 |
#if defined _WIN32 |
|
3194 |
rb_encoding *fsenc = rb_utf8_encoding(); |
|
3195 |
#else |
|
3196 |
rb_encoding *fsenc = rb_filesystem_encoding(); |
|
3197 |
#endif |
|
3198 |
if (enc != fsenc) { |
|
3199 |
dir = username = RSTRING_PTR(rb_str_conv_enc(user, enc, fsenc)); |
|
3200 |
} |
|
3201 | ||
3202 |
#ifdef HAVE_PWD_H |
|
3203 |
pwPtr = getpwnam(username); |
|
3204 |
#else |
|
3191 | 3205 |
if (strcasecmp(username, getlogin()) == 0) |
3192 | 3206 |
dir = pwPtr = getenv("HOME"); |
3193 | 3207 |
#endif |
3194 |
- |