From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: libc-alpha@sourceware.org
Subject: Re: [PATCH] Fix handling of collating elements in fnmatch (bug 17396, bug 16976)
Date: Wed, 09 Jan 2019 13:35:00 -0000 [thread overview]
Message-ID: <a172fddf-f3c2-5ba1-a170-7ca82cc8c03b@linaro.org> (raw)
In-Reply-To: <mvmo98qezmh.fsf@suse.de>
On 09/01/2019 11:20, Andreas Schwab wrote:
> diff --git a/sysdeps/s390/wmemcmp.c b/posix/tst-fnmatch4.c
> similarity index 52%
> copy from sysdeps/s390/wmemcmp.c
> copy to posix/tst-fnmatch4.c
> index ec0b4027f8..dc13f89288 100644
> --- a/sysdeps/s390/wmemcmp.c
> +++ b/posix/tst-fnmatch4.c
> @@ -1,5 +1,5 @@
> -/* Multiple versions of wmemcmp.
> - Copyright (C) 2015-2019 Free Software Foundation, Inc.
> +/* Test for fnmatch handling of collating elements
> + Copyright (C) 2019 Free Software Foundation, Inc.
> This file is part of the GNU C Library.
>
> The GNU C Library is free software; you can redistribute it and/or
> @@ -16,23 +16,35 @@
> License along with the GNU C Library; if not, see
> <http://www.gnu.org/licenses/>. */
>
> -#include <ifunc-wmemcmp.h>
> -
> -#if HAVE_WMEMCMP_IFUNC
> -# include <wchar.h>
> -# include <ifunc-resolve.h>
> -
> -# if HAVE_WMEMCMP_C
> -extern __typeof (wmemcmp) WMEMCMP_C attribute_hidden;
> -# endif
> -
> -# if HAVE_WMEMCMP_Z13
> -extern __typeof (wmemcmp) WMEMCMP_Z13 attribute_hidden;
> -# endif
> -
> -s390_libc_ifunc_expr (wmemcmp, wmemcmp,
> - (HAVE_WMEMCMP_Z13 && (hwcap & HWCAP_S390_VX))
> - ? WMEMCMP_Z13
> - : WMEMCMP_DEFAULT
> - )
> -#endif
> +#include <stdio.h>
> +#include <locale.h>
> +#include <fnmatch.h>
> +
> +static int
> +do_test_locale (const char *locale)
> +{
> + const char *pattern = "[[.ch.]]";
> +
> + if (setlocale (LC_ALL, locale) == NULL)
> + {
> + printf ("could not set locale %s\n", locale);
> + return 1;
> + }
> +
> + if (fnmatch (pattern, "ch", 0) != 0)
> + {
> + printf ("%s didn't match in locale %s\n", pattern, locale);
> + return 1;
> + }
> +
> + return 0;
> +}
Maybe TEST_COMPARE on both check?
> +
> +static int
> +do_test (void)
> +{
> + return (do_test_locale ("cs_CZ.ISO-8859-2")
> + || do_test_locale ("cs_CZ.UTF-8"));
> +}
> +
> +#include <support/test-driver.c>
> diff --git a/posix/tst-fnmatch5.c b/posix/tst-fnmatch5.c
> new file mode 100644
> index 0000000000..5ebff1f424
> --- /dev/null
> +++ b/posix/tst-fnmatch5.c
> @@ -0,0 +1,52 @@
> +/* Test for fnmatch handling of collating elements
> + Copyright (C) 2019 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <http://www.gnu.org/licenses/>. */
> +
> +#include <fnmatch.h>
> +#include <locale.h>
> +#include <stdio.h>
> +#include <string.h>
> +
> +#define LENGTH 20000000
> +
> +static char pattern[LENGTH + 7];
> +
> +static int
> +do_test (void)
> +{
> + if (setlocale (LC_ALL, "en_US.UTF-8") == NULL)
> + {
> + puts ("could not set locale");
> + return 1;
> + }
> + pattern[0] = '[';
> + pattern[1] = '[';
> + pattern[2] = '.';
> + memset (pattern + 3, 'a', LENGTH);
> + pattern[LENGTH + 3] = '.';
> + pattern[LENGTH + 4] = ']';
> + pattern[LENGTH + 5] = ']';
> + int ret = fnmatch (pattern, "a", 0);
> + if (ret == 0)
> + {
> + puts ("fnmatch returned 0 for invalid pattern");
> + return 1;
> + }
> + return 0;
> +}
> +
> +#include <support/test-driver.c>
Same as before.
next prev parent reply other threads:[~2019-01-09 13:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-11 15:55 Andreas Schwab
2019-01-07 15:26 ` Florian Weimer
2019-01-09 13:20 ` Andreas Schwab
2019-01-09 13:35 ` Adhemerval Zanella [this message]
2019-01-09 14:32 ` Andreas Schwab
2019-01-09 18:33 ` Adhemerval Zanella
2019-01-10 8:43 ` Andreas Schwab
2019-01-10 12:25 ` Adhemerval Zanella
2019-01-10 13:20 ` Andreas Schwab
2019-01-09 14:05 ` Florian Weimer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a172fddf-f3c2-5ba1-a170-7ca82cc8c03b@linaro.org \
--to=adhemerval.zanella@linaro.org \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).