X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f X-Trace-PostClient-IP: 68.147.232.190 From: Brian Inglis Newsgroups: comp.os.msdos.djgpp Subject: Re: fnmatch("\\\\", "\\", 0) == 1 ??? Organization: Systematic Software Message-ID: References: <456dad03$0$486$cc7c7865 AT news DOT luth DOT se> <200611291634 DOT kATGYcbw010800 AT envy DOT delorie DOT com> X-Newsreader: Forte Agent 1.93/32.576 English (American) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 45 Date: Thu, 30 Nov 2006 05:42:21 GMT NNTP-Posting-Host: 64.59.135.176 X-Complaints-To: abuse AT shaw DOT ca X-Trace: pd7urf2no 1164865341 64.59.135.176 (Wed, 29 Nov 2006 22:42:21 MST) NNTP-Posting-Date: Wed, 29 Nov 2006 22:42:21 MST To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com fOn Wed, 29 Nov 2006 11:34:38 -0500 in comp.os.msdos.djgpp, DJ Delorie wrote: > >> This function indicates if STRING matches the PATTERN. ..." >> >> So DJGPP says that "\" doesn't match "\\" while Linux says it does. >> >> Well, I say DJGPP is right as the pattern says there should be two >> backslashes and you only provide one. > >Except that PATTERN is a regex influenced by FNM_NOESCAPE and >FNM_PATHNAME, and STRING isn't. So a pattern of "\\" is a single >escaped backslash, whereas a string of "\" is a single backslash. >They should match. switch ((c = *pattern++)) { ... ... ... case '\\': /*+++ pattern already post-incremented to point to next char */ if (!(flags & FNM_NOESCAPE) && pattern[1] && strchr("*?[\\", pattern[1])) /*+++ should be: if (!(flags & FNM_NOESCAPE) && strchr("*?[\\", *pattern)) *+++ as end of input pattern will match end char in escapes string */ { /*+++ end of input pattern might be clearer with ! or == '\0' */ if ((c = *pattern++) == 0) { c = '\\'; --pattern; } if (c != *string++) return FNM_NOMATCH; break; } -- Thanks. Take care, Brian Inglis Calgary, Alberta, Canada Brian DOT Inglis AT CSi DOT com (Brian[dot]Inglis{at}SystematicSW[dot]ab[dot]ca) fake address use address above to reply