Bump.

Emacs gets HOME from environment here. I think that getting it from pw entry is 
more correct, but I can make a patch to behave like emacs if needed.

On 19/05/17 14:11, Lucas Gabriel Vuotto wrote:
> Previous patch shall be ignored, as it was an ugly hack. Below is a patch 
> that is simpler and fixes expandtilde instead, so it fixes the problem in 
> other situations (writing files to ~, for example). The only thing that I'm 
> not sure is whether to use getuid or geteuid. Any suggestion / explanation is 
> welcome.
> 
> Index: usr.bin/mg/fileio.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/mg/fileio.c,v
> retrieving revision 1.103
> diff -u -p -u -p -r1.103 fileio.c
> --- usr.bin/mg/fileio.c    28 Jul 2016 21:40:25 -0000    1.103
> +++ usr.bin/mg/fileio.c    18 May 2017 17:53:03 -0000
> @@ -723,15 +723,12 @@ expandtilde(const char *fn)
>          return(ret);
>      }
>      if (ulen == 0) { /* ~/ or ~ */
> -        if ((un = getlogin()) != NULL)
> -            (void)strlcpy(user, un, sizeof(user));
> -        else
> -            user[0] = '\0';
> +        pw = getpwuid(getuid());
>      } else { /* ~user/ or ~user */
>          memcpy(user, &fn[1], ulen);
>          user[ulen] = '\0';
> +        pw = getpwnam(user);
>      }
> -    pw = getpwnam(user);
>      if (pw != NULL) {
>          plen = strlcpy(path, pw->pw_dir, sizeof(path));
>          if (plen == 0 || path[plen - 1] != '/') {
> 

Reply via email to