public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix fnmatch escape handling in brackets (BZ #361)
@ 2004-09-01 21:27 Jakub Jelinek
  2004-09-02  3:38 ` Ulrich Drepper
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2004-09-01 21:27 UTC (permalink / raw)
  To: Ulrich Drepper; +Cc: Glibc hackers, Markus Oberhumer

Hi!

When FNM_NOESCAPE is not set, [\\-a] is a range from backslash to a,
while glibc was not handling this as a range.
I've added 25 tests, without the fnmatch_loop.c patch 6 of them fail.
I have not been able to reproduce any problems when backslash is in the end
of range nor I saw any obvious problems in the code related to this.
Markus, if you see problems with some other pattern, can you please provide
testcase for it?

2004-09-01  Jakub Jelinek  <jakub@redhat.com>

	[BZ #361]
	* posix/fnmatch_loop.c (FCT): For backslash between brackets, branch
	to normal_bracket after fetching the next character.
	* posix/tst-fnmatch.input: Add 25 new tests.
	Reported by Markus Oberhumer <markus@oberhumer.com>.

--- libc/posix/fnmatch_loop.c.jj	2003-06-13 22:54:18.000000000 +0200
+++ libc/posix/fnmatch_loop.c	2004-09-01 22:44:18.309301655 +0200
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991,1992,1993,1996,1997,1998,1999,2000,2001,2003
+/* Copyright (C) 1991,1992,1993,1996,1997,1998,1999,2000,2001,2003,2004
 	Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -242,8 +242,7 @@ FCT (pattern, string, string_end, no_lea
 		    c = FOLD ((UCHAR) *p);
 		    ++p;
 
-		    if (c == fn)
-		      goto matched;
+		    goto normal_bracket;
 		  }
 		else if (c == L('[') && *p == L(':'))
 		  {
--- libc/posix/tst-fnmatch.input.jj	2001-10-27 04:37:27.000000000 +0200
+++ libc/posix/tst-fnmatch.input	2004-09-01 23:15:28.962236860 +0200
@@ -1,5 +1,5 @@
 # Tests for fnmatch.
-# Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+# Copyright (C) 2000, 2001, 2004 Free Software Foundation, Inc.
 # This file is part of the GNU C Library.
 # Contributes by Ulrich Drepper <drepper@redhat.com>.
 #
@@ -389,6 +389,31 @@ C		"az"			"[-a]z"		       0
 C		"bz"			"[-ab]z"	       0
 C		"cz"			"[-ab]z"	       NOMATCH
 C		"-z"			"[-ab]z"	       0
+C		"\\"			"[\\\\-a]"	       0
+C		"_"			"[\\\\-a]"	       0
+C		"a"			"[\\\\-a]"	       0
+C		"-"			"[\\\\-a]"	       NOMATCH
+C		"\\"			"[\\]-a]"	       NOMATCH
+C		"_"			"[\\]-a]"	       0
+C		"a"			"[\\]-a]"	       0
+C		"]"			"[\\]-a]"	       0
+C		"-"			"[\\]-a]"	       NOMATCH
+C		"\\"			"[!\\\\-a]"	       NOMATCH
+C		"_"			"[!\\\\-a]"	       NOMATCH
+C		"a"			"[!\\\\-a]"	       NOMATCH
+C		"-"			"[!\\\\-a]"	       0
+C		"!"			"[\\!-]"	       0
+C		"-"			"[\\!-]"	       0
+C		"\\"			"[\\!-]"	       NOMATCH
+C		"Z"			"[Z-\\\\]"	       0
+C		"["			"[Z-\\\\]"	       0
+C		"\\"			"[Z-\\\\]"	       0
+C		"-"			"[Z-\\\\]"	       NOMATCH
+C		"Z"			"[Z-\\]]"	       0
+C		"["			"[Z-\\]]"	       0
+C		"\\"			"[Z-\\]]"	       0
+C		"]"			"[Z-\\]]"	       0
+C		"-"			"[Z-\\]]"	       NOMATCH
 
 # Following are tests outside the scope of IEEE 2003.2 since they are using
 # locales other than the C locale.  The main focus of the tests is on the

	Jakub

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix fnmatch escape handling in brackets (BZ #361)
  2004-09-01 21:27 [PATCH] Fix fnmatch escape handling in brackets (BZ #361) Jakub Jelinek
@ 2004-09-02  3:38 ` Ulrich Drepper
  0 siblings, 0 replies; 2+ messages in thread
From: Ulrich Drepper @ 2004-09-02  3:38 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Glibc hackers

Applied.

-- 
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-09-02  3:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-01 21:27 [PATCH] Fix fnmatch escape handling in brackets (BZ #361) Jakub Jelinek
2004-09-02  3:38 ` Ulrich Drepper

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).