From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Michal Nazarewicz Newsgroups: gmane.emacs.bugs Subject: bug#24378: [PATCH 6/6] Factor out character category lookup to separate function Date: Tue, 6 Sep 2016 15:31:34 +0200 Message-ID: <1473168694-13605-6-git-send-email-mina86@mina86.com> References: <1473168498-13194-1-git-send-email-mina86@mina86.com> <1473168694-13605-1-git-send-email-mina86@mina86.com> NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1473169090 15378 195.159.176.226 (6 Sep 2016 13:38:10 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 6 Sep 2016 13:38:10 +0000 (UTC) To: 24378@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Sep 06 15:38:06 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bhGZh-0003UD-OD for geb-bug-gnu-emacs@m.gmane.org; Tue, 06 Sep 2016 15:38:05 +0200 Original-Received: from localhost ([::1]:33479 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhGZf-00051x-FD for geb-bug-gnu-emacs@m.gmane.org; Tue, 06 Sep 2016 09:38:03 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58298) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhGTv-0000Cf-KM for bug-gnu-emacs@gnu.org; Tue, 06 Sep 2016 09:32:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bhGTr-0007G2-V0 for bug-gnu-emacs@gnu.org; Tue, 06 Sep 2016 09:32:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:53299) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhGTr-0007Ft-RI for bug-gnu-emacs@gnu.org; Tue, 06 Sep 2016 09:32:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bhGTr-0005vy-OB for bug-gnu-emacs@gnu.org; Tue, 06 Sep 2016 09:32:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Michal Nazarewicz Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 06 Sep 2016 13:32:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24378 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 24378-submit@debbugs.gnu.org id=B24378.147316871122756 (code B ref 24378); Tue, 06 Sep 2016 13:32:03 +0000 Original-Received: (at 24378) by debbugs.gnu.org; 6 Sep 2016 13:31:51 +0000 Original-Received: from localhost ([127.0.0.1]:51004 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bhGTf-0005us-AI for submit@debbugs.gnu.org; Tue, 06 Sep 2016 09:31:51 -0400 Original-Received: from mail-wm0-f49.google.com ([74.125.82.49]:38747) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bhGTc-0005tv-QN for 24378@debbugs.gnu.org; Tue, 06 Sep 2016 09:31:49 -0400 Original-Received: by mail-wm0-f49.google.com with SMTP id 1so190062858wmz.1 for <24378@debbugs.gnu.org>; Tue, 06 Sep 2016 06:31:48 -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; bh=5B8xYQl/rzi77DgDiFJoFq2iRdlOQwP/Zb1O+NbW9zs=; b=UQ7y2ha5Dv3WFDynrELDgRzZVevRINj83W7eQFRWh3NuwX+wKek/WfeoltXTo5BBen dwkx4GEXzlqgxLA7r1HO6FiKAoIS0yuRCCgc7UA6XCZW1xsbKBHc5JdiB0lCpOex8BV4 78XxTB0Bo4fg9792XRINm3s6bsb2fWv6czFzITEgW7I/EOjpUDp/E0HCn/FuEsn49Rre Bx1zBDjQ1iIMhYQzClTUljEZD0Ws0xctwrcdgTXekJkgzoFZogslZ8pZ5qWpjuTkkdPr 3XbFpSWYAi4BBpN0/8/K7J0sNa8KllgHnAA18uQpcI/MHOmA+jimRovA5hvrxm/3fzbB Zb9g== 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; bh=5B8xYQl/rzi77DgDiFJoFq2iRdlOQwP/Zb1O+NbW9zs=; b=KP6Huuf+oz81gHoRw3/0gBZ5tEtd1/uKpuQ3xH0iXE1pwwo4T0GToI6txl/SFLjNaM OUyxA3+8O/ih9j1qlcrxyeCSh3a1QuwOCEWKgw6/LYXlOrePsVXnH+uyQKlqs8SROzCG GygRxOzZDbEFG20Qneuqh0wKIRKUuXKaJFs04IR7HQMATW7nixcOw4FS9SyqNViZrUrn 7spiIoIjY4BxaRVyjov3j0jJOScneUakTjwX5JgdEgNzl3slqbgWYmF7HFRUwv+eID67 WzXdXwdj+UNGwjRmMn36Iz8HLNU7iWGeF8LWkZNYhLciK8oSilt2umrJ1+9kRRRospNB C6rg== X-Gm-Message-State: AE9vXwOu3O8YgBmN3yWRlCqahLX2CJDTv/IePBU20Q/dVVdK83W6DABTm4JEzHH1x0q1iQSE X-Received: by 10.28.229.19 with SMTP id c19mr21758234wmh.0.1473168702772; Tue, 06 Sep 2016 06:31:42 -0700 (PDT) Original-Received: from mpn.zrh.corp.google.com ([172.16.113.135]) by smtp.gmail.com with ESMTPSA id v189sm26529366wmv.12.2016.09.06.06.31.40 for <24378@debbugs.gnu.org> (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Sep 2016 06:31:41 -0700 (PDT) Original-Received: by mpn.zrh.corp.google.com (Postfix, from userid 126942) id B3EC41E0268; Tue, 6 Sep 2016 15:31:39 +0200 (CEST) X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: <1473168694-13605-1-git-send-email-mina86@mina86.com> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:122987 Archived-At: * src/character.c (char_unicode_category): New function returning Unicode general category of specified character. (alphabeticp, alphanumericp, graphicp, printablep): Use the above. --- src/character.c | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/src/character.c b/src/character.c index b19e41d..18a8fa3 100644 --- a/src/character.c +++ b/src/character.c @@ -960,14 +960,18 @@ character is not ASCII nor 8-bit character, an error is signaled. */) return make_number (c); } +static unicode_category_t +char_unicode_category (int c) +{ + Lisp_Object category = CHAR_TABLE_REF (Vunicode_category_table, c); + return INTEGERP (category) ? XINT (category) : UNICODE_CATEGORY_UNKNOWN; +} + /* Return true if C is an alphabetic character. */ bool alphabeticp (int c) { - Lisp_Object category = CHAR_TABLE_REF (Vunicode_category_table, c); - if (! INTEGERP (category)) - return false; - EMACS_INT gen_cat = XINT (category); + unicode_category_t gen_cat = char_unicode_category (c); /* See UTS #18. There are additional characters that should be here, those designated as Other_uppercase, Other_lowercase, @@ -987,10 +991,7 @@ alphabeticp (int c) bool alphanumericp (int c) { - Lisp_Object category = CHAR_TABLE_REF (Vunicode_category_table, c); - if (! INTEGERP (category)) - return false; - EMACS_INT gen_cat = XINT (category); + unicode_category_t gen_cat = char_unicode_category (c); /* See UTS #18. Same comment as for alphabeticp applies. FIXME. */ return (gen_cat == UNICODE_CATEGORY_Lu @@ -1009,13 +1010,11 @@ alphanumericp (int c) bool graphicp (int c) { - Lisp_Object category = CHAR_TABLE_REF (Vunicode_category_table, c); - if (! INTEGERP (category)) - return false; - EMACS_INT gen_cat = XINT (category); + unicode_category_t gen_cat = char_unicode_category (c); /* See UTS #18. */ - return (!(gen_cat == UNICODE_CATEGORY_Zs /* space separator */ + return (!(gen_cat == UNICODE_CATEGORY_UNKNOWN + || gen_cat == UNICODE_CATEGORY_Zs /* space separator */ || gen_cat == UNICODE_CATEGORY_Zl /* line separator */ || gen_cat == UNICODE_CATEGORY_Zp /* paragraph separator */ || gen_cat == UNICODE_CATEGORY_Cc /* control */ @@ -1027,13 +1026,11 @@ graphicp (int c) bool printablep (int c) { - Lisp_Object category = CHAR_TABLE_REF (Vunicode_category_table, c); - if (! INTEGERP (category)) - return false; - EMACS_INT gen_cat = XINT (category); + unicode_category_t gen_cat = char_unicode_category (c); /* See UTS #18. */ - return (!(gen_cat == UNICODE_CATEGORY_Cc /* control */ + return (!(gen_cat == UNICODE_CATEGORY_UNKNOWN + || gen_cat == UNICODE_CATEGORY_Cc /* control */ || gen_cat == UNICODE_CATEGORY_Cs /* surrogate */ || gen_cat == UNICODE_CATEGORY_Cn)); /* unassigned */ } -- 2.8.0.rc3.226.g39d4020