From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24468 invoked by alias); 28 Nov 2001 17:43:48 -0000 Mailing-List: contact gdb-patches-help@sourceware.cygnus.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 24388 invoked from network); 28 Nov 2001 17:43:44 -0000 Received: from unknown (HELO miranda.axis.se) (193.13.178.2) by hostedprojects.ges.redhat.com with SMTP; 28 Nov 2001 17:43:44 -0000 Received: from ironmaiden.axis.se (ironmaiden.axis.se [10.13.8.120]) by miranda.axis.se (8.12.1/8.12.1/Debian -2) with ESMTP id fASHhYXX019733; Wed, 28 Nov 2001 18:43:34 +0100 Received: from axis.com (localhost [127.0.0.1]) by ironmaiden.axis.se (8.9.3/8.9.3/Debian 8.9.3-21) with ESMTP id SAA06793; Wed, 28 Nov 2001 18:43:34 +0100 X-Authentication-Warning: ironmaiden.axis.se: Host localhost [127.0.0.1] claimed to be axis.com Message-ID: <3C052245.8C02668E@axis.com> Date: Sat, 17 Nov 2001 04:03:00 -0000 From: Orjan Friberg Organization: Axis Communications AB X-Mailer: Mozilla 4.76 [en] (X11; U; Linux 2.2.19 i686) X-Accept-Language: en MIME-Version: 1.0 To: Eli Zaretskii CC: gdb-patches@sources.redhat.com Subject: Re: [RFC]: Solib search (Was: Re: Cross solib support; continued) References: <3BEAA3A0.586B3046@axis.com> <20011108110955.A12240@nevyn.them.org> <3C03AB51.DB27B3D4@axis.com> <3405-Tue27Nov2001175932+0200-eliz@is.elta.co.il> <3C04B5A9.1F054A9F@axis.com> <7458-Wed28Nov2001183554+0200-eliz@is.elta.co.il> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-SW-Source: 2001-11/txt/msg00321.txt.bz2 Message-ID: <20011117040300.wQ61lWEoAricdqlRE8TtwApLVkjXYjdkKpnec-TjCpk@z> Eli Zaretskii wrote: > > > Date: Wed, 28 Nov 2001 11:00:09 +0100 > > From: Orjan Friberg > > > That will only get rid of the first dir separator. > > But that's what your original code did on Unix: it would test if the > first character is a slash, and if so, step over that one slash. Did > I miss something? No, you didn't miss anything ;) . I forgot to explain something. > Since we are under the if clause, we _know_ that the file name begins > with either "/foo" or "d:/foo". In the first case, IS_DIR_SEPARATOR > returns 1, so the while loop is terminated immediately, but > in_pathname was already bumped to point after the slash--that's what > your original code did. In the second code, the loop will march over > the drive letter and the colon and terminate on the slash that > follows, and again in_pathname will be incremented by the last > iteration to point right after the slash. I was trying to address the situation where in_pathname contains several leading slashes; then your suggested code (and my original code also) would terminate too early. I guess we don't normally care about multiple leading slashes since it's a valid path, but in this case we need to get rid of all of them to make it a relative path. This code should cut it: if (found_file < 0 && IS_ABSOLUTE_PATH (in_pathname)) { /* First, get rid of any drive letters etc. */ while (!IS_DIR_SEPARATOR (*in_pathname)) in_pathname++; /* Next, get rid of all leading dir separators. */ while (IS_DIR_SEPARATOR (*in_pathname)) in_pathname++; } (The first while loop could have been written like your original suggestion, to have it consume the first dir separator also, but for consistency I did them both in the same style.) -- Orjan Friberg Axis Communications AB