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

Discussion in 'Ruby' started by ThoML, Jul 6, 2008.

  1. ThoML

    ThoML Guest

    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.
     
    ThoML, Jul 6, 2008
    #1
    1. Advertisements

  2. Hi,

    At Mon, 7 Jul 2008 00:26:39 +0900,
    ThoML wrote in [ruby-talk:307404]:
    Thank you, fixed now.
     
    Nobuyoshi Nakada, Jul 6, 2008
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.