Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Kai Tietz <ktietz70@googlemail.com>
Cc: binutils@sourceware.org, gdb-patches@sourceware.org,
	gcc-patches@gcc.gnu.org
Subject: Re: [patch libiberty include]: Add additional helper functions for directory-separator searching
Date: Tue, 08 Mar 2011 12:01:00 -0000	[thread overview]
Message-ID: <E1PwvTi-0004AB-Mq@fencepost.gnu.org> (raw)
In-Reply-To: <AANLkTin72tEGAGdR2b38dyJe=XWRwnx7XOS2w6a=Mw9h@mail.gmail.com>	(message from Kai Tietz on Tue, 8 Mar 2011 12:25:37 +0100)

> Date: Tue, 8 Mar 2011 12:25:37 +0100
> From: Kai Tietz <ktietz70@googlemail.com>
> Cc: binutils@sourceware.org, gdb-patches@sourceware.org, 
> 	gcc-patches@gcc.gnu.org
> 
> > Btw, why do we need filename_dirchr?  The use case for
> > filename_dirrchr is clear, but in what situations will we need the
> > other one?
> 
> As the comment notes. strchr/strrchr searches for one character. This
> is for unix-file-system normally slash. On DOS based file-systems
> there are two characters representing a directory-separator. Slash and
> Backslash. Therefore this routine takes care that both are handled
> similiar to a single character searching.

We are miscommunicating.  I was asking when would a program want to
find the _first_ directory separator character in a file name.
Searching for the last one is a frequent use case: when you want to
create a file in the same directory as another, or when you are
looking for a basename of a file.  But when do you need the first
slash?

> >> +  if (!r || (r2 && r2 < r))
> >
> > Why do you test for r2 being non-NULL?  You are not going to
> > dereference it in the next comparison, and NULL is comparable as any
> > other value.
> 
> As if we found slash, we don't want to override function's result by
> backslash not found. If the null-check wouldn't be present condition
> would be always true for r2 == NULL as, NULL is always less then a
> pointer. But r shall be modified only if r2 (backslash) was found
> before r (slash).
> (same logic but here from right to left for the strrchr-case)

But in strrchr-case, r2 cannot be greater than r1 if it is NULL,
right?


  reply	other threads:[~2011-03-08 11:53 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-08 11:25 Kai Tietz
2011-03-08 11:53 ` Eli Zaretskii
2011-03-08 11:55   ` Kai Tietz
2011-03-08 12:01     ` Eli Zaretskii [this message]
2011-03-08 12:48       ` Kai Tietz
2011-03-08 13:25         ` Pedro Alves
2011-03-08 13:33           ` Kai Tietz
2011-03-08 14:30             ` Pedro Alves
2011-03-08 14:45               ` Kai Tietz
2011-03-08 18:49               ` Eli Zaretskii
2011-03-08 18:54                 ` Pedro Alves
2011-03-08 18:58                 ` Kai Tietz
2011-03-08 19:59                   ` Eli Zaretskii
     [not found] ` <E1Pwupb-0001ns-M8__47566.5626036518$1299582745$gmane$org@fencepost.gnu.org>
2011-03-08 12:43   ` Andreas Schwab
2011-03-08 16:52 ` Kai Tietz
2011-03-08 17:02   ` Kai Tietz
2011-03-08 18:39     ` Eli Zaretskii
2011-03-08 19:51       ` DJ Delorie
2011-03-08 22:38         ` Eli Zaretskii
2011-03-08 23:10         ` Pedro Alves
2011-03-09  7:12           ` Eli Zaretskii
2011-03-09 12:40             ` Pedro Alves
2011-03-09 12:54               ` Eli Zaretskii
2011-03-09 13:39                 ` Pedro Alves
2011-03-09 13:54                   ` Eli Zaretskii
2011-03-12 22:59                     ` Kai Tietz
2011-03-09 15:02                   ` Build regression [Re: [patch libiberty include]: Add additional helper functions for directory-separator searching] Jan Kratochvil
2011-03-09 15:40                     ` Pedro Alves
2011-03-09 16:09                       ` Jan Kratochvil
2011-03-13  1:09         ` [patch libiberty include]: Add additional helper functions for directory-separator searching Kai Tietz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1PwvTi-0004AB-Mq@fencepost.gnu.org \
    --to=eliz@gnu.org \
    --cc=binutils@sourceware.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=ktietz70@googlemail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox