From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 28 13:00:46 2016 Received: (at submit) by debbugs.gnu.org; 28 Jul 2016 17:00:47 +0000 Received: from localhost ([127.0.0.1]:49519 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bSofu-00068N-O5 for submit@debbugs.gnu.org; Thu, 28 Jul 2016 13:00:46 -0400 Received: from eggs.gnu.org ([208.118.235.92]:60461) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bSoft-000685-Ak for submit@debbugs.gnu.org; Thu, 28 Jul 2016 13:00:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bSofm-0001vB-Up for submit@debbugs.gnu.org; Thu, 28 Jul 2016 13:00:40 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_05,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:47928) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bSofm-0001uy-SG for submit@debbugs.gnu.org; Thu, 28 Jul 2016 13:00:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51402) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bSofk-0000Wu-Di for bug-gnu-emacs@gnu.org; Thu, 28 Jul 2016 13:00:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bSofi-0001tz-DG for bug-gnu-emacs@gnu.org; Thu, 28 Jul 2016 13:00:35 -0400 Received: from mail-wm0-x236.google.com ([2a00:1450:400c:c09::236]:37432) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bSofi-0001tg-0E for bug-gnu-emacs@gnu.org; Thu, 28 Jul 2016 13:00:34 -0400 Received: by mail-wm0-x236.google.com with SMTP id i5so117289904wmg.0 for ; Thu, 28 Jul 2016 10:00:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=JkYr8Qb++viTBqYYoO2s4Yc4sCMUMrXCrmiVP8PYO78=; b=fbvA9EFqz7sQZ0ePtrfqHv8h9aVKk8fNapopreFpG2HApl/pZ0NP6Zkwhbuq/DR4lS vXzVBSa9PtfF5XesUb1lIeguhwyTlso3XdJSrWBhlkC4QX4FYkuMjZyaYK6wYiRbiteO mnUu3lzHbDIAHIGp8bbt79m135cZKPTs61EimcBmMsqhc3JvKabFTpw+wAwKIqf9TCfd UCoR6jUWYNQvxT/1qL35yva2L5sdYQi0ZAYPMgWVuchtKR+2p0VKIj5V/B51YDAwYXUI bE3Re4NcG4ZXn7Of1xlFds0tKW7a9iDr7ND4mTfn5kZQ3BGFM4qu5hq+Tyjn9hq3U6Up 8RhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:subject:date:message-id :mime-version:content-transfer-encoding; bh=JkYr8Qb++viTBqYYoO2s4Yc4sCMUMrXCrmiVP8PYO78=; b=kNvdxfM9GTx771o1HShdDt5ssCq9ZBF/z4gFaTgT471+j0H9HfQ9eZgIkLnbK+mPp8 AAXVWojaUFg1odxMve7DTaHJusomSNeD8Oz0nVYUcPSscO25FMdhCWHVlpOmNUeDMP7k Y/s45AAENXeL916EhXbUHEv+29e7XuGZCVcJ0iBbuocTFauUZ5d6egr9SQHiELFOekAr CW1U34wSSdZ4R0QEUW1xbYVEhF53vQcLt3iK6xmdQ0ut/NL7r1pQCjakd9EATxvY3N4a 0aaz0imkm5LAQxGM0V0pNe1W2/bKsLJr11bqxwLyvHKrTE+YRy7thRoASkG1AcCGR+S2 vsQQ== X-Gm-Message-State: AEkoous/obCcInx7TWlj1EWb5uFX7KDVaJOvsTt5Kbl5N9vJqbnyBgsXj2NYus6nh8ieQL1N X-Received: by 10.194.52.72 with SMTP id r8mr28520803wjo.166.1469725232361; Thu, 28 Jul 2016 10:00:32 -0700 (PDT) Received: from mpn.zrh.corp.google.com ([172.16.113.135]) by smtp.gmail.com with ESMTPSA id x133sm13159483wmf.16.2016.07.28.10.00.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jul 2016 10:00:31 -0700 (PDT) Received: by mpn.zrh.corp.google.com (Postfix, from userid 126942) id E4E431E028B; Thu, 28 Jul 2016 19:00:30 +0200 (CEST) From: Michal Nazarewicz To: bug-gnu-emacs@gnu.org Subject: [PATCH 0/4] Some regex dead-code elimination Date: Thu, 28 Jul 2016 19:00:28 +0200 Message-Id: <1469725228-24151-1-git-send-email-mina86@mina86.com> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) The first patch is just a minor cleanup, the rests bank on the observation that Emacs only ever uses its own regex syntax. Overall, this shrinks Emacs by over 60 kB and expecetdly also speeds it up. This patchest is put on top of my previous on from bug#24009. The whole branch can be seen at https://github.com/mina86/emacs/. Unless there are objections, I’ve submit it in a week or so. Michal Nazarewicz (4): Remove dead opcodes in regex bytecode Get rid of re_set_syntax Get rid of re_set_whitespace_regexp Hardcode regex syntax to remove dead code handling different syntax src/regex.c | 101 ++++++++++++++++++++++++++++++++++------------------------- src/regex.h | 20 ++++++++++-- src/search.c | 17 +++------- 3 files changed, 80 insertions(+), 58 deletions(-) -- 2.8.0.rc3.226.g39d4020 From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 28 14:07:27 2016 Received: (at 24100) by debbugs.gnu.org; 28 Jul 2016 18:07:27 +0000 Received: from localhost ([127.0.0.1]:49563 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bSpiQ-0007j9-VM for submit@debbugs.gnu.org; Thu, 28 Jul 2016 14:07:27 -0400 Received: from mail-wm0-f54.google.com ([74.125.82.54]:38097) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bSpiP-0007is-UV for 24100@debbugs.gnu.org; Thu, 28 Jul 2016 14:07:26 -0400 Received: by mail-wm0-f54.google.com with SMTP id o80so119614172wme.1 for <24100@debbugs.gnu.org>; Thu, 28 Jul 2016 11:07:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:subject:date:message-id; bh=NPbFwOF0vI2AyIr1N/tjnvlLADUGaP/CpcKDbDz5J9M=; b=TbJNqxig6R8R3NvxTCfZoDJYXNklJP9U6jtXz8pVd8lYXpnhiKx9qLsJQH9TtW7NIN YMF0Kbu8qMdIYDEkISpiXe+OQm/AC7wCX/skJcuX+gTC4Wg0TfKmc09OsaQWRRUOEF7c 8QmHiWUG3gpoUZ9+zOQVZlb6lBjM3kfqQ1gX4XTfE58PDV7ww6iEVXhQEGjPHRHpcdfA G9iHVryHf5XIbFbne9HK0mYW7CyM2gwvC70pcAd1iLxmfInfUtUHCaO7iVeBBEmAniEp H/DXFJk06ZeG1Oc+5DzW9oMAX3yRZMJghChwKSAVfzxXE2NGuFtrPjM/HVrBUBO20rTJ b4aA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:subject:date:message-id; bh=NPbFwOF0vI2AyIr1N/tjnvlLADUGaP/CpcKDbDz5J9M=; b=OB8qHzjCWlHTtj/MOORzCYN2BFJEladPMwr5eG7WRvH8QQ3CpTt+t7ktykIvY/TVfs 1VeB+ltgbny36eRyXdqAEx/Ex4AlF4PhtDh+9Q56Zdk3xCFg5pu3mZO0Ic8uEax3qqNP 0wnPyHj5qkHfXVPum1q7q+bTq0IigFzgrMe/hyma9wuGPC0lmM+97E0CRZifXuRXjAhD PEEGp0zZJ/aJJJAbftiHDq+Uxwq+5LQCdzY89Cr4a0jAN0KXKrH7BEhhpqvzZMQ5W32b NPb1xhQBjnReGOY/oavK0fWTfDqc0u5Jo8H9QogLzNJ17aoHzi/PqwpKY4DB8IgC1hWx 4EAA== X-Gm-Message-State: ALyK8tKGALek6Cju3FSo38rT7IzCe+o+a9dtOjoY5zK7DcVP0AXVHX0LtzTIm8iQPe74c19c X-Received: by 10.28.27.143 with SMTP id b137mr63622559wmb.12.1469729240003; Thu, 28 Jul 2016 11:07:20 -0700 (PDT) Received: from mpn.zrh.corp.google.com ([172.16.113.135]) by smtp.gmail.com with ESMTPSA id d8sm13400293wmi.0.2016.07.28.11.07.19 for <24100@debbugs.gnu.org> (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jul 2016 11:07:19 -0700 (PDT) Received: by mpn.zrh.corp.google.com (Postfix, from userid 126942) id 9C8D31E35E5; Thu, 28 Jul 2016 20:07:18 +0200 (CEST) From: Michal Nazarewicz To: 24100@debbugs.gnu.org Subject: [PATCH 1/4] Remove dead opcodes in regex bytecode Date: Thu, 28 Jul 2016 20:07:14 +0200 Message-Id: <1469729237-14208-1-git-send-email-mina86@mina86.com> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 X-Spam-Score: -2.0 (--) X-Debbugs-Envelope-To: 24100 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.0 (--) There is no way to specify before_dot and after_dot opcodes in a regex so code handling those ends up being dead. Remove it. * src/regex.c (print_partial_compiled_pattern, regex_compile, analyze_first, re_match_2_internal): Remove handling and references to before_dot and after_dot opcodes. --- src/regex.c | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/src/regex.c b/src/regex.c index 3a25835..261d299 100644 --- a/src/regex.c +++ b/src/regex.c @@ -669,9 +669,7 @@ typedef enum notsyntaxspec #ifdef emacs - ,before_dot, /* Succeeds if before point. */ - at_dot, /* Succeeds if at point. */ - after_dot, /* Succeeds if after point. */ + , at_dot, /* Succeeds if at point. */ /* Matches any character whose category-set contains the specified category. The operator is followed by a byte which contains a @@ -1053,18 +1051,10 @@ print_partial_compiled_pattern (re_char *start, re_char *end) break; # ifdef emacs - case before_dot: - fprintf (stderr, "/before_dot"); - break; - case at_dot: fprintf (stderr, "/at_dot"); break; - case after_dot: - fprintf (stderr, "/after_dot"); - break; - case categoryspec: fprintf (stderr, "/categoryspec"); mcnt = *p++; @@ -3440,8 +3430,6 @@ regex_compile (const_re_char *pattern, size_t size, reg_syntax_t syntax, goto normal_char; #ifdef emacs - /* There is no way to specify the before_dot and after_dot - operators. rms says this is ok. --karl */ case '=': laststart = b; BUF_PUSH (at_dot); @@ -4018,9 +4006,7 @@ analyze_first (const_re_char *p, const_re_char *pend, char *fastmap, /* All cases after this match the empty string. These end with `continue'. */ - case before_dot: case at_dot: - case after_dot: #endif /* !emacs */ case no_op: case begline: @@ -6148,24 +6134,12 @@ re_match_2_internal (struct re_pattern_buffer *bufp, const_re_char *string1, break; #ifdef emacs - case before_dot: - DEBUG_PRINT ("EXECUTING before_dot.\n"); - if (PTR_BYTE_POS (d) >= PT_BYTE) - goto fail; - break; - case at_dot: DEBUG_PRINT ("EXECUTING at_dot.\n"); if (PTR_BYTE_POS (d) != PT_BYTE) goto fail; break; - case after_dot: - DEBUG_PRINT ("EXECUTING after_dot.\n"); - if (PTR_BYTE_POS (d) <= PT_BYTE) - goto fail; - break; - case categoryspec: case notcategoryspec: { -- 2.8.0.rc3.226.g39d4020 From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 28 14:07:30 2016 Received: (at 24100) by debbugs.gnu.org; 28 Jul 2016 18:07:30 +0000 Received: from localhost ([127.0.0.1]:49566 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bSpiU-0007jT-7U for submit@debbugs.gnu.org; Thu, 28 Jul 2016 14:07:30 -0400 Received: from mail-wm0-f51.google.com ([74.125.82.51]:38105) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bSpiQ-0007it-Fb for 24100@debbugs.gnu.org; Thu, 28 Jul 2016 14:07:27 -0400 Received: by mail-wm0-f51.google.com with SMTP id o80so119614498wme.1 for <24100@debbugs.gnu.org>; Thu, 28 Jul 2016 11:07:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yuRGIQdlRq7cHnGDwlQGkEu2mrt1qZsoB8MsVp5Kyjk=; b=dE3afmsre0ODQeTj1/pb3kGKN27imU7VIQFB+6tGjJnDI4DS7BzdA4oHtYP2zt9D8O CvqpjuZhb4Gf+uzwfVRsDFe0LwEtk6nD5FHZo+xWnq1d91CS24sK/vekgvl11X4fiag2 YmOQAwXTZx2WSOXFm91uhhhBPrL8xSKNXWlVpSYHPpXCctWnsVCmjszYwEpQx25FBSu/ sHPuHPmUHunu43F+KcdHp1GlnP0ZGQYsFhn1q87x+h2bRMRpymSLvd3BiSv6uDOy58Ey n2u7sx8WfuUEA5qHfuNPNU5tFIaRKksQqXDc+uFPhLKWpNICR3j013SHpXVz+zWGte7R cYaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=yuRGIQdlRq7cHnGDwlQGkEu2mrt1qZsoB8MsVp5Kyjk=; b=ctvYFL8uJc9FiMJ5zXaT8LySX8ZyuoUxdjoEt1I7XMR29l+5YOfBwpNAG7kv2Wr3Zr 3pW/Yryh4ceJuDJazRS2XQeCpWRfaxQcNPydZWXPW51iezA0d53gih+D48iIhrpweEyc C5XMTz4SwvpiV/LaSKkYLuoqMzBn0FlAhgHhvLagZzcq5GhtK0HLgGJvDmWiiL4Zdi4q eqk1Pn4UDQ8rSQ0PgrvLlkHVQsVsDkaSZ+wJOPSsMXTrxip9f38SKM8ZInl8ZzllG6aO i0ZQshxVWRSVjinNVjrINoEHq2snG2OxtuKD1uAb2c7StjUd5FwRr+jqqYTOUJycWOR+ cUUw== X-Gm-Message-State: AEkooutknYUotmXixleuiiPmmkG1nehOm8qFJ7N+D/E+9YYQpFGMmrUjjeOssQ+Xu+oUAuZR X-Received: by 10.195.18.170 with SMTP id gn10mr35073766wjd.46.1469729240355; Thu, 28 Jul 2016 11:07:20 -0700 (PDT) Received: from mpn.zrh.corp.google.com ([172.16.113.135]) by smtp.gmail.com with ESMTPSA id v189sm44484652wmv.12.2016.07.28.11.07.19 for <24100@debbugs.gnu.org> (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jul 2016 11:07:19 -0700 (PDT) Received: by mpn.zrh.corp.google.com (Postfix, from userid 126942) id B84EB1E021E; Thu, 28 Jul 2016 20:07:18 +0200 (CEST) From: Michal Nazarewicz To: 24100@debbugs.gnu.org Subject: [PATCH 4/4] Hardcode regex syntax to remove dead code handling different syntax Date: Thu, 28 Jul 2016 20:07:17 +0200 Message-Id: <1469729237-14208-4-git-send-email-mina86@mina86.com> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: <1469729237-14208-1-git-send-email-mina86@mina86.com> References: <1469729237-14208-1-git-send-email-mina86@mina86.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.0 (--) X-Debbugs-Envelope-To: 24100 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.0 (--) Emacs only ever uses its own regex syntax so support for other syntaxes is never used. Hardcode the syntax so that the compilar can detect such dead code and remove it from compiled code. The only exception is RE_NO_POSIX_BACKTRACKING which can be separatelly specified. Handle this separatelly with a function argument (replacing now unnecessary syntax argument). With this patchset, size of Emacs binary on x86_64 machine is reduced by around 60 kB: new-sizes:-rwx------ 3 mpn eng 30254720 Jul 27 23:31 src/emacs old-sizes:-rwx------ 3 mpn eng 30314828 Jul 27 23:29 src/emacs * src/regex.h (re_pattern_buffer): Don’t define syntax field #ifdef emacs. (re_compile_pattern): Replace syntax with posix_backtracking argument. * src/regex.c (print_compiled_pattern): Don’t print syntax #ifdef emacs. (regex_compile): #ifdef emacs, replace syntax argument with posix_backtracking which is now used instead of testing for RE_NO_POSIX_BACKTRACKING syntax. (re_match_2_internal): Don’t access bufp->syntax #ifndef emacs. (re_compile_pattern): Replace syntax with posix_backtracking argument. * src/search.c (compile_pattern_1): Pass boolean posix_backtracking instead of syntax to re_compile_pattern. --- src/regex.c | 40 +++++++++++++++++++++++++++++++--------- src/regex.h | 5 +++-- src/search.c | 4 +--- 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/src/regex.c b/src/regex.c index c32a62f..8dafb11 100644 --- a/src/regex.c +++ b/src/regex.c @@ -1108,7 +1108,9 @@ print_compiled_pattern (struct re_pattern_buffer *bufp) printf ("no_sub: %d\t", bufp->no_sub); printf ("not_bol: %d\t", bufp->not_bol); printf ("not_eol: %d\t", bufp->not_eol); +#ifndef emacs printf ("syntax: %lx\n", bufp->syntax); +#endif fflush (stdout); /* Perhaps we should print the translate table? */ } @@ -1558,9 +1560,11 @@ do { \ /* Subroutine declarations and macros for regex_compile. */ static reg_errcode_t regex_compile (re_char *pattern, size_t size, - reg_syntax_t syntax, #ifdef emacs + bool posix_backtracking, const char *whitespace_regexp, +#else + reg_syntax_t syntax, #endif struct re_pattern_buffer *bufp); static void store_op1 (re_opcode_t op, unsigned char *loc, int arg); @@ -2426,9 +2430,14 @@ do { \ } while (0) static reg_errcode_t -regex_compile (const_re_char *pattern, size_t size, reg_syntax_t syntax, +regex_compile (const_re_char *pattern, size_t size, #ifdef emacs +# define syntax RE_SYNTAX_EMACS + bool posix_backtracking, const char *whitespace_regexp, +#else + reg_syntax_t syntax, +# define posix_backtracking (!(syntax & RE_NO_POSIX_BACKTRACKING)) #endif struct re_pattern_buffer *bufp) { @@ -2518,7 +2527,9 @@ regex_compile (const_re_char *pattern, size_t size, reg_syntax_t syntax, range_table_work.allocated = 0; /* Initialize the pattern buffer. */ +#ifndef emacs bufp->syntax = syntax; +#endif bufp->fastmap_accurate = 0; bufp->not_bol = bufp->not_eol = 0; bufp->used_syntax = 0; @@ -3645,7 +3656,7 @@ regex_compile (const_re_char *pattern, size_t size, reg_syntax_t syntax, /* If we don't want backtracking, force success the first time we reach the end of the compiled pattern. */ - if (syntax & RE_NO_POSIX_BACKTRACKING) + if (!posix_backtracking) BUF_PUSH (succeed); /* We have succeeded; set the length of the buffer. */ @@ -3680,6 +3691,12 @@ regex_compile (const_re_char *pattern, size_t size, reg_syntax_t syntax, #endif /* not MATCH_MAY_ALLOCATE */ FREE_STACK_RETURN (REG_NOERROR); + +#ifdef emacs +# undef syntax +#else +# undef posix_backtracking +#endif } /* regex_compile */ /* Subroutines for `regex_compile'. */ @@ -5442,6 +5459,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, const_re_char *string1, { int buf_charlen; re_wchar_t buf_ch; + reg_syntax_t syntax; DEBUG_PRINT ("EXECUTING anychar.\n"); @@ -5450,10 +5468,14 @@ re_match_2_internal (struct re_pattern_buffer *bufp, const_re_char *string1, target_multibyte); buf_ch = TRANSLATE (buf_ch); - if ((!(bufp->syntax & RE_DOT_NEWLINE) - && buf_ch == '\n') - || ((bufp->syntax & RE_DOT_NOT_NULL) - && buf_ch == '\000')) +#ifdef emacs + syntax = RE_SYNTAX_EMACS; +#else + syntax = bufp->syntax; +#endif + + if ((!(syntax & RE_DOT_NEWLINE) && buf_ch == '\n') + || ((syntax & RE_DOT_NOT_NULL) && buf_ch == '\000')) goto fail; DEBUG_PRINT (" Matched \"%d\".\n", *d); @@ -6281,7 +6303,7 @@ bcmp_translate (const_re_char *s1, const_re_char *s2, register ssize_t len, const char * re_compile_pattern (const char *pattern, size_t length, #ifdef emacs - reg_syntax_t syntax, const char *whitespace_regexp, + bool posix_backtracking, const char *whitespace_regexp, #endif struct re_pattern_buffer *bufp) { @@ -6298,7 +6320,7 @@ re_compile_pattern (const char *pattern, size_t length, ret = regex_compile ((re_char*) pattern, length, #ifdef emacs - syntax, + posix_backtracking, whitespace_regexp, #else re_syntax_options, diff --git a/src/regex.h b/src/regex.h index af9480d..b672d3f 100644 --- a/src/regex.h +++ b/src/regex.h @@ -354,9 +354,10 @@ struct re_pattern_buffer /* Number of bytes actually used in `buffer'. */ size_t used; +#ifndef emacs /* Syntax setting with which the pattern was compiled. */ reg_syntax_t syntax; - +#endif /* Pointer to a fastmap, if any, otherwise zero. re_search uses the fastmap, if there is one, to skip over impossible starting points for matches. */ @@ -473,7 +474,7 @@ extern reg_syntax_t re_set_syntax (reg_syntax_t __syntax); BUFFER. Return NULL if successful, and an error string if not. */ extern const char *re_compile_pattern (const char *__pattern, size_t __length, #ifdef emacs - reg_syntax_t syntax, + bool posix_backtracking, const char *whitespace_regexp, #endif struct re_pattern_buffer *__buffer); diff --git a/src/search.c b/src/search.c index c7556a9..7f2b4f9 100644 --- a/src/search.c +++ b/src/search.c @@ -114,7 +114,6 @@ compile_pattern_1 (struct regexp_cache *cp, Lisp_Object pattern, Lisp_Object translate, bool posix) { const char *whitespace_regexp; - reg_syntax_t syntax; char *val; cp->regexp = Qnil; @@ -133,12 +132,11 @@ compile_pattern_1 (struct regexp_cache *cp, Lisp_Object pattern, So let's turn it off. */ /* BLOCK_INPUT; */ - syntax = RE_SYNTAX_EMACS | (posix ? 0 : RE_NO_POSIX_BACKTRACKING); whitespace_regexp = STRINGP (Vsearch_spaces_regexp) ? SSDATA (Vsearch_spaces_regexp) : NULL; val = (char *) re_compile_pattern (SSDATA (pattern), SBYTES (pattern), - syntax, whitespace_regexp, &cp->buf); + posix, whitespace_regexp, &cp->buf); /* If the compiled pattern hard codes some of the contents of the syntax-table, it can only be reused with *this* syntax table. */ -- 2.8.0.rc3.226.g39d4020 From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 28 14:07:31 2016 Received: (at 24100) by debbugs.gnu.org; 28 Jul 2016 18:07:31 +0000 Received: from localhost ([127.0.0.1]:49569 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bSpiV-0007jg-IO for submit@debbugs.gnu.org; Thu, 28 Jul 2016 14:07:31 -0400 Received: from mail-wm0-f45.google.com ([74.125.82.45]:36137) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bSpiS-0007iw-U0 for 24100@debbugs.gnu.org; Thu, 28 Jul 2016 14:07:29 -0400 Received: by mail-wm0-f45.google.com with SMTP id q128so261785230wma.1 for <24100@debbugs.gnu.org>; Thu, 28 Jul 2016 11:07:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CWMMvrr25/mZNTihyDo/a20j2ujVM7uIJfJ+wERzWGI=; b=EVMhoG+gph2puAD07S4l0A1hb4yEb6oNUPiAVjdPeDVGwB8Rls/JVqmW5v6tEzB7iG Pu8H+q1GwTXdOk2dNCJ7jwd5S38ohx/Xd/ibdl3aL/lgs828zzctwL98NyGHYX4VSbnr 1XbxklhPraeirUHd9mqvfEnD4PX0Rkq0J/krCZj0+2PDLbzuuHqH9205ogGVbJNYAZVj TcesZb+4s5Ck3FhNVOnXLbtv2P/GmlcZrc+jgmWOtQddJYlmMgXqjt6CVPI9h9fEBhCW kQwbFpRRHSEKgMiJ+uMBofF5Vqnlb+U7fbddfZlKOA3Ucq42jhOFlp0birVShvRFM4aD xUVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=CWMMvrr25/mZNTihyDo/a20j2ujVM7uIJfJ+wERzWGI=; b=gSP4LQ7g4ehCUvjf9GOXZuvZdpJrjhEAdpDlzWjJ9ZLhfHyRVPiKxr8LTl9cuKpNMF +WLzVMfPfK+I7hap0jxgJ5Z5cDgk+oazIldK3maBClHChdOxX56OxE4a1FixcKN7yOpE 8KGhy6E4CU5924sHKWsBdcbhfDB3E66o48COVHZVjs6IPkNTVyPrJ29gPV1weFd++c8d 759ST9kOZvoifHzl1D0CewGPs/JKrxXu2/S06jBv3aZzjguH4Qp3EQ59HdNmplt5MOu2 CEsZTUcoXaX5r23DE3oGhVRxWHaGVqG2X1NRa5WeIyxY6xJAE7O57ixQnR+zQDCdvkWB WXFQ== X-Gm-Message-State: AEkooutjNfhhQ3AjKDEvYkeXWFf3XuHWiC9f2uc+Ja1h+1OJlvomT2R+6xcFampNmWI0Ce2D X-Received: by 10.28.193.8 with SMTP id r8mr38619475wmf.13.1469729242202; Thu, 28 Jul 2016 11:07:22 -0700 (PDT) Received: from mpn.zrh.corp.google.com ([2620:0:105f:301:7557:b5f1:c9d7:d894]) by smtp.gmail.com with ESMTPSA id q4sm12651853wjk.24.2016.07.28.11.07.19 for <24100@debbugs.gnu.org> (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jul 2016 11:07:20 -0700 (PDT) Received: by mpn.zrh.corp.google.com (Postfix, from userid 126942) id C07521E35E4; Thu, 28 Jul 2016 20:07:18 +0200 (CEST) From: Michal Nazarewicz To: 24100@debbugs.gnu.org Subject: [PATCH 3/4] Get rid of re_set_whitespace_regexp Date: Thu, 28 Jul 2016 20:07:16 +0200 Message-Id: <1469729237-14208-3-git-send-email-mina86@mina86.com> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: <1469729237-14208-1-git-send-email-mina86@mina86.com> References: <1469729237-14208-1-git-send-email-mina86@mina86.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.0 (--) X-Debbugs-Envelope-To: 24100 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.0 (--) * src/regex.h (re_set_whitespace_regexp): Delete. (re_compile_pattern): Add whitespace_regexp argument #ifdef emacs. * src/regex.c (re_set_whitespace_regexp, whitespace_regexp): Delete. (regex_compile): Add whitespace_regexp argument #ifdef emacs and wrap whitespace_regexp-related code in an #ifdef emacs so it’s compiled out unless building Emacs. (re_compile_pattern): Pass whitespace_regexp argument to regex_compile * src/search.c (compile_pattern_1): Don’t use re_set_whitespace_regexp, pass the regex as argument to re_compile_pattern instead. --- src/regex.c | 39 ++++++++++++++++++++++++--------------- src/regex.h | 3 +-- src/search.c | 13 +++++-------- 3 files changed, 30 insertions(+), 25 deletions(-) diff --git a/src/regex.c b/src/regex.c index 4edc064..c32a62f 100644 --- a/src/regex.c +++ b/src/regex.c @@ -1177,16 +1177,6 @@ re_set_syntax (reg_syntax_t syntax) WEAK_ALIAS (__re_set_syntax, re_set_syntax) #endif - -/* Regexp to use to replace spaces, or NULL meaning don't. */ -static const_re_char *whitespace_regexp; - -void -re_set_whitespace_regexp (const char *regexp) -{ - whitespace_regexp = (const_re_char *) regexp; -} -WEAK_ALIAS (__re_set_syntax, re_set_syntax) /* This table gives an error message for each of the error codes listed in regex.h. Obviously the order here has to be same as there. @@ -1569,6 +1559,9 @@ do { \ static reg_errcode_t regex_compile (re_char *pattern, size_t size, reg_syntax_t syntax, +#ifdef emacs + const char *whitespace_regexp, +#endif struct re_pattern_buffer *bufp); static void store_op1 (re_opcode_t op, unsigned char *loc, int arg); static void store_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2); @@ -2398,6 +2391,9 @@ static boolean group_in_compile_stack (compile_stack_type compile_stack, /* `regex_compile' compiles PATTERN (of length SIZE) according to SYNTAX. Returns one of error codes defined in `regex.h', or zero for success. + If WHITESPACE_REGEXP is given (only #ifdef emacs), it is used instead of + a space character in PATTERN. + Assumes the `allocated' (and perhaps `buffer') and `translate' fields are set in BUFP on entry. @@ -2431,6 +2427,9 @@ do { \ static reg_errcode_t regex_compile (const_re_char *pattern, size_t size, reg_syntax_t syntax, +#ifdef emacs + const char *whitespace_regexp, +#endif struct re_pattern_buffer *bufp) { /* We fetch characters from PATTERN here. */ @@ -2483,6 +2482,7 @@ regex_compile (const_re_char *pattern, size_t size, reg_syntax_t syntax, /* If the object matched can contain multibyte characters. */ const boolean multibyte = RE_MULTIBYTE_P (bufp); +#ifdef emacs /* Nonzero if we have pushed down into a subpattern. */ int in_subpattern = 0; @@ -2491,6 +2491,7 @@ regex_compile (const_re_char *pattern, size_t size, reg_syntax_t syntax, re_char *main_p; re_char *main_pattern; re_char *main_pend; +#endif #ifdef DEBUG debug++; @@ -2559,6 +2560,7 @@ regex_compile (const_re_char *pattern, size_t size, reg_syntax_t syntax, { if (p == pend) { +#ifdef emacs /* If this is the end of an included regexp, pop back to the main regexp and try again. */ if (in_subpattern) @@ -2569,6 +2571,7 @@ regex_compile (const_re_char *pattern, size_t size, reg_syntax_t syntax, pend = main_pend; continue; } +#endif /* If this is the end of the main regexp, we are done. */ break; } @@ -2577,6 +2580,7 @@ regex_compile (const_re_char *pattern, size_t size, reg_syntax_t syntax, switch (c) { +#ifdef emacs case ' ': { re_char *p1 = p; @@ -2609,6 +2613,7 @@ regex_compile (const_re_char *pattern, size_t size, reg_syntax_t syntax, pend = p + strlen ((const char *) p); break; } +#endif case '^': { @@ -6276,13 +6281,10 @@ bcmp_translate (const_re_char *s1, const_re_char *s2, register ssize_t len, const char * re_compile_pattern (const char *pattern, size_t length, #ifdef emacs - reg_syntax_t syntax, + reg_syntax_t syntax, const char *whitespace_regexp, #endif struct re_pattern_buffer *bufp) { -#ifndef emacs - const reg_syntax_t syntax = re_syntax_options; -#endif reg_errcode_t ret; /* GNU code is written to assume at least RE_NREGS registers will be set @@ -6294,7 +6296,14 @@ re_compile_pattern (const char *pattern, size_t length, setting no_sub. */ bufp->no_sub = 0; - ret = regex_compile ((re_char*) pattern, length, syntax, bufp); + ret = regex_compile ((re_char*) pattern, length, +#ifdef emacs + syntax, + whitespace_regexp, +#else + re_syntax_options, +#endif + bufp); if (!ret) return NULL; diff --git a/src/regex.h b/src/regex.h index 4497333..af9480d 100644 --- a/src/regex.h +++ b/src/regex.h @@ -474,6 +474,7 @@ extern reg_syntax_t re_set_syntax (reg_syntax_t __syntax); extern const char *re_compile_pattern (const char *__pattern, size_t __length, #ifdef emacs reg_syntax_t syntax, + const char *whitespace_regexp, #endif struct re_pattern_buffer *__buffer); @@ -627,8 +628,6 @@ extern re_wctype_t re_wctype_parse (const unsigned char **strp, unsigned limit); typedef int re_wchar_t; -extern void re_set_whitespace_regexp (const char *regexp); - #endif /* not WIDE_CHAR_SUPPORT */ #endif /* regex.h */ diff --git a/src/search.c b/src/search.c index f041952..c7556a9 100644 --- a/src/search.c +++ b/src/search.c @@ -113,6 +113,7 @@ static void compile_pattern_1 (struct regexp_cache *cp, Lisp_Object pattern, Lisp_Object translate, bool posix) { + const char *whitespace_regexp; reg_syntax_t syntax; char *val; @@ -132,21 +133,17 @@ compile_pattern_1 (struct regexp_cache *cp, Lisp_Object pattern, So let's turn it off. */ /* BLOCK_INPUT; */ - if (STRINGP (Vsearch_spaces_regexp)) - re_set_whitespace_regexp (SSDATA (Vsearch_spaces_regexp)); - else - re_set_whitespace_regexp (NULL); - syntax = RE_SYNTAX_EMACS | (posix ? 0 : RE_NO_POSIX_BACKTRACKING); + whitespace_regexp = STRINGP (Vsearch_spaces_regexp) ? + SSDATA (Vsearch_spaces_regexp) : NULL; + val = (char *) re_compile_pattern (SSDATA (pattern), SBYTES (pattern), - syntax, &cp->buf); + syntax, whitespace_regexp, &cp->buf); /* If the compiled pattern hard codes some of the contents of the syntax-table, it can only be reused with *this* syntax table. */ cp->syntax_table = cp->buf.used_syntax ? BVAR (current_buffer, syntax_table) : Qt; - re_set_whitespace_regexp (NULL); - /* unblock_input (); */ if (val) xsignal1 (Qinvalid_regexp, build_string (val)); -- 2.8.0.rc3.226.g39d4020 From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 28 14:07:34 2016 Received: (at 24100) by debbugs.gnu.org; 28 Jul 2016 18:07:34 +0000 Received: from localhost ([127.0.0.1]:49571 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bSpiX-0007jq-Tw for submit@debbugs.gnu.org; Thu, 28 Jul 2016 14:07:34 -0400 Received: from mail-wm0-f54.google.com ([74.125.82.54]:37291) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bSpiU-0007j1-W2 for 24100@debbugs.gnu.org; Thu, 28 Jul 2016 14:07:31 -0400 Received: by mail-wm0-f54.google.com with SMTP id i5so119628078wmg.0 for <24100@debbugs.gnu.org>; Thu, 28 Jul 2016 11:07:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Wox80dkCNEneMkzvjn3C2xFd+grPElulAi/dePbhRuo=; b=ZSgv+nQdJnnMjpmB7pmm7Aremvxb6Whz2ZQ1dXhJpUaBTLafCXWCy5V5g5kUe0wddq d5/kqhZ8Re1Yblj6W64CqHp7Mr89+YCTCGS73YeIl99VGqGjrp/tw2sJomAJz+pRmN8w HVTk4KUcTa6J6oBKpvBkWNvnMdLVgqe9LsuXCX8Vnmhm61ICfEsIH+1LpAb4CaBl3dqL U8TYRnh5IT2uA0HqNFdp7GQ99FAhQQVxvEtHCh2lMQXPeEpMfSOyUZdoJxkMTYAD44kf 99R1t/LWgl/+1GI1YFjRJhgwk8L8NAu56spb7OESklLOYzPgAQwBf2N7NzcwuVJ3UkeW SKyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Wox80dkCNEneMkzvjn3C2xFd+grPElulAi/dePbhRuo=; b=L0kXhq/9OsQJn6tQAp9UWsFF2EL6XARFQR7YGgxf58oPeQZgBg5LTg+YhmpPeRY3XW oRRtfdS7I8iLa1P9w6+ZPhkVqd6gFmI2KQOl6ncJ5Nun3+iLrqVdiyZPw4hpG/6YVDkU 9CY+uoDG3xOO1CeIyDGjCaxxOrwpOHrkahBsYaFGKA2hYdl96q+jCv3QOT/Ojj0qtA4t 4vnzXfP/vHbXdN0W3oLVLea7cCu/pR7FRmVFvknwlKkx8NkMfu8Fkq2rIKdu4AdjQkik kPLIcqZp1iOYExjFQBFIpawHaCyr1D4KCZ5kLZL1832fjygAZ7qr3F6WOAWUmdtYopAd aMLQ== X-Gm-Message-State: ALyK8tI3sB/sCBxprZwKMNxTjONmZosQTTRsyLb61jl46vFQC/N9ewfU6Y8tsVzCtCNffzPl X-Received: by 10.28.38.196 with SMTP id m187mr57936901wmm.81.1469729242671; Thu, 28 Jul 2016 11:07:22 -0700 (PDT) Received: from mpn.zrh.corp.google.com ([172.16.113.135]) by smtp.gmail.com with ESMTPSA id m62sm13336642wmm.24.2016.07.28.11.07.19 for <24100@debbugs.gnu.org> (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jul 2016 11:07:20 -0700 (PDT) Received: by mpn.zrh.corp.google.com (Postfix, from userid 126942) id C8B301E0291; Thu, 28 Jul 2016 20:07:18 +0200 (CEST) From: Michal Nazarewicz To: 24100@debbugs.gnu.org Subject: [PATCH 2/4] Get rid of re_set_syntax Date: Thu, 28 Jul 2016 20:07:15 +0200 Message-Id: <1469729237-14208-2-git-send-email-mina86@mina86.com> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: <1469729237-14208-1-git-send-email-mina86@mina86.com> References: <1469729237-14208-1-git-send-email-mina86@mina86.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.0 (--) X-Debbugs-Envelope-To: 24100 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.0 (--) Instead of using a global variable for storing regex syntax, pass it to re_compile_pattern. This is only enabled when compiling Emacs (i.e. ‘#ifdef emacs’). * src/regex.h (re_set_syntax): Declare only #ifndef emacs. (re_compile_pattern): Now takes syntax argument #ifdef emacs. * src/regex.c (re_syntax_options): Define only #ifndef emacs. (re_compile_pattern): Use the new syntax argument #ifdef emacs. * src/search.c (compile_pattern_1): Don’t use re_set_syntax and instead pass syntax to re_compile_pattern directly. --- src/regex.c | 12 +++++++++++- src/regex.h | 14 ++++++++++++++ src/search.c | 10 ++++------ 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/regex.c b/src/regex.c index 261d299..4edc064 100644 --- a/src/regex.c +++ b/src/regex.c @@ -1149,6 +1149,8 @@ print_double_string (re_char *where, re_char *string1, ssize_t size1, #endif /* not DEBUG */ +#ifndef emacs + /* Set by `re_set_syntax' to the current regexp syntax to recognize. Can also be assigned to arbitrarily: each pattern buffer stores its own syntax, so it can be changed between regex compilations. */ @@ -1174,6 +1176,8 @@ re_set_syntax (reg_syntax_t syntax) } WEAK_ALIAS (__re_set_syntax, re_set_syntax) +#endif + /* Regexp to use to replace spaces, or NULL meaning don't. */ static const_re_char *whitespace_regexp; @@ -6271,8 +6275,14 @@ bcmp_translate (const_re_char *s1, const_re_char *s2, register ssize_t len, const char * re_compile_pattern (const char *pattern, size_t length, +#ifdef emacs + reg_syntax_t syntax, +#endif struct re_pattern_buffer *bufp) { +#ifndef emacs + const reg_syntax_t syntax = re_syntax_options; +#endif reg_errcode_t ret; /* GNU code is written to assume at least RE_NREGS registers will be set @@ -6284,7 +6294,7 @@ re_compile_pattern (const char *pattern, size_t length, setting no_sub. */ bufp->no_sub = 0; - ret = regex_compile ((re_char*) pattern, length, re_syntax_options, bufp); + ret = regex_compile ((re_char*) pattern, length, syntax, bufp); if (!ret) return NULL; diff --git a/src/regex.h b/src/regex.h index 01b659a..4497333 100644 --- a/src/regex.h +++ b/src/regex.h @@ -20,6 +20,13 @@ #ifndef _REGEX_H #define _REGEX_H 1 +#if defined emacs && (defined _REGEX_RE_COMP || defined _LIBC) +/* We’re not defining re_set_syntax and using a different prototype of + re_compile_pattern when building Emacs so fail compilation early with + a (somewhat helpful) error message when conflict is detected. */ +# error "_REGEX_RE_COMP nor _LIBC can be defined if emacs is defined." +#endif + /* Allow the use in C++ code. */ #ifdef __cplusplus extern "C" { @@ -453,14 +460,21 @@ typedef struct /* Declarations for routines. */ +#ifndef emacs + /* Sets the current default syntax to SYNTAX, and return the old syntax. You can also simply assign to the `re_syntax_options' variable. */ extern reg_syntax_t re_set_syntax (reg_syntax_t __syntax); +#endif + /* Compile the regular expression PATTERN, with length LENGTH and syntax given by the global `re_syntax_options', into the buffer BUFFER. Return NULL if successful, and an error string if not. */ extern const char *re_compile_pattern (const char *__pattern, size_t __length, +#ifdef emacs + reg_syntax_t syntax, +#endif struct re_pattern_buffer *__buffer); diff --git a/src/search.c b/src/search.c index 7cb18a2..f041952 100644 --- a/src/search.c +++ b/src/search.c @@ -113,8 +113,8 @@ static void compile_pattern_1 (struct regexp_cache *cp, Lisp_Object pattern, Lisp_Object translate, bool posix) { + reg_syntax_t syntax; char *val; - reg_syntax_t old; cp->regexp = Qnil; cp->buf.translate = (! NILP (translate) ? translate : make_number (0)); @@ -131,16 +131,15 @@ compile_pattern_1 (struct regexp_cache *cp, Lisp_Object pattern, Using BLOCK_INPUT here means the debugger won't run if an error occurs. So let's turn it off. */ /* BLOCK_INPUT; */ - old = re_set_syntax (RE_SYNTAX_EMACS - | (posix ? 0 : RE_NO_POSIX_BACKTRACKING)); if (STRINGP (Vsearch_spaces_regexp)) re_set_whitespace_regexp (SSDATA (Vsearch_spaces_regexp)); else re_set_whitespace_regexp (NULL); - val = (char *) re_compile_pattern (SSDATA (pattern), - SBYTES (pattern), &cp->buf); + syntax = RE_SYNTAX_EMACS | (posix ? 0 : RE_NO_POSIX_BACKTRACKING); + val = (char *) re_compile_pattern (SSDATA (pattern), SBYTES (pattern), + syntax, &cp->buf); /* If the compiled pattern hard codes some of the contents of the syntax-table, it can only be reused with *this* syntax table. */ @@ -148,7 +147,6 @@ compile_pattern_1 (struct regexp_cache *cp, Lisp_Object pattern, re_set_whitespace_regexp (NULL); - re_set_syntax (old); /* unblock_input (); */ if (val) xsignal1 (Qinvalid_regexp, build_string (val)); -- 2.8.0.rc3.226.g39d4020 From debbugs-submit-bounces@debbugs.gnu.org Tue Aug 02 12:06:49 2016 Received: (at 24100-done) by debbugs.gnu.org; 2 Aug 2016 16:06:49 +0000 Received: from localhost ([127.0.0.1]:53800 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bUcDR-0005Dx-MF for submit@debbugs.gnu.org; Tue, 02 Aug 2016 12:06:49 -0400 Received: from mail-wm0-f54.google.com ([74.125.82.54]:38799) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bUcDQ-0005Di-5Y for 24100-done@debbugs.gnu.org; Tue, 02 Aug 2016 12:06:48 -0400 Received: by mail-wm0-f54.google.com with SMTP id o80so297614130wme.1 for <24100-done@debbugs.gnu.org>; Tue, 02 Aug 2016 09:06:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:subject:in-reply-to:organization:references :user-agent:face:date:message-id:mime-version :content-transfer-encoding; bh=nfoQon4tyv45eVCgXz/JX5++bl/EJ+BPN0P+OMeH+rU=; b=Ry3Z2Q8zbdcJkSOs087y3+ZJ7kGeX5freF/FnPsuL7Ykw7PqotWM123veXi+V3JiIN Fwmkuw32RPocUvv5CM6xIOyQv99Zty38oKK0qT5FefQVztiLZ+D8v8uqYPCnTvaCEOWY pV05uau3TN7UGi06cfXAwybuyBMZTDdysD7O9xSolDCYh6C7XvSh15zCZum46pp3/Wuz iRaebYKlaGOJiYGcb8zr0VmKqxifR3ivORqVhPOSH/e6SHtPrkXgPIQv1EbjYyBvKkL0 3gAdbMWfffm7+FIRyXxKDyf6bWrGvtYvGla9XfcCRtDP75Ohi3+wnqNp8LCRBmeNEmLr +yGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:subject:in-reply-to:organization :references:user-agent:face:date:message-id:mime-version :content-transfer-encoding; bh=nfoQon4tyv45eVCgXz/JX5++bl/EJ+BPN0P+OMeH+rU=; b=CLy22N2nDkctRgQNyg6zPZZXhr7QW3AI4KaEmEuW0hIY+aJDSXuVkeiprpbt9FivH0 A93f6MOfVJFA8K7VpF4oPgxE7YYpmOSgK5LCskYF1xdXTu/8D0Trhkf7U6aADHHgqDrR ewCdQPCjfxmeVJjzuIyAtnmBGOoJtcYjc09JManAMJLHHqgZO5SNgSa6r4bLd4nECbYy 6tglq8b0L03LFYNxABI2rhCa0YCbuPJxIubhcUeIOEgdqpkmCORaXWTKXih0tG2EPnWu 4AtPOzeYe9cefdAXwqy4AhFcIdPhGBtcDZmMF9e9z75vBwYaWrkcub26314oT3LWsMgL KoLw== X-Gm-Message-State: AEkoouto+YMhEbzfaLlaeiYPP6lK2fn7AmVnBPLK6+fzX8JYnwGt0Q2an5psspSaE1I9oGgR X-Received: by 10.194.29.2 with SMTP id f2mr55648054wjh.161.1470154002270; Tue, 02 Aug 2016 09:06:42 -0700 (PDT) Received: from mpn-glaptop ([2620:0:105f:301:5e0:8629:cc48:7615]) by smtp.gmail.com with ESMTPSA id d80sm22781097wmd.14.2016.08.02.09.06.41 for <24100-done@debbugs.gnu.org> (version=TLS1_2 cipher=AES128-SHA bits=128/128); Tue, 02 Aug 2016 09:06:41 -0700 (PDT) From: Michal Nazarewicz To: 24100-done@debbugs.gnu.org Subject: Re: [PATCH 0/4] Some regex dead-code elimination In-Reply-To: <1469725228-24151-1-git-send-email-mina86@mina86.com> Organization: http://mina86.com/ References: <1469725228-24151-1-git-send-email-mina86@mina86.com> User-Agent: Notmuch/0.19+53~g2e63a09 (http://notmuchmail.org) Emacs/25.1.50.1 (x86_64-unknown-linux-gnu) Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAJFBMVEWbfGlUPDDHgE57V0jUupKjgIObY0PLrom9mH4dFRK4gmjPs41MxjOgAAACP0lEQVQ4T23Sv2vbQBQHcBk1xE6WyALX107VUEgmn6+ouUwpEQQ6uRjttkWP4CkBg2M0BQLBdPFZYPsyFYo7qEtKDQ7on+t7+nF2Ux8ahD587717OmNYrOvycHsZ+o2r051wHTHysAvGb8ygvgu4QWT0sCmkgZCIEnlV2X8BtyraazFGDuxhmKSQJMlwHQ7v5MHSNxmz78rfElwAa3ieVD9e+hBhjaPDDG6NgFo2f4wBMNIo5YmRtF0RyDgFjJjlMIWbnuM4x9MMfABGTlN4qgIQB4A1DEyA1BHWtfeWNUMwiVJKoqh97KrkOO+qzgluVYLvFCUKAX73nONeBr7BGMdM6Sg0kuep03VywLaIzRiVr+GAzKlpQIsAFnWAG2e6DT5WmWDiudZMIc6hYrMOmeMQK9WX0B+/RfjzL9DI7Y9/Iayn29Ci0r2i4f9gMimMSZLCDMalgQGU5hnUtqAN0OGvEmO1Wnl0C0wWSCEHnuHBqmygxdxA8oWXwbipoc1EoNR9DqOpBpOJrnr0criQab9ZT4LL+wI+K7GBQH30CrhUruilgP9DRTrhVWZCiAyILP+wiuLeCKGTD6r/nc8LOJcAwR6IBTUs+7CASw3QFZ0MdA2PI3zNziH4ZKVhXCRMBjeZ1DWMekKwDCASwExy+NQ86TaykaDAFHO4aP48y4fIcDM5yOG8GcTLbOyp8A8azjJI93JFd1EA6yN8sSxMQJWoABqniRZVykYgRXErzrdqExAoUrRb0xfRp8p2A/4XmfilTtkDZ4cAAAAASUVORK5CYII= X-Face: -TR8(rDTHy/(xl?SfWd1|3:TTgDIatE^t'vop%*gVg[kn$t{EpK(P"VQ=~T2#ysNmJKN$"yTRLB4YQs$4{[.]Fc1)*O]3+XO^oXM>Q#b^ix, O)Zbn)q[y06$`e3?C)`CwR9y5riE=fv^X@x$y?D:XO6L&x4f-}}I4=VRNwiA^t1-ZrVK^07.Pi/57c_du'& X-PGP: 50751FF4 X-PGP-FP: AC1F 5F5C D418 88F8 CC84 5858 2060 4012 5075 1FF4 X-Hashcash: 1:20:160802:bug-gnu-emacs@gnu.org::LB6PnRTRbJjvZ/Bs:00000000000000000000000000000000000000005Gmf Date: Tue, 02 Aug 2016 18:06:40 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: base64 X-Spam-Score: -2.0 (--) X-Debbugs-Envelope-To: 24100-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.0 (--) UHVzaGVkLg0KDQotLSANCkJlc3QgcmVnYXJkcw0K44Of44OP44KmIOKAnPCdk7bwnZOy8J2Tt/Cd k6o4NuKAnSDjg4rjgrbjg6zjg7TjgqTjg4QNCsKrSWYgYXQgZmlyc3QgeW91IGRvbuKAmXQgc3Vj Y2VlZCwgZ2l2ZSB1cCBza3lkaXZpbmfCuw0K From unknown Fri Jun 13 10:16:02 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 31 Aug 2016 11:24:03 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator