From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1863 invoked by alias); 30 May 2012 03:44:48 -0000 Received: (qmail 1849 invoked by uid 22791); 30 May 2012 03:44:47 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,TW_CP X-Spam-Check-By: sourceware.org Received: from mail-vb0-f41.google.com (HELO mail-vb0-f41.google.com) (209.85.212.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 30 May 2012 03:44:24 +0000 Received: by vbbey12 with SMTP id ey12so3628147vbb.0 for ; Tue, 29 May 2012 20:44:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:subject:from:to:cc:date:in-reply-to:references :organization:content-type:x-mailer:content-transfer-encoding :mime-version:x-gm-message-state; bh=dtRafRtbxrM0mAcXsQ7onG0Z4Gc2Vz5SDRl2LvVNUF8=; b=eJh3XYG3ml22tZlmwmb5uiNamaWmWt/ZWfFu3fC4VP8l2dqn4YupY6/HsgoBi8QNFS JU7fzM/CArQvSPpQ+gwVmq3QmPu/wATnuqMpew/kajtfTu4WxUeUs5kMqOMoi1phujMr gEO5lnaMnUGCWRDQ7O0LRIE7QSNhqrAP7F883vQo3Em93h+UaqU0HW5nY7y1b7WVZpTk LZkDSsMcqvD3S5+tli2CXNp+1fmKgZtrU+Goq3RlYQpn7VaxxoV8C2+mIRm4w2HZC9jr MK6i9W5mi58lDNr+lwMuv9fZRdk6MJ5PZvSvxQ8eLD8MMoDykFTIepEeq0WPTYc7DrbT Ncxw== Received: by 10.52.67.205 with SMTP id p13mr12930167vdt.33.1338349463364; Tue, 29 May 2012 20:44:23 -0700 (PDT) Received: from [192.168.1.50] (201.86.34.17.dynamic.adsl.gvt.net.br. [201.86.34.17]) by mx.google.com with ESMTPS id g10sm27703727vdk.2.2012.05.29.20.44.20 (version=SSLv3 cipher=OTHER); Tue, 29 May 2012 20:44:22 -0700 (PDT) Message-ID: <1338349458.3618.1.camel@hactar> Subject: Re: [patch] Expand tildes in solib-search-path entries. From: Thiago Jung Bauermann To: Pedro Alves Cc: gdb-patches ml Date: Wed, 30 May 2012 03:44:00 -0000 In-Reply-To: <4FBE542E.8020703@redhat.com> References: <1337710624.19373.9.camel@hactar> <4FBE542E.8020703@redhat.com> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit Mime-Version: 1.0 X-Gm-Message-State: ALoCoQn5kvtBx43oNTxqRx0EaoHxOyo/jVlrcg66ufVp6Bus0Mh701+oOrIJF+3i+brVmKNxGwPl X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-05/txt/msg01035.txt.bz2 Hello Pedro, On Thu, 2012-05-24 at 16:30 +0100, Pedro Alves wrote: > On 05/22/2012 07:17 PM, Thiago Jung Bauermann wrote: > > > diff --git a/gdb/source.c b/gdb/source.c > > index 27c5b0e..af68ebd 100644 > > --- a/gdb/source.c > > +++ b/gdb/source.c > > @@ -771,8 +771,28 @@ openp (const char *path, int opts, const char *string, > > } > > else > > { > > - /* Normal file name in path -- just use it. */ > > - strcpy (filename, dir); > > + /* See whether we need to expand the tilde. */ > > + if (strchr(dir, '~')) > > > Seem to me this could be an "else if" above the "else" instead of > nested within the "else". The "Don't search $cdir" bit below > should never apply, even in the rare beyond belief case of the user's > home expanding to literal "$cdir". Okay with that change. You are right, here's what I committed. -- []'s Thiago Jung Bauermann Linaro Toolchain Working Group 2012-05-30 Thiago Jung Bauermann * source.c (openp): Expand tilde in path entries. diff --git a/gdb/source.c b/gdb/source.c index 27c5b0e..7de86b4 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -769,6 +769,25 @@ openp (const char *path, int opts, const char *string, } strcpy (filename, current_directory); } + else if (strchr(dir, '~')) + { + /* See whether we need to expand the tilde. */ + int newlen; + char *tilde_expanded; + + tilde_expanded = tilde_expand (dir); + + /* First, realloc the filename buffer if too short. */ + len = strlen (tilde_expanded); + newlen = len + strlen (string) + 2; + if (newlen > alloclen) + { + alloclen = newlen; + filename = alloca (alloclen); + } + strcpy (filename, tilde_expanded); + xfree (tilde_expanded); + } else { /* Normal file name in path -- just use it. */