This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

bug: posix/fnmatch_loop.c ?


Dear glibc developers,

I wonder posix/fnmatch_loop.c has a bug.
Following program said [[.a.]] didn't match with 'a' in en_US.UTF-8.

I think attached patch can fix it.

#include <locale.h>
#include <fnmatch.h>

int main()
{
  char *pat = "[[.a.]]";
  char *stra = "a";
  int flag = 0;
  char* cloc;

  cloc = setlocale(LC_ALL, "C");
  printf("current locale: %s\n", cloc);
  printf("pat: %s, str: %s ->", pat, stra);
  printf("%s\n", fnmatch(pat, stra, flag)? "not match": "match");

  cloc = setlocale(LC_ALL, "en_US.UTF-8");
  printf("current locale: %s\n", cloc);
  printf("pat: %s, str: %s ->", pat, stra);
  printf("%s\n", fnmatch(pat, stra, flag)? "not match": "match");
}

Thanks,
--
Isamu Hasegawa
IBM Japan, Ltd.
--- posix/fnmatch_loop.c.orig	Thu Feb  1 10:07:14 2001
+++ posix/fnmatch_loop.c	Thu Feb  1 10:08:42 2001
@@ -531,7 +531,7 @@
 
 				c = *p++;
 			      }
-			    else if (symb_table[2 * elem] != 0 && c1 == 1)
+			    else if (symb_table[2 * elem] == 0 && c1 == 1)
 			      {
 				/* No valid character.  Match it as a
 				   single byte.  */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]