Opened 17 years ago
Closed 13 years ago
#193 closed defect (fixed)
fnmatch() implementation is broken
Reported by: | guest | Owned by: | bird |
---|---|---|---|
Priority: | normal | Milestone: | libc-0.6.5 |
Component: | libc | Version: | 0.6 |
Severity: | normal | Keywords: | |
Cc: |
Description
According to http://www.opengroup.org/onlinepubs/000095399/functions/fnmatch.html[[BR]]
If string matches the pattern specified by pattern, then fnmatch() shall return 0. If there is no match, fnmatch() shall return FNM_NOMATCH, which is defined in <fnmatch.h>. If an error occurs, fnmatch() shall return another non-zero value.
FNM_NOMATCH is defined in fnmatch.h as
#define FNM_NOMATCH 1
but fnmatch() return 2 in case of string is not match to pattern.
Testcase attached here
#include <stdio.h> #include <fnmatch.h> int main() { const char pat[]= "a"; const char string[]= "__nargin__"; int flags= FNM_PATHNAME|FNM_NOESCAPE|FNM_PERIOD; printf("fnmatch(\"%s\", \"%s\", %d) return %d\n", pat, string, flags, fnmatch(pat, string, flags) ); }
Output should be like
fnmatch("a", "__nargin__", 7) return 1
While with current libc implementation it is
fnmatch("a", "__nargin__", 7) return 2
Working implementation can be taken here http://www.koders.com/c/fid9017D6D4B610AB3B4FB492C9229D41676C2FAA78.aspx?s=md5
Change History (6)
comment:1 by , 17 years ago
comment:2 by , 17 years ago
Milestone: | → libc-0.6.4 |
---|---|
Version: | → 0.6 |
comment:3 by , 14 years ago
Status: | new → assigned |
---|
comment:4 by , 13 years ago
The problem here is header confusion. For some reason I don't recall/know, fnmatch.h and emx/fnmatch.h differs constant wise but ends up in the same EMX code. So, when using the GNU liberty header the EMX code will choke and return _FNM_ERR (2).
comment:6 by , 13 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Was tested with libc05 and libc063 versions