cybernoid / archivemount

A fuse filesystem for mounting archives in formats supported by libarchive.
Other
184 stars 19 forks source link

Pass REG_ENHANCED to regcomp where available #6

Closed mjfwalsh closed 4 years ago

mjfwalsh commented 4 years ago

On MacOS -o subtree=<regexp> currently fails as \? only has a special meaning if the REG_ENHANCED flag is passed to regcomp.

cybernoid commented 4 years ago

I have no way to test that since I have no Mac, but it's a one-liner, so I trust it will do what you say. Thanks!

mjfwalsh commented 4 years ago

Happy to help. It's just one of those differences between regex implementations.

This is what Apple's re_format(7) manpage says:

ENHANCED FEATURES
     When the REG_ENHANCED flag is passed to one of the regcomp() variants, additional features are
     activated.  Like the enhanced regex implementations in scripting languages such as perl(1) and
     python(1), these additional features may conflict with the IEEE Std 1003.2 (``POSIX.2'') stan-
     dards in some ways.  Use this with care in situations which require portability (including to
     past versions of the Mac OS X using the previous regex implementation).

     For enhanced basic REs, `+', `?' and `|' remain regular characters, but `\+', `\?' and `\|' have
     the same special meaning as the unescaped characters do for extended REs, i.e., one or more
     matches, zero or one matches and alteration, respectively.  For enhanced extended REs, back ref-
     erences are available.  Additional enhanced features are listed below.

Given the option I'd probably go for an extended regex instead:

#define PREFIX      "(^/|^\\./|^)"