musl/src/regex/fnmatch.c, branch master musl - an implementation of the standard library for Linux-based systems byte-based C locale, phase 1: multibyte character handling functions 2015年06月16日T05:28:48+00:00 Rich Felker dalias@aerifal.cx 2015年06月16日T04:44:17+00:00 1507ebf837334e9e07cfab1ca1c2e88449069a80 this patch makes the functions which work directly on multibyte characters treat the high bytes as individual abstract code units rather than as multibyte sequences when MB_CUR_MAX is 1. since MB_CUR_MAX is presently defined as a constant 4, all of the new code added is dead code, and optimizing compilers' code generation should not be affected at all. a future commit will activate the new code. as abstract code units, bytes 0x80 to 0xff are represented by wchar_t values 0xdf80 to 0xdfff, at the end of the surrogates range. this ensures that they will never be misinterpreted as Unicode characters, and that all wctype functions return false for these "characters" without needing locale-specific logic. a high range outside of Unicode such as 0x7fffff80 to 0x7fffffff was also considered, but since C11's char16_t also needs to be able to represent conversions of these bytes, the surrogate range was the natural choice.
this patch makes the functions which work directly on multibyte
characters treat the high bytes as individual abstract code units
rather than as multibyte sequences when MB_CUR_MAX is 1. since
MB_CUR_MAX is presently defined as a constant 4, all of the new code
added is dead code, and optimizing compilers' code generation should
not be affected at all. a future commit will activate the new code.
as abstract code units, bytes 0x80 to 0xff are represented by wchar_t
values 0xdf80 to 0xdfff, at the end of the surrogates range. this
ensures that they will never be misinterpreted as Unicode characters,
and that all wctype functions return false for these "characters"
without needing locale-specific logic. a high range outside of Unicode
such as 0x7fffff80 to 0x7fffffff was also considered, but since C11's
char16_t also needs to be able to represent conversions of these
bytes, the surrogate range was the natural choice.
implement FNM_CASEFOLD extension to fnmatch function 2014年12月17日T19:54:37+00:00 Nagy Szabolcs nsz@port70.net 2014年10月10日T10:09:03+00:00 efa9d396f9d3af6c6f85ec86302b48206c574a38
implement FNM_LEADING_DIR extension flag in fnmatch 2013年12月02日T07:08:41+00:00 Rich Felker dalias@aerifal.cx 2013年12月02日T07:08:41+00:00 a4e10e304d54c6ac3c12db08774ef74a978a2073 previously this flag was defined and accepted as a no-op, possibly breaking some software that uses it. given the choice to remove the definition and possibly break applications that were already working, or simply implement the feature, the latter turned out to be easy enough to make the decision easy. in the case where the FNM_PATHNAME flag is also set, this implementation is clean and essentially optimal. otherwise, it's an inefficient "brute force" implementation. at some point, when cleaning up and refactoring this code, I may add a more direct code path for handling FNM_LEADING_DIR in the non-FNM_PATHNAME case, but at this point my main interest is avoiding introducing new bugs in the code that implements the standard fnmatch features specified by POSIX.
previously this flag was defined and accepted as a no-op, possibly
breaking some software that uses it. given the choice to remove the
definition and possibly break applications that were already working,
or simply implement the feature, the latter turned out to be easy
enough to make the decision easy.
in the case where the FNM_PATHNAME flag is also set, this
implementation is clean and essentially optimal. otherwise, it's an
inefficient "brute force" implementation. at some point, when cleaning
up and refactoring this code, I may add a more direct code path for
handling FNM_LEADING_DIR in the non-FNM_PATHNAME case, but at this
point my main interest is avoiding introducing new bugs in the code
that implements the standard fnmatch features specified by POSIX.
fix fnmatch corner cases related to escaping 2013年12月01日T19:36:22+00:00 Rich Felker dalias@aerifal.cx 2013年12月01日T19:36:22+00:00 6ec82a3b58ee1b873ff0dfad8fa9d41c3d25dcc0 the FNM_PATHNAME logic for advancing by /-delimited components was incorrect when the / character was escaped (i.e. \/), and a final \ at the end of pattern was not handled correctly.
the FNM_PATHNAME logic for advancing by /-delimited components was
incorrect when the / character was escaped (i.e. \/), and a final \ at
the end of pattern was not handled correctly.
fix the end of string matching in fnmatch with FNM_PATHNAME 2013年12月01日T17:32:48+00:00 Szabolcs Nagy nsz@port70.net 2013年12月01日T17:32:48+00:00 da0fcdb8e913ca7cdf8931328f2b37e93309b2c5 a '/' in the pattern could be incorrectly matched against the terminating null byte in the string causing arbitrarily long sequence of out-of-bounds access in fnmatch("/","",FNM_PATHNAME)
a '/' in the pattern could be incorrectly matched against the
terminating null byte in the string causing arbitrarily long
sequence of out-of-bounds access in fnmatch("/","",FNM_PATHNAME)
new fnmatch implementation 2012年04月28日T22:05:29+00:00 Rich Felker dalias@aerifal.cx 2012年04月28日T22:05:29+00:00 45b38550eec7de580d790440154791c67cae8475 unlike the old one, this one's algorithm does not suffer from potential stack overflow issues or pathologically bad performance on certain patterns. instead of backtracking, it uses a matching algorithm which I have not seen before (unsure whether I invented or re-invented it) that runs in O(1) space and O(nm) time. it may be possible to improve the time to O(n), but not without significantly greater complexity.
unlike the old one, this one's algorithm does not suffer from
potential stack overflow issues or pathologically bad performance on
certain patterns. instead of backtracking, it uses a matching
algorithm which I have not seen before (unsure whether I invented or
re-invented it) that runs in O(1) space and O(nm) time. it may be
possible to improve the time to O(n), but not without significantly
greater complexity.
update fnmatch to POSIX 2008 semantics 2012年04月26日T16:24:44+00:00 Rich Felker dalias@aerifal.cx 2012年04月26日T16:24:44+00:00 2b87a5db82833c6d148b70d29a33cd51fff491e3 an invalid bracket expression must be treated as if the opening bracket were just a literal character. this is to fix a bug whereby POSIX left the behavior of the "[" shell command undefined due to it being an invalid bracket expression.
an invalid bracket expression must be treated as if the opening
bracket were just a literal character. this is to fix a bug whereby
POSIX left the behavior of the "[" shell command undefined due to it
being an invalid bracket expression.
eliminate (harmless in this case) vla usage in fnmatch.c 2011年06月05日T17:30:56+00:00 Rich Felker dalias@aerifal.cx 2011年06月05日T17:30:56+00:00 a6c399cf62bbd88f0f0142fd3e9e1e72bd093bc3
initial check-in, version 0.5.0 2011年02月12日T05:22:29+00:00 Rich Felker dalias@aerifal.cx 2011年02月12日T05:22:29+00:00 0b44a0315b47dd8eced9f3b7f31580cf14bbfc01

AltStyle によって変換されたページ (->オリジナル) /