From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11543 invoked by alias); 8 Mar 2011 18:51:22 -0000 Received: (qmail 11516 invoked by uid 22791); 8 Mar 2011 18:51:21 -0000 X-SWARE-Spam-Status: No, hits=-1.1 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST X-Spam-Check-By: sourceware.org Received: from mail-qy0-f176.google.com (HELO mail-qy0-f176.google.com) (209.85.216.176) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 08 Mar 2011 18:51:16 +0000 Received: by qyk30 with SMTP id 30so5228859qyk.0 for ; Tue, 08 Mar 2011 10:51:14 -0800 (PST) MIME-Version: 1.0 Received: by 10.229.135.82 with SMTP id m18mr1830436qct.82.1299610274445; Tue, 08 Mar 2011 10:51:14 -0800 (PST) Received: by 10.229.89.197 with HTTP; Tue, 8 Mar 2011 10:51:14 -0800 (PST) In-Reply-To: <838vwph30i.fsf@gnu.org> References: <201103081243.34340.pedro@codesourcery.com> <201103081333.03177.pedro@codesourcery.com> <838vwph30i.fsf@gnu.org> Date: Tue, 08 Mar 2011 18:51:00 -0000 Message-ID: Subject: Re: [patch libiberty include]: Add additional helper functions for directory-separator searching From: Kai Tietz To: Eli Zaretskii Cc: Pedro Alves , gdb-patches@sourceware.org, gcc-patches@gcc.gnu.org, binutils@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2011-03/txt/msg00130.txt.bz2 2011/3/8 Eli Zaretskii : >> From: Pedro Alves >> Date: Tue, 8 Mar 2011 13:33:02 +0000 >> Cc: Kai Tietz , >> =A0gcc-patches@gcc.gnu.org, >> =A0Eli Zaretskii , >> =A0binutils@sourceware.org >> >> On Tuesday 08 March 2011 12:48:11, Kai Tietz wrote: >> >> > Well, a better example is elfstab_offset_sections() in elfread.c. >> >> =A0 /* The ELF symbol info doesn't include path names, so strip the path >> =A0 =A0 =A0(if any) from the psymtab filename. =A0*/ >> =A0 while (0 !=3D (p =3D strchr (filename, '/'))) >> =A0 =A0 filename =3D p + 1; >> >> Looks like its looking for the last path separator, so >> it might as well use filename_dirrchr instead. > > Exactly. > >> > Another is in find_file_and_directory() in dwarf2read.c file. >> >> Workaround for Irix. =A0Certainly that '/' should not depend >> on the host gdb is running on. > > It actually should use IS_ABSOLUTE_FILE_NAME, if any portability > enhancement is needed here. > > In my experience, the strchr analog is not needed, only the strrchr > one (which could be used quite a lot). =A0The few places that use strchr > now should actually be rewritten to search from the end, because > that's what they need. > Here I am not that sure. For example in gcc's gengtype.c (read_input_list) is a use-case for strchr on filenames, which can't be expressed by strrchr. Please be aware that libiberty is shared between different ventures. I admit that filenames/paths are searched normal from right to left. But there might be cases a left to right search is suitable. Regards, Kai