Professional Web Applications Themes

File.fnmatch's behavior - Ruby

Hi, rubyists. I'm now thinking of File.fnmatch's behavior. I've read [ruby-dev:16555] and agreed the point "It sounds good to me that FNM_PATHNAME behavior is default (and introduce oposite flag like FNM_SLASHMATCH), and '**/' is implemented." Is this change acceptable? And current bracket expression's behavior is similer to ruby's regular expression and differs from SUSv3. Current: File.fnmatch("[a/c]", "a", FNM_PATHNAME) # => true (ignore '/' in bracket expression) File.fnmatch("[\*]", "\") # => false (\ is escaping character) File.fnmatch("[\*]", "*") # => true SUSv3: File.fnmatch("[a/c]", "a", FNM_PATHNAME) # => false ('/' has supiority over bracket expression) File.fnmatch("[a/c]", "[a/c]", FNM_PATHNAME) # => true (so, ...

  1. #1

    Default File.fnmatch's behavior

    Hi, rubyists.

    I'm now thinking of File.fnmatch's behavior.
    I've read [ruby-dev:16555] and agreed the point

    "It sounds good to me that FNM_PATHNAME behavior is default (and introduce oposite flag like FNM_SLASHMATCH),
    and '**/' is implemented."

    Is this change acceptable?

    And current bracket expression's behavior is similer to ruby's regular expression and differs from SUSv3.

    Current:
    File.fnmatch("[a/c]", "a", FNM_PATHNAME) # => true (ignore '/' in bracket expression)
    File.fnmatch("[\\*]", "\\") # => false (\ is escaping character)
    File.fnmatch("[\\*]", "*") # => true

    SUSv3:
    File.fnmatch("[a/c]", "a", FNM_PATHNAME) # => false ('/' has supiority over bracket expression)
    File.fnmatch("[a/c]", "[a/c]", FNM_PATHNAME) # => true (so, '[a' is handled like ordinary character)
    File.fnmatch("[\\*]", "\\") # => true (\ is ordinary character)
    File.fnmatch("[\\*]", "*") # => true

    Which one is prefered?

    Any comments will be appreciated.

    Regards,

    Yamamoto.



    H.Yamamoto Guest

  2. #2

    Default Re: File.fnmatch's behavior

    > Hi, rubyists. 

    I like it. fnmatch is one of those few methods whose doentation I have
    to look up every time I use it. And then it doesn't do what I want, so I
    need to experiment with irb.

    Your proposal seems a step in the right direction. I'd like to see some
    "real-world" examples, rather than the "a/b" stuff, though.

    Cheers,
    Gavin




    Gavin Guest

  3. #3

    Default Re: File.fnmatch's behavior

    Thanks, Gavin.
     
    >
    >I like it. fnmatch is one of those few methods whose doentation I have
    >to look up every time I use it. And then it doesn't do what I want, so I
    >need to experiment with irb.[/ref]

    I'm glad to here that.
     

    I've already written dir.c to replace "ruby-1.9.0(2004-02-23) Rev1.107".
    Maybe this can help you.

    Regards,
    Yamamoto


    H.Yamamoto Guest

  4. #4

    Default Re: File.fnmatch's behavior

    Sorry, I fogot to tell you where it is...

    http://www.ccsnet.ne.jp/~ocean/23007/dir.c

    Regards,
    Yamamoto


    H.Yamamoto Guest

  5. #5

    Default Re: File.fnmatch's behavior

    Hi.

    **/ is not implemented yet. I'll implement it soon.

    Regard.
    Yamamoto



    H.Yamamoto Guest

  6. #6

    Default Re: File.fnmatch's behavior

    Hi, rubyists.

    I implemented fnmatch. I did some change to behavior, so I want to know whether
    this is acceptable as File.fnmatch in ruby1.9 or not.

    Changed feature is...

    * Followed SUSv3 pattern handling.

    * Undefine FNM_PATHNAME and define oposite flag FNM_SEPMATCH.

    * '**/' is supported when FNM_SEPMATCH is not set.

    * Only '/' is accepted as path separator.

    * Faster '*' expansion.

    Still open issue is... [ruby-dev:23029]

    * Should File.fnmatch('**/test/', '/b/c/test/') match or not?
    * Should File.fnmatch('**/test/', '../test/') match or not?

    C file's location is

    http://www.ccsnet.ne.jp/~ocean/23030/fnmatch.c

    Please try it and comment about it.

    Regards,

    Yamamoto.


    H.Yamamoto Guest

Similar Threads

  1. where's the webservice behavior file ?
    By Lee_Nover in forum ASP.NET Web Services
    Replies: 0
    Last Post: September 29th, 04:51 AM
  2. Log file of shockwave behavior
    By Diego in forum Macromedia Director Lingo
    Replies: 0
    Last Post: December 8th, 11:00 PM
  3. *Very* strange file behavior...
    By Mike in forum Mac Programming
    Replies: 2
    Last Post: October 7th, 02:11 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139