This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v2 12/12] posix: Remove VLA usage for internal fnmatch implementation


On Feb 05 2018, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:

> diff --git a/posix/fnmatch_loop.c b/posix/fnmatch_loop.c
> index eadb343..831e5ba 100644
> --- a/posix/fnmatch_loop.c
> +++ b/posix/fnmatch_loop.c
> @@ -493,26 +493,20 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
>  			  {
>  			    int32_t table_size;
>  			    const int32_t *symb_table;
> -# if WIDE_CHAR_VERSION
> -			    char str[c1];
> -			    unsigned int strcnt;
> -# else
> -#  define str (startp + 1)
> -# endif
> +			    struct char_array str;
> +			    char_array_init_empty (&str);
>  			    const unsigned char *extra;
>  			    int32_t idx;
>  			    int32_t elem;
>  			    int32_t second;
>  			    int32_t hash;
>  
> -# if WIDE_CHAR_VERSION
>  			    /* We have to convert the name to a single-byte
>  			       string.  This is possible since the names
>  			       consist of ASCII characters and the internal
>  			       representation is UCS4.  */
> -			    for (strcnt = 0; strcnt < c1; ++strcnt)
> -			      str[strcnt] = startp[1 + strcnt];
> -#endif
> +			    for (size_t strcnt = 0; strcnt < c1; ++strcnt)
> +			      char_array_append_char (&str, startp[1 + strcnt]);
>  
>  			    table_size =
>  			      _NL_CURRENT_WORD (LC_COLLATE,

That needs to be removed altogether, see
<http://sourceware.org/ml/libc-alpha/2017-04/msg00068.html>.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]