Fix cache dir resolving on Windows

Message ID 20190607062719.10989-1-orgads@gmail.com
State New, archived
Headers

Commit Message

Orgad Shaneh June 7, 2019, 6:27 a.m. UTC
  From: Orgad Shaneh <orgads@gmail.com>

... when not running from MSYS environment, and HOME is not set.
---
 gdb/common/pathstuff.c | 4 ++++
 1 file changed, 4 insertions(+)
  

Comments

Eli Zaretskii June 7, 2019, 7:36 a.m. UTC | #1
> From: orgads@gmail.com
> Cc: Orgad Shaneh <orgads@gmail.com>
> Date: Fri,  7 Jun 2019 09:27:19 +0300
> 
> From: Orgad Shaneh <orgads@gmail.com>
> 
> ... when not running from MSYS environment, and HOME is not set.
> ---
>  gdb/common/pathstuff.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/gdb/common/pathstuff.c b/gdb/common/pathstuff.c
> index 2b1669a5b9..59410fb61f 100644
> --- a/gdb/common/pathstuff.c
> +++ b/gdb/common/pathstuff.c
> @@ -231,6 +231,10 @@ get_standard_cache_dir ()
>  #endif
>  
>    const char *home = getenv ("HOME");
> +#ifdef _WIN32
> +  if (home == nullptr)
> +      home = getenv ("APPDATA");
> +#endif
>    if (home != NULL)
>      {
>        /* Make sure the path is absolute and tilde-expanded.  */

Thanks, this LGTM.
  
Eli Zaretskii June 7, 2019, 8 a.m. UTC | #2
> Date: Fri, 07 Jun 2019 10:36:39 +0300
> From: Eli Zaretskii <eliz@gnu.org>
> CC: gdb-patches@sourceware.org
> 
> >    const char *home = getenv ("HOME");
> > +#ifdef _WIN32
> > +  if (home == nullptr)
> > +      home = getenv ("APPDATA");
> > +#endif
> >    if (home != NULL)
> >      {
> >        /* Make sure the path is absolute and tilde-expanded.  */
> 
> Thanks, this LGTM.

Actually, I see that we mention HOME on Windows in the manual, in a
footnote that's part of the "Startup" node.  I think we should
document this addition there.  Would you like to add a change to the
manual as well?

Thanks.

P.S. I see that you don't have a copyright assignment on file, which
means we are limited in the amount of changes we can accept from you.
Would you like to start the legal paperwork of assigning to the FSF
the copyright for your changes?  If so, I will send you the form to
fill.
  
Eli Zaretskii June 7, 2019, 12:29 p.m. UTC | #3
> From: Orgad Shaneh <orgads@gmail.com>
> Date: Fri, 7 Jun 2019 11:58:45 +0300
> 
> On Fri, Jun 7, 2019 at 11:01 AM Eli Zaretskii <eliz@gnu.org> wrote:
> > Actually, I see that we mention HOME on Windows in the manual, in a
> > footnote that's part of the "Startup" node.  I think we should
> > document this addition there.  Would you like to add a change to the
> > manual as well?
> 
> This refers to gdbinit, which probably should also be added a fallback
> to APPDATA. Anyway, it is not related to this patch, which is about
> the cache directory.

Oh, so we probe $HOME in more than one place?  Yes, I think we should
do this in all of those places, preferably through a single function.

> > P.S. I see that you don't have a copyright assignment on file, which
> > means we are limited in the amount of changes we can accept from you.
> > Would you like to start the legal paperwork of assigning to the FSF
> > the copyright for your changes?  If so, I will send you the form to
> > fill.
> 
> Sure.

Thanks, form sent off-list.
  
Tom Tromey June 7, 2019, 6:10 p.m. UTC | #4
>> +#ifdef _WIN32
>> +  if (home == nullptr)
>> +      home = getenv ("APPDATA");

I think the assignment line is indented a bit too far -- should be 2
spaces over from the "if", per the GNU style.

thanks,
Tom
  

Patch

diff --git a/gdb/common/pathstuff.c b/gdb/common/pathstuff.c
index 2b1669a5b9..59410fb61f 100644
--- a/gdb/common/pathstuff.c
+++ b/gdb/common/pathstuff.c
@@ -231,6 +231,10 @@  get_standard_cache_dir ()
 #endif
 
   const char *home = getenv ("HOME");
+#ifdef _WIN32
+  if (home == nullptr)
+      home = getenv ("APPDATA");
+#endif
   if (home != NULL)
     {
       /* Make sure the path is absolute and tilde-expanded.  */