comp.lang.ada
 help / color / mirror / Atom feed
Subject: Re: Ada.Directories.Base_Name and dot files
Date: Thu, 08 Oct 2009 11:58:01 +0200
Date: 2009-10-08T11:58:01+02:00	[thread overview]
Message-ID: <4acdb7aa$0$283$14726298@news.sunsite.dk> (raw)
In-Reply-To: <uhbua1ayz.fsf@stephe-leake.org>

Stephen Leake wrote:
> Thomas L�cke <"tl at ada-dk.org"> writes:
> 
>> begin
>>    IO.Put_Line (Item => "1: " & D.Base_Name (Name => "foo.txt"));
>>    IO.Put_Line (Item => "2: " & D.Base_Name (Name => ".foo"));
>>    IO.Put_Line (Item => "3: " & D.Base_Name (Name => ".foo.bar"));
>> end Dot;
>> ++++
>>
>> The output I get is this:
>>
>> ++++
>> 1: foo
>> 2:
>> 3: .foo
>> ++++
>>
>> What I had hoped for, was this:
>>
>> ++++
>> 1: foo
>> 2: .foo
>> 3: .foo
>> ++++
> 
> Just out of curiosity, what made you hope for this? The Gnu coreutils
> basename function doesn't do what you want, either:


Yes, that was actually a typo. I was hoping for the same behavior as 
basename, as shown in your output below.

In my haste, I just forgot to add the .bar part to output line 3: .foo

I was too focused on the second line, where .foo was completely 
eliminated.


> 
> $ basename foo.txt
> foo.txt
> $ basename foo.txt .txt
> foo
> $ basename .foo
> .foo
> $ basename .foo .foo
> .foo
> $ basename .foo.bar
> .foo.bar
> $ basename .foo.bar .bar
> .foo
> $ basename .foo.bar .foo
> .foo.bar
> $ basename .foo.bar .foo.bar
> .foo.bar
> 
> 
>> With the current null string solution, you'd have to do some manual
>> parsing to get to the actual basename of a dot file.
> 
> What is your definition of "the actual basename"?


On my Linux system, my definition of the basename, is the name returned 
by basename.


> 
>> Is there a good reason for the current behavior?
> 
> It's well-defined. And it does what I want :).
> 

I've read the link posted by Adam, and it has made me a lot wiser in 
regards to this issue. I feel I now have a better understanding of why 
Ada.Directories.Base_Name does what it does.

So I guess I now also think that it is both well-defined and that it 
does what I didn't knew I wanted.  :o)

-- 
Regards,
Thomas L�cke

Email: tl at ada-dk.org
Web: http:ada-dk.org
IRC nick: ThomasLocke



  reply	other threads:[~2009-10-08  9:58 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-07 12:40 Ada.Directories.Base_Name and dot files 
2009-10-07 14:46 ` Yannick Duchêne Hibou57
2009-10-07 17:06   ` 
2009-10-07 14:52 ` Adam Beneschan
2009-10-07 17:06   ` 
2009-10-07 15:10 ` Adam Beneschan
2009-10-07 15:37   ` Yannick Duchêne Hibou57
2009-10-11  2:39     ` Randy Brukardt
2009-10-07 20:11   ` 
2009-10-08  9:39 ` Stephen Leake
2009-10-08  9:58   `  [this message]
2009-10-26 19:26     ` Type casting Bruno
2009-10-26 20:02       ` Jeffrey R. Carter
2009-10-26 20:09       ` Adam Beneschan
2009-10-26 19:27     ` Conversions Bruno
2009-10-26 20:09       ` Conversions Jeffrey R. Carter
2009-10-26 20:19       ` Conversions Adam Beneschan
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox