emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master c579b28 3/6: Replace decimalnump with alphanumericp


From: Michal Nazarewicz
Subject: [Emacs-diffs] master c579b28 3/6: Replace decimalnump with alphanumericp
Date: Fri, 9 Sep 2016 16:32:58 +0000 (UTC)

branch: master
commit c579b28f6281c9cc0b711a012c30bf00036c60bf
Author: Michal Nazarewicz <address@hidden>
Commit: Michal Nazarewicz <address@hidden>

    Replace decimalnump with alphanumericp
    
    decimalnump was used in regex.c only in ISALNUM macro which ored it with
    alphabeticp.  Because both of those functions require Unicode general
    category lookup, this resulted in unnecessary lookups (if alphabeticp
    return false decimalp had to perform another lookup).  Drop decimalnump
    in favour of alphanumericp which combines decimelnump with alphabeticp.
    
    * src/character.c (decimalnump): Remove in favour of…
    (alphanumericp): …new function.
    
    * src/regex.c (ISALNUM): Use alphanumericp.
---
 src/character.c |   17 +++++++++++++----
 src/character.h |    2 +-
 src/regex.c     |    2 +-
 3 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/src/character.c b/src/character.c
index 9f60aa7..b19e41d 100644
--- a/src/character.c
+++ b/src/character.c
@@ -983,17 +983,26 @@ alphabeticp (int c)
          || gen_cat == UNICODE_CATEGORY_Nl);
 }
 
-/* Return true if C is a decimal-number character.  */
+/* Return true if C is a alphabetic or decimal-number character.  */
 bool
-decimalnump (int c)
+alphanumericp (int c)
 {
   Lisp_Object category = CHAR_TABLE_REF (Vunicode_category_table, c);
   if (! INTEGERP (category))
     return false;
   EMACS_INT gen_cat = XINT (category);
 
-  /* See UTS #18.  */
-  return gen_cat == UNICODE_CATEGORY_Nd;
+  /* See UTS #18.  Same comment as for alphabeticp applies.  FIXME. */
+  return (gen_cat == UNICODE_CATEGORY_Lu
+         || gen_cat == UNICODE_CATEGORY_Ll
+         || gen_cat == UNICODE_CATEGORY_Lt
+         || gen_cat == UNICODE_CATEGORY_Lm
+         || gen_cat == UNICODE_CATEGORY_Lo
+         || gen_cat == UNICODE_CATEGORY_Mn
+         || gen_cat == UNICODE_CATEGORY_Mc
+         || gen_cat == UNICODE_CATEGORY_Me
+         || gen_cat == UNICODE_CATEGORY_Nl
+         || gen_cat == UNICODE_CATEGORY_Nd);
 }
 
 /* Return true if C is a graphic character.  */
diff --git a/src/character.h b/src/character.h
index 7f01bc6..2cb76b0 100644
--- a/src/character.h
+++ b/src/character.h
@@ -676,7 +676,7 @@ extern Lisp_Object Vchar_unify_table;
 extern Lisp_Object string_escape_byte8 (Lisp_Object);
 
 extern bool alphabeticp (int);
-extern bool decimalnump (int);
+extern bool alphanumericp (int);
 extern bool graphicp (int);
 extern bool printablep (int);
 
diff --git a/src/regex.c b/src/regex.c
index c808398..5f51b43 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -324,7 +324,7 @@ enum syntaxcode { Swhitespace = 0, Sword = 1, Ssymbol = 2 };
                    ? (((c) >= 'a' && (c) <= 'z')       \
                       || ((c) >= 'A' && (c) <= 'Z')    \
                       || ((c) >= '0' && (c) <= '9'))   \
-                   : (alphabeticp (c) || decimalnump (c)))
+                   : alphanumericp (c))
 
 # define ISALPHA(c) (IS_REAL_ASCII (c)                 \
                    ? (((c) >= 'a' && (c) <= 'z')       \



reply via email to

[Prev in Thread] Current Thread [Next in Thread]