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

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.

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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs