Project

General

Profile

Bug #12652 » 0001-For-Dir.home-encode-passed-user.patch

davispuh (Dāvis Mosāns), 08/03/2016 04:27 PM

View differences:

file.c
VALUE
rb_home_dir_of(VALUE user, VALUE result)
{
const char *dir, *username = RSTRING_PTR(user);
#ifdef HAVE_PWD_H
struct passwd *pwPtr = getpwnam(username);
struct passwd *pwPtr;
#else
extern char *getlogin(void);
const char *pwPtr = 0;
# define endpwent() ((void)0)
#endif
const char *dir, *username = RSTRING_PTR(user);
rb_encoding *enc = rb_enc_get(user);
#if defined _WIN32
rb_encoding *fsenc = rb_utf8_encoding();
#else
rb_encoding *fsenc = rb_filesystem_encoding();
#endif
if (enc != fsenc) {
dir = username = RSTRING_PTR(rb_str_conv_enc(user, enc, fsenc));
}
#ifdef HAVE_PWD_H
pwPtr = getpwnam(username);
#else
if (strcasecmp(username, getlogin()) == 0)
dir = pwPtr = getenv("HOME");
#endif
    (1-1/1)