From patchwork Mon Mar 9 18:58:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Pluzhnikov X-Patchwork-Id: 5535 Received: (qmail 18438 invoked by alias); 9 Mar 2015 18:59:10 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 18424 invoked by uid 89); 9 Mar 2015 18:59:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mail-ob0-f181.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=79lQ6ls05M2RzmGtJ7UnZk7FivKWdsMC0Xzs45mje/s=; b=HJ0vqhZs3EPhzQDlXga6f75YA7NIHETxXdbjziXwuP5wqtHOQ9H+XNksYOr+5C+gBr tl7+0PgLIP5DAqsNxVWhuRiUTyA2O98KeK0GoZ50OBcGLGKizsoGYUDozJiq6QG/I/+q RUq2jsZ6BSSGH2ziCSQ50+7fKJAxPLlwrZMFlJnlo2u4LmZSUPBACBcW/MydKVWig9zi MJ72HdHz+lP0CRB4/Yzxabe8UlOe9sPxwpYT7/bvlanEf88uWYNXlmNfTDT8WV4dKwNx NUWAEpCNRCHqvkZ5uLsFZnE7zkxyKrg9kXxzj2KtU5JSouB/aheJmkLuIFO4GxJXI0tb U17w== X-Gm-Message-State: ALoCoQnJk15gBM4uEMh+GMv05Q2qUymoOtkplecctiryJLbggLlhziT2fENGemRY2eiXc2YboU6x X-Received: by 10.60.132.33 with SMTP id or1mr21044189oeb.82.1425927546587; Mon, 09 Mar 2015 11:59:06 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <54FDE447.4040000@cs.ucla.edu> References: <54FDE447.4040000@cs.ucla.edu> From: Paul Pluzhnikov Date: Mon, 9 Mar 2015 11:58:36 -0700 Message-ID: Subject: Re: [patch][committed] Fix second instance of BZ #18043 To: Paul Eggert Cc: GLIBC Devel On Mon, Mar 9, 2015 at 11:19 AM, Paul Eggert wrote: > On 03/09/2015 07:28 AM, Paul Pluzhnikov wrote: >> >> - if (strchr ("-=?+", words[1 + *offset]) == NULL) >> + if (words[1 + *offset] == '\0' >> + || strchr ("-=?+", words[1 + *offset]) == NULL) > > > For stuff like this, how about using memchr instead? E.g.,: Sounds good to me. Something like attached? 2015-03-09 Paul Pluzhnikov [BZ #18043] * posix/wordexp.c (CHAR_IN_SET): New macro. (parse_param): Use it. diff --git a/posix/wordexp.c b/posix/wordexp.c index 36b6fff..661dfd4 100644 --- a/posix/wordexp.c +++ b/posix/wordexp.c @@ -1218,6 +1218,9 @@ parse_comm (char **word, size_t *word_length, size_t *max_length, return WRDE_SYNTAX; } +#define CHAR_IN_SET(ch, char_set) \ + (memchr (char_set "", (ch), sizeof (char_set) - 1) != NULL) + static int internal_function parse_param (char **word, size_t *word_length, size_t *max_length, @@ -1299,7 +1302,7 @@ parse_param (char **word, size_t *word_length, size_t *max_length, } while (isdigit(words[++*offset])); } - else if (words[*offset] != '\0' && strchr ("*@$", words[*offset]) != NULL) + else if (CHAR_IN_SET (words[*offset], "*@$")) { /* Special parameter. */ special = 1; @@ -1343,8 +1346,7 @@ parse_param (char **word, size_t *word_length, size_t *max_length, break; case ':': - if (words[1 + *offset] == '\0' - || strchr ("-=?+", words[1 + *offset]) == NULL) + if (!CHAR_IN_SET (words[1 + *offset], "-=?+")) goto syntax; colon_seen = 1; @@ -2046,6 +2048,8 @@ do_error: return error; } +#undef CHAR_IN_SET + static int internal_function parse_dollars (char **word, size_t *word_length, size_t *max_length,