[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

File.extname("foo bar") = " bar" .................?

ThoML

7/6/2008 3:25:00 PM

Hi,

I just realized that the result of

File.extname("foo bar")

is

=> " bar"

I have to admit this comes unexpected. In file.c, I found this

#if USE_NTFS
#define istrailinggabage(x) ((x) == '.' || (x) == ' ')
#else
#define istrailinggabage(x) 0
#endif

and

#if defined _WIN32 || defined __CYGWIN__
#define USE_NTFS 1
#else
#define USE_NTFS 0
#endif

Is this intentional? Could somebody please explain.

This is on
ruby 1.8.7 (2008-06-20 patchlevel 22) [i386-cygwin]
and
ruby 1.9.0 (2008-06-20 revision 17482) [i386-cygwin]

With ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32] the result is
closer to what I'd expect:
$ /cygdrive/c/ruby/bin/ruby -e "p File.extname('foo bar')"
""

Thanks,
Thomas.
1 Answer

Nobuyoshi Nakada

7/6/2008 4:26:00 PM

0

Hi,

At Mon, 7 Jul 2008 00:26:39 +0900,
ThoML wrote in [ruby-talk:307404]:
> I just realized that the result of
>
> File.extname("foo bar")
>
> is
>
> => " bar"

Thank you, fixed now.

--
Nobu Nakada