Message ID | 20190603193716.4861-1-orgads@gmail.com |
---|---|
State | New, archived |
Headers |
Received: (qmail 50732 invoked by alias); 3 Jun 2019 19:37:35 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: <gdb-patches.sourceware.org> List-Unsubscribe: <mailto:gdb-patches-unsubscribe-##L=##H@sourceware.org> List-Subscribe: <mailto:gdb-patches-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-help@sourceware.org>, <http://sourceware.org/ml/#faqs> Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 50724 invoked by uid 89); 3 Jun 2019 19:37:35 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=H*m:gmail, msys, HContent-Transfer-Encoding:8bit X-HELO: mail-wm1-f68.google.com Received: from mail-wm1-f68.google.com (HELO mail-wm1-f68.google.com) (209.85.128.68) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 03 Jun 2019 19:37:33 +0000 Received: by mail-wm1-f68.google.com with SMTP id 16so8014808wmg.5 for <gdb-patches@sourceware.org>; Mon, 03 Jun 2019 12:37:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=oP8tloTnZKDm0ydrywhuvnYmqSk997tzWNm0qJV/y14=; b=kJQmMfeOb7OGbgFwYRomtJWaBCdRMz9k1wn2EEoA3tTCXzPMKD9uTTs8E91tK2Xkt2 lfUoAte6mnh70cjhA2JnC7kOQYO+8iFynHftg/2RmKi58W7eCLJauTNbhF9TcQRKsexc LBOtSafx/qP9tXGujdJKB1Lw2uZsJTjgM7JjjBMElHMEFqS0eBPP42PzP+4b3E0u0ehy qVWPJEBC+OdPFfX/oys/V/tqrW/hM8FnIKwOd6qHGy2hKhx/223QM4JIJ+02fDmlMBp3 bqMO8/zI6Ak2yZXV+XVUxpJX9r4IhVmPw62raY4fv2sef1gl1hnmcU3XCujF87olqP9S qaSQ== Return-Path: <orgads@gmail.com> Received: from junior.corp.audiocodes.com ([212.76.104.181]) by smtp.gmail.com with ESMTPSA id s127sm12207162wmf.48.2019.06.03.12.37.29 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 03 Jun 2019 12:37:30 -0700 (PDT) From: orgads@gmail.com To: gdb-patches@sourceware.org Cc: Orgad Shaneh <orgads@gmail.com> Subject: [PATCH] Fix cache dir resolving on Windows Date: Mon, 3 Jun 2019 22:37:16 +0300 Message-Id: <20190603193716.4861-1-orgads@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit |
Commit Message
Orgad Shaneh
June 3, 2019, 7:37 p.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
> From: orgads@gmail.com > Cc: Orgad Shaneh <orgads@gmail.com> > Date: Mon, 3 Jun 2019 22:37:16 +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..edb8a1fcda 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 ("USERPROFILE"); > +#endif > if (home != NULL) This is against the MS platform recommendations regarding "known folders", see https://docs.microsoft.com/en-us/windows/desktop/shell/knownfolderid https://docs.microsoft.com/en-us/windows/desktop/shell/csidl But maybe we don't care about that. I know that many applications ported from Unix don't.
On 2019-06-04 10:44 a.m., Eli Zaretskii wrote: >> From: orgads@gmail.com >> Cc: Orgad Shaneh <orgads@gmail.com> >> Date: Mon, 3 Jun 2019 22:37:16 +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..edb8a1fcda 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 ("USERPROFILE"); >> +#endif >> if (home != NULL) > > This is against the MS platform recommendations regarding "known > folders", see > > https://docs.microsoft.com/en-us/windows/desktop/shell/knownfolderid > https://docs.microsoft.com/en-us/windows/desktop/shell/csidl > > But maybe we don't care about that. I know that many applications > ported from Unix don't. If it's not too complicated to do The Right Thing (use these and be a good citizen, I would prefer that. But I won't be the one writing the change for Windows and maintaining it, so I won't force it either. Simon
> Cc: gdb-patches@sourceware.org > From: Simon Marchi <simark@simark.ca> > Date: Tue, 4 Jun 2019 11:05:52 -0400 > > > https://docs.microsoft.com/en-us/windows/desktop/shell/knownfolderid > > https://docs.microsoft.com/en-us/windows/desktop/shell/csidl > > > > But maybe we don't care about that. I know that many applications > > ported from Unix don't. > > If it's not too complicated to do The Right Thing (use these and be a good citizen, > I would prefer that. But I won't be the one writing the change for Windows > and maintaining it, so I won't force it either. If we want to follow the recommendations, it's just the matter of using a different environment variable: APPDATA instead of USERPROFILE. It is usually a subdirectory of USERPROFILE.
diff --git a/gdb/common/pathstuff.c b/gdb/common/pathstuff.c index 2b1669a5b9..edb8a1fcda 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 ("USERPROFILE"); +#endif if (home != NULL) { /* Make sure the path is absolute and tilde-expanded. */