-/* Copyright (C) 1991-2014 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 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
it matches, nonzero if not. */
static int FCT (const CHAR *pattern, const CHAR *string,
const CHAR *string_end, int no_leading_period, int flags,
- struct STRUCT *ends, size_t alloca_used)
- internal_function;
+ struct STRUCT *ends, size_t alloca_used);
static int EXT (INT opt, const CHAR *pattern, const CHAR *string,
const CHAR *string_end, int no_leading_period, int flags,
- size_t alloca_used)
- internal_function;
-static const CHAR *END (const CHAR *patternp) internal_function;
+ size_t alloca_used);
+static const CHAR *END (const CHAR *patternp);
static int
-internal_function
-FCT (pattern, string, string_end, no_leading_period, flags, ends, alloca_used)
- const CHAR *pattern;
- const CHAR *string;
- const CHAR *string_end;
- int no_leading_period;
- int flags;
- struct STRUCT *ends;
- size_t alloca_used;
+FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
+ int no_leading_period, int flags, struct STRUCT *ends, size_t alloca_used)
{
const CHAR *p = pattern, *n = string;
UCHAR c;
#ifdef _LIBC
else if (c == L('[') && *p == L('='))
{
- UCHAR str[1];
+ /* It's important that STR be a scalar variable rather
+ than a one-element array, because GCC (at least 4.9.2
+ -O2 on x86-64) can be confused by the array and
+ diagnose a "used initialized" in a dead branch in the
+ findidx function. */
+ UCHAR str;
uint32_t nrules =
_NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
const CHAR *startp = p;
c = L('[');
goto normal_bracket;
}
- str[0] = c;
+ str = c;
c = *++p;
if (c != L('=') || p[1] != L(']'))
if (nrules == 0)
{
- if ((UCHAR) *n == str[0])
+ if ((UCHAR) *n == str)
goto matched;
}
else
const int32_t *table;
# if WIDE_CHAR_VERSION
const int32_t *weights;
- const int32_t *extra;
+ const wint_t *extra;
# else
const unsigned char *weights;
const unsigned char *extra;
# endif
const int32_t *indirect;
int32_t idx;
- const UCHAR *cp = (const UCHAR *) str;
-
- /* This #include defines a local function! */
-# if WIDE_CHAR_VERSION
-# include <locale/weightwc.h>
-# else
-# include <locale/weight.h>
-# endif
+ const UCHAR *cp = (const UCHAR *) &str;
# if WIDE_CHAR_VERSION
table = (const int32_t *)
_NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEWC);
weights = (const int32_t *)
_NL_CURRENT (LC_COLLATE, _NL_COLLATE_WEIGHTWC);
- extra = (const int32_t *)
+ extra = (const wint_t *)
_NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAWC);
indirect = (const int32_t *)
_NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTWC);
_NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTMB);
# endif
- idx = findidx (&cp, 1);
+ idx = FINDIDX (table, indirect, extra, &cp, 1);
if (idx != 0)
{
/* We found a table entry. Now see whether the
int32_t idx2;
const UCHAR *np = (const UCHAR *) n;
- idx2 = findidx (&np, string_end - n);
+ idx2 = FINDIDX (table, indirect, extra,
+ &np, string_end - n);
if (idx2 != 0
&& (idx >> 24) == (idx2 >> 24)
&& len == weights[idx2 & 0xffffff])
}
else if (c == L('[') && *p == L('.'))
{
- ++p;
while (1)
{
c = *++p;
- if (c == '\0')
+ if (c == L('\0'))
return FNM_NOMATCH;
- if (*p == L('.') && p[1] == L(']'))
+ if (c == L('.') && p[1] == L(']'))
break;
}
p += 2;
static const CHAR *
-internal_function
END (const CHAR *pattern)
{
const CHAR *p = pattern;
}
else if ((*p == L('?') || *p == L('*') || *p == L('+') || *p == L('@')
|| *p == L('!')) && p[1] == L('('))
- p = END (p + 1);
+ {
+ p = END (p + 1);
+ if (*p == L('\0'))
+ /* This is an invalid pattern. */
+ return pattern;
+ }
else if (*p == L(')'))
break;
static int
-internal_function
EXT (INT opt, const CHAR *pattern, const CHAR *string, const CHAR *string_end,
int no_leading_period, int flags, size_t alloca_used)
{
#undef L
#undef BTOWC
#undef WIDE_CHAR_VERSION
+#undef FINDIDX