diff options
author | Jakub Jelinek <jakub@redhat.com> | 2005-04-01 15:13:31 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2005-04-01 15:13:31 +0000 |
commit | e8eaba2b25948c0e60f70c33c5c52aad70bbf5fc (patch) | |
tree | 020566c0ffd2d27131ee7bac45eea5560a4732bd /posix | |
parent | e3166b6660ce5f0640242a4806a380bb651a2291 (diff) | |
download | glibc-e8eaba2b25948c0e60f70c33c5c52aad70bbf5fc.tar glibc-e8eaba2b25948c0e60f70c33c5c52aad70bbf5fc.tar.gz glibc-e8eaba2b25948c0e60f70c33c5c52aad70bbf5fc.tar.bz2 glibc-e8eaba2b25948c0e60f70c33c5c52aad70bbf5fc.zip |
Updated to fedora-glibc-20050401T1444
Diffstat (limited to 'posix')
-rw-r--r-- | posix/fnmatch.c | 79 | ||||
-rw-r--r-- | posix/tst-execle1.c | 3 | ||||
-rw-r--r-- | posix/tst-execle2.c | 3 |
3 files changed, 65 insertions, 20 deletions
diff --git a/posix/fnmatch.c b/posix/fnmatch.c index e409ed7300..3fa7c322d1 100644 --- a/posix/fnmatch.c +++ b/posix/fnmatch.c @@ -327,31 +327,74 @@ fnmatch (pattern, string, flags) { mbstate_t ps; size_t n; + const char *p; wchar_t *wpattern; wchar_t *wstring; /* Convert the strings into wide characters. */ memset (&ps, '\0', sizeof (ps)); - n = mbsrtowcs (NULL, &pattern, 0, &ps); - if (__builtin_expect (n == (size_t) -1, 0)) - /* Something wrong. - XXX Do we have to set `errno' to something which mbsrtows hasn't - already done? */ - return -1; - wpattern = (wchar_t *) alloca ((n + 1) * sizeof (wchar_t)); - assert (mbsinit (&ps)); - (void) mbsrtowcs (wpattern, &pattern, n + 1, &ps); + p = pattern; +#ifdef _LIBC + n = strnlen (pattern, 1024); +#else + n = strlen (pattern); +#endif + if (__builtin_expect (n < 1024, 1)) + { + wpattern = (wchar_t *) alloca ((n + 1) * sizeof (wchar_t)); + n = mbsrtowcs (wpattern, &p, n + 1, &ps); + if (__builtin_expect (n == (size_t) -1, 0)) + /* Something wrong. + XXX Do we have to set `errno' to something which mbsrtows hasn't + already done? */ + return -1; + if (p) + memset (&ps, '\0', sizeof (ps)); + } + if (__builtin_expect (p != NULL, 0)) + { + n = mbsrtowcs (NULL, &pattern, 0, &ps); + if (__builtin_expect (n == (size_t) -1, 0)) + /* Something wrong. + XXX Do we have to set `errno' to something which mbsrtows hasn't + already done? */ + return -1; + wpattern = (wchar_t *) alloca ((n + 1) * sizeof (wchar_t)); + assert (mbsinit (&ps)); + (void) mbsrtowcs (wpattern, &pattern, n + 1, &ps); + } assert (mbsinit (&ps)); - n = mbsrtowcs (NULL, &string, 0, &ps); - if (__builtin_expect (n == (size_t) -1, 0)) - /* Something wrong. - XXX Do we have to set `errno' to something which mbsrtows hasn't - already done? */ - return -1; - wstring = (wchar_t *) alloca ((n + 1) * sizeof (wchar_t)); - assert (mbsinit (&ps)); - (void) mbsrtowcs (wstring, &string, n + 1, &ps); +#ifdef _LIBC + n = strnlen (string, 1024); +#else + n = strlen (string); +#endif + p = string; + if (__builtin_expect (n < 1024, 1)) + { + wstring = (wchar_t *) alloca ((n + 1) * sizeof (wchar_t)); + n = mbsrtowcs (wstring, &p, n + 1, &ps); + if (__builtin_expect (n == (size_t) -1, 0)) + /* Something wrong. + XXX Do we have to set `errno' to something which mbsrtows hasn't + already done? */ + return -1; + if (p) + memset (&ps, '\0', sizeof (ps)); + } + if (__builtin_expect (p != NULL, 0)) + { + n = mbsrtowcs (NULL, &string, 0, &ps); + if (__builtin_expect (n == (size_t) -1, 0)) + /* Something wrong. + XXX Do we have to set `errno' to something which mbsrtows hasn't + already done? */ + return -1; + wstring = (wchar_t *) alloca ((n + 1) * sizeof (wchar_t)); + assert (mbsinit (&ps)); + (void) mbsrtowcs (wstring, &string, n + 1, &ps); + } return internal_fnwmatch (wpattern, wstring, wstring + n, flags & FNM_PERIOD, flags); diff --git a/posix/tst-execle1.c b/posix/tst-execle1.c index adea0a8d46..bacf51b1a2 100644 --- a/posix/tst-execle1.c +++ b/posix/tst-execle1.c @@ -6,8 +6,9 @@ static int do_test (void) { static const char prog[] = "does-not-exist"; + char *env [] = {"FOO=BAR", NULL}; errno = 0; - execle (prog, prog, NULL, "FOO=BAR", NULL); + execle (prog, prog, NULL, env); if (errno != ENOENT) { diff --git a/posix/tst-execle2.c b/posix/tst-execle2.c index fb9b09b423..002d4c938f 100644 --- a/posix/tst-execle2.c +++ b/posix/tst-execle2.c @@ -45,8 +45,9 @@ prepare (int argc, char *argv[]) static int do_test (void) { + char *env[] = {"FOO=BAR", NULL}; errno = 0; - execle (copy, copy, NULL, "FOO=BAR", NULL); + execle (copy, copy, NULL, env); if (errno != EACCES) { |