From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Eli Zaretskii" To: orjan.friberg@axis.com Cc: gdb-patches@sources.redhat.com Subject: Re: [RFC]: Solib search (Was: Re: Cross solib support; continued) Date: Wed, 28 Nov 2001 08:37:00 -0000 Message-ID: <7458-Wed28Nov2001183554+0200-eliz@is.elta.co.il> 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> X-SW-Source: 2001-11/msg00535.html Message-ID: <20011128083700.vAMLzoRsNkJMzdPppv3-32_UWtzMP5m_xnZAvh74uoE@z> > Date: Wed, 28 Nov 2001 11:00:09 +0100 > From: Orjan Friberg > > > > while (!IS_DIR_SEPARATOR (*in_pathname++)) > > ; > > If I understand you correctly, your suggestion is: > > if (found_file < 0 && IS_ABSOLUTE_PATH (in_pathname)) > { > while (!IS_DIR_SEPARATOR (*in_pathname++)) > ; > } Yes, that's what I suggested. > 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? > To me it seems it should be something like: > > if (found_file < 0 && IS_ABSOLUTE_PATH (in_pathname)) > { > while (IS_DIR_SEPARATOR (*in_pathname)) > in_pathname++; > } > > (Can't use while (IS_DIR_SEPARATOR (*in_pathname++)) as it would > remove the first non-dir separator also.) No, I do think my code is right. Let me explain why. 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.