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#24603: [RFC 14/18] Factor out character category lookup to separate function Date: Tue, 4 Oct 2016 03:10:37 +0200 Message-ID: <1475543441-10493-14-git-send-email-mina86@mina86.com> References: <1475543441-10493-1-git-send-email-mina86@mina86.com> NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1475544134 1818 195.159.176.226 (4 Oct 2016 01:22:14 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 4 Oct 2016 01:22:14 +0000 (UTC) To: 24603@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Oct 04 03:22:10 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 1brEQS-0005UD-NI for geb-bug-gnu-emacs@m.gmane.org; Tue, 04 Oct 2016 03:21:44 +0200 Original-Received: from localhost ([::1]:39772 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brEQR-0003m2-1o for geb-bug-gnu-emacs@m.gmane.org; Mon, 03 Oct 2016 21:21:43 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56609) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brEHE-0006r2-Ng for bug-gnu-emacs@gnu.org; Mon, 03 Oct 2016 21:12:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1brEHD-0002au-4g for bug-gnu-emacs@gnu.org; Mon, 03 Oct 2016 21:12:12 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:37373) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brEHD-0002ai-20 for bug-gnu-emacs@gnu.org; Mon, 03 Oct 2016 21:12:11 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1brEH9-0006kX-TS for bug-gnu-emacs@gnu.org; Mon, 03 Oct 2016 21:12:07 -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, 04 Oct 2016 01:12:07 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24603 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 24603-submit@debbugs.gnu.org id=B24603.147554347225729 (code B ref 24603); Tue, 04 Oct 2016 01:12:07 +0000 Original-Received: (at 24603) by debbugs.gnu.org; 4 Oct 2016 01:11:12 +0000 Original-Received: from localhost ([127.0.0.1]:43546 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1brEGG-0006gp-2N for submit@debbugs.gnu.org; Mon, 03 Oct 2016 21:11:12 -0400 Original-Received: from mail-wm0-f43.google.com ([74.125.82.43]:38658) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1brEGB-0006e3-Fx for 24603@debbugs.gnu.org; Mon, 03 Oct 2016 21:11:07 -0400 Original-Received: by mail-wm0-f43.google.com with SMTP id p138so182364059wmb.1 for <24603@debbugs.gnu.org>; Mon, 03 Oct 2016 18:11:07 -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=+2rOJHx/Ya9XiYmND+ct09LDvH8VhXE0CctBYF7SHA8=; b=pL8jpII9aFHzThEryEU3RWO2xHNjoXWh/9QM9Zv0oPRniFWtca7K+V94EsqpljEX3r QuiHwWakavNfENUysS+hkEEPiAiGR45IMaO8jRiF1hfKF7XvzUa0H8Pn8WC3nbohINgJ l9CmhUVN4l+HBSUQa/uBQck4JUxSpV8U+tv3cgf+ykJk4cccfGqp6CIWaN4pHPStnHDz od4gJa1mFL1ua4sNr6LQljJariv3GpMI5ldB8IS9/h9FlK/txeRs8e+584YAJYKCcS70 7CzL1Lx53flEevI0A6vBRrRyR2Nbq4GpO0eLfESWT1usMYNn0RzO2uI5DUtCSu4JHSsC laWw== 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=+2rOJHx/Ya9XiYmND+ct09LDvH8VhXE0CctBYF7SHA8=; b=aKX+gjAZAstWhZOFuC/I+Tl1peer1MRd3k4gOY6yTuMXrAdzMzm+SiSUBR5H3ZRNkZ XZhPpj9RrI+jl6CJIWlVnd9ZjOcMnKz98ug+VB0IeX7zzixe9ouMQT4CfKwJRmGrr3kF gJpdToDNUx7wZmCpdNK8Ha3r/appFDKofjyOGfxTUJMJHjJRzdE0iM8mElbEzIIxBHJC 6FUCb3kqd3un6pphlO+0lh+FEBhnAEBQBZwIZjGOuvG2l2RBDz61nIbefQ16LZWU5Rmn hJVaz4EbHPJ5q83bEJI5lYsxhYFaXXBB2Hy5X+ylHn8vcVs/iXIA63NzooAKu5pPK02n 495w== X-Gm-Message-State: AA6/9RnTgnJlgAMOX3YyDmaqamT3hM965Fkgc97YeNEBZGlBYSUEMiPrwJomekCJmng4b2dJ X-Received: by 10.28.150.211 with SMTP id y202mr13498043wmd.6.1475543461636; Mon, 03 Oct 2016 18:11:01 -0700 (PDT) Original-Received: from mpn.zrh.corp.google.com ([2620:0:105f:301:e126:377e:c57c:59ab]) by smtp.gmail.com with ESMTPSA id x135sm23546129wmd.0.2016.10.03.18.10.53 for <24603@debbugs.gnu.org> (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Oct 2016 18:10:56 -0700 (PDT) Original-Received: by mpn.zrh.corp.google.com (Postfix, from userid 126942) id 3756F1E0298; Tue, 4 Oct 2016 03:10:48 +0200 (CEST) X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: <1475543441-10493-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:124006 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 75a7dab..1e49536 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