From patchwork Mon Oct 15 04:41:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paul Eggert X-Patchwork-Id: 29737 Received: (qmail 54558 invoked by alias); 15 Oct 2018 04:41:34 -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 54546 invoked by uid 89); 15 Oct 2018 04:41:33 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.2 spammy=evaluated, H*Ad:D*ucla.edu, UD:stdbool.h, stdbool.h X-HELO: zimbra.cs.ucla.edu X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" X-Quarantine-ID: X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" From: Paul Eggert To: libc-alpha@sourceware.org Cc: Paul Eggert Subject: [committed 2/2] regex: simplify by using intprops.h Date: Sun, 14 Oct 2018 21:41:13 -0700 Message-Id: <620a5d4cb19f817ef0ed721c2a3fe27d72b12156.1539578358.git.eggert@cs.ucla.edu> In-Reply-To: References: MIME-Version: 1.0 In-Reply-To: References: [BZ#23744] * posix/regex_internal.h [_LIBC]: Include intprops.h. (TYPE_SIGNED, INT_ADD_WRAPV) [_LIBC]: Remove. intprops.h defines them. --- ChangeLog | 6 ++++++ posix/regex_internal.h | 18 +----------------- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 52299e6c56..26017655f9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2018-10-14 Paul Eggert + regex: simplify by using intprops.h + [BZ#23744] + * posix/regex_internal.h [_LIBC]: Include intprops.h. + (TYPE_SIGNED, INT_ADD_WRAPV) [_LIBC]: Remove. + intprops.h defines them. + regex: __builtin_expect → __glibc_unlikely [BZ#23744] This refactoring was prompted by a problem when the regex code is diff --git a/posix/regex_internal.h b/posix/regex_internal.h index de4bcbdc2d..f4b2702868 100644 --- a/posix/regex_internal.h +++ b/posix/regex_internal.h @@ -33,23 +33,7 @@ #include #include -/* Properties of integers. Although Gnulib has intprops.h, glibc does - without for now. */ -#ifndef _LIBC -# include "intprops.h" -#else -/* True if the real type T is signed. */ -# define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) - -/* True if adding the nonnegative Idx values A and B would overflow. - If false, set *R to A + B. A, B, and R may be evaluated more than - once, or zero times. Although this is not a full implementation of - Gnulib INT_ADD_WRAPV, it is good enough for glibc regex code. - FIXME: This implementation is a fragile stopgap, and this file would - be simpler and more robust if intprops.h were migrated into glibc. */ -# define INT_ADD_WRAPV(a, b, r) \ - (IDX_MAX - (a) < (b) ? true : (*(r) = (a) + (b), false)) -#endif +#include #ifdef _LIBC # include