diff options
author | Ulrich Drepper <drepper@redhat.com> | 2002-07-10 23:09:16 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2002-07-10 23:09:16 +0000 |
commit | 81c64d407c82933f18dc09de9bf58cc76d6a6148 (patch) | |
tree | 25a6b5492c2edae9d761ca208d147d726d516804 /posix/bug-regex6.c | |
parent | f4741da2e730191150e4394237716fb29d61845c (diff) | |
download | glibc-81c64d407c82933f18dc09de9bf58cc76d6a6148.tar.gz glibc-81c64d407c82933f18dc09de9bf58cc76d6a6148.tar.xz glibc-81c64d407c82933f18dc09de9bf58cc76d6a6148.zip |
Update.
2002-07-10 Ulrich Drepper <drepper@redhat.com> * Versions.def [libpthread]: Add GLIBC_2.2.6. * posix/Versions [libc] (GLIBC_2.2.6): Add __nanosleep. 2002-07-06 Bruno Haible <bruno@clisp.org> * sysdeps/unix/sysv/sysv4/bits/sigset.h (__NSSBITS): Correct value. * sysdeps/unix/sysv/linux/bits/statvfs.h (ST_NODIRATIME): Set to 2048.
Diffstat (limited to 'posix/bug-regex6.c')
-rw-r--r-- | posix/bug-regex6.c | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/posix/bug-regex6.c b/posix/bug-regex6.c new file mode 100644 index 0000000000..9a06898a26 --- /dev/null +++ b/posix/bug-regex6.c @@ -0,0 +1,74 @@ +/* Test for regexec. + Copyright (C) 2002 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek <jakub@redhat.com>, 2002. + + 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, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <sys/types.h> +#include <regex.h> +#include <locale.h> +#include <stdio.h> + +int +main (int argc, char *argv[]) +{ + regex_t re; + regmatch_t mat[10]; + int i, j, ret = 0; + char *locales[] = { "C", "de_DE.UTF-8" }; + char *string = "http://www.regex.com/pattern/matching.html#intro"; + regmatch_t expect[10] = { + { 0, 48 }, { 0, 5 }, { 0, 4 }, { 5, 20 }, { 7, 20 }, { 20, 42 }, + { -1, -1 }, { -1, -1 }, { 42, 48 }, { 43, 48 } }; + + for (i = 0; i < sizeof (locales) / sizeof (locales[0]); ++i) + { + if (setlocale (LC_ALL, locales[i]) == NULL) + { + puts ("cannot set locale"); + ret = 1; + } + else if (regcomp (&re, + "^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?", + REG_EXTENDED) != REG_NOERROR) + { + puts ("cannot compile expression \"[a-f]*\""); + ret = 1; + } + else if (regexec (&re, string, 10, mat, 0) == REG_NOMATCH) + { + puts ("no match"); + ret = 1; + } + else + { + if (! memcmp (mat, expect, sizeof (mat))) + printf ("matching ok for %s locale\n", locales[i]); + else + { + printf ("matching failed for %s locale:\n", locales[i]); + ret = 1; + for (j = 0; j < 9; ++j) + if (mat[j].rm_so != -1) + printf ("%d: %.*s\n", j, mat[j].rm_eo - mat[j].rm_so, + string + mat[j].rm_so); + } + } + } + + return ret; +} |