emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] trunk r113676: * composite.h: Minor fixups.


From: Paul Eggert
Subject: [Emacs-diffs] trunk r113676: * composite.h: Minor fixups.
Date: Sat, 03 Aug 2013 21:10:00 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 113676
revision-id: address@hidden
parent: address@hidden
committer: Paul Eggert <address@hidden>
branch nick: trunk
timestamp: Sat 2013-08-03 14:09:57 -0700
message:
  * composite.h: Minor fixups.
  
  (composition_registered_p): Rename from COMPOSITION_REGISTERD_P
  to fix a misspelling, and change it to an inline function while
  we're at it (it need not be a macro).  All uses changed.
  (composition_method, composition_valid_p):
  Rewrite to avoid assignments in if-conditions.
modified:
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/composite.c                
composite.c-20091113204419-o5vbwnq5f7feedwu-1728
  src/composite.h                
composite.h-20091113204419-o5vbwnq5f7feedwu-1729
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2013-08-03 18:23:23 +0000
+++ b/src/ChangeLog     2013-08-03 21:09:57 +0000
@@ -1,3 +1,12 @@
+2013-08-03  Paul Eggert  <address@hidden>
+
+       * composite.h: Minor fixups.
+       (composition_registered_p): Rename from COMPOSITION_REGISTERD_P
+       to fix a misspelling, and change it to an inline function while
+       we're at it (it need not be a macro).  All uses changed.
+       (composition_method, composition_valid_p):
+       Rewrite to avoid assignments in if-conditions.
+
 2013-08-03  Dmitry Antipov  <address@hidden>
 
        Do not use global Lisp_Object in composition macros.

=== modified file 'src/composite.c'
--- a/src/composite.c   2013-08-03 18:16:43 +0000
+++ b/src/composite.c   2013-08-03 21:09:57 +0000
@@ -1873,7 +1873,7 @@
   if (NILP (detail_p))
     return list3 (make_number (start), make_number (end), Qt);
 
-  if (COMPOSITION_REGISTERD_P (prop))
+  if (composition_registered_p (prop))
     id = COMPOSITION_ID (prop);
   else
     {

=== modified file 'src/composite.h'
--- a/src/composite.h   2013-08-03 18:23:23 +0000
+++ b/src/composite.h   2013-08-03 21:09:57 +0000
@@ -49,34 +49,38 @@
 /* Maximum number of components a single composition can have.  */
 #define MAX_COMPOSITION_COMPONENTS 16
 
-/* These macros access information about a composition that
+/* These operations access information about a composition that
    has `composition' property PROP.  PROP is:
        ((LENGTH . COMPONENTS) . MODIFICATION-FUNC)
    or
        (COMPOSITION-ID . (LENGTH COMPONENTS . MODIFICATION-FUNC))
    They don't check validity of PROP.  */
 
-/* Return 1 if the composition is already registered.  */
-#define COMPOSITION_REGISTERD_P(prop) INTEGERP (XCAR (prop))
+/* Return true if PROP is already registered.  */
+COMPOSITE_INLINE bool
+composition_registered_p (Lisp_Object prop)
+{
+  return INTEGERP (XCAR (prop));
+}
 
 /* Return ID number of the already registered composition.  */
 #define COMPOSITION_ID(prop) XINT (XCAR (prop))
 
 /* Return length of the composition.  */
 #define COMPOSITION_LENGTH(prop)       \
-  (COMPOSITION_REGISTERD_P (prop)      \
+  (composition_registered_p (prop)     \
    ? XINT (XCAR (XCDR (prop)))         \
    : XINT (XCAR (XCAR (prop))))
 
 /* Return components of the composition.  */
 #define COMPOSITION_COMPONENTS(prop)   \
-  (COMPOSITION_REGISTERD_P (prop)      \
+  (composition_registered_p (prop)     \
    ? XCAR (XCDR (XCDR (prop)))         \
    : XCDR (XCAR (prop)))
 
 /* Return modification function of the composition.  */
 #define COMPOSITION_MODIFICATION_FUNC(prop)    \
-  (COMPOSITION_REGISTERD_P (prop)              \
+  (composition_registered_p (prop)             \
    ? XCDR (XCDR (XCDR (prop)))                 \
    : CONSP (prop) ? XCDR (prop) : Qnil)
 
@@ -199,43 +203,42 @@
 extern void compose_text (ptrdiff_t, ptrdiff_t, Lisp_Object, Lisp_Object,
                           Lisp_Object);
 
-/* Return the method of composition.  */
+/* Return the method of a composition with property PROP.  */
+
 COMPOSITE_INLINE enum composition_method
 composition_method (Lisp_Object prop)
 {
-  Lisp_Object temp;
-
-  return (COMPOSITION_REGISTERD_P (prop)
-         ? composition_table[COMPOSITION_ID (prop)]->method
-         : (temp = XCDR (XCAR (prop)),
-            (NILP (temp)
+  if (composition_registered_p (prop))
+    return composition_table[COMPOSITION_ID (prop)]->method;
+  else
+    {
+      Lisp_Object temp = XCDR (XCAR (prop));
+      return (NILP (temp)
              ? COMPOSITION_RELATIVE
-             : (INTEGERP (temp) || STRINGP (temp))
+             : INTEGERP (temp) || STRINGP (temp)
              ? COMPOSITION_WITH_ALTCHARS
-             : COMPOSITION_WITH_RULE_ALTCHARS)));
+             : COMPOSITION_WITH_RULE_ALTCHARS);
+    }
 }
 
-/* Return 1 if the composition is valid.  It is valid if
-   length of the composition equals to (END - START).  */
+/* Given offsets START and END, return true if PROP is a valid composition
+   property with length END - START.  */
+
 COMPOSITE_INLINE bool
 composition_valid_p (ptrdiff_t start, ptrdiff_t end, Lisp_Object prop)
 {
-  Lisp_Object temp;
-
   return (CONSP (prop)
-         && (COMPOSITION_REGISTERD_P (prop)
+         && (composition_registered_p (prop)
              ? (COMPOSITION_ID (prop) >= 0
                 && COMPOSITION_ID (prop) <= n_compositions
                 && CONSP (XCDR (prop)))
-             : (temp = XCAR (prop),
-                (CONSP (temp)
-                 && (temp = XCDR (temp),
-                     (NILP (temp)
-                      || STRINGP (temp)
-                      || VECTORP (temp)
-                      || INTEGERP (temp)
-                      || CONSP (temp))))))
-         && (end - start) == COMPOSITION_LENGTH (prop));
+             : (CONSP (XCAR (prop))
+                 && (NILP (XCDR (XCAR (prop)))
+                     || STRINGP (XCDR (XCAR (prop)))
+                     || VECTORP (XCDR (XCAR (prop)))
+                     || INTEGERP (XCDR (XCAR (prop)))
+                     || CONSP (XCDR (XCAR (prop))))))
+         && COMPOSITION_LENGTH (prop) == end - start);
 }
 
 /* Macros for lispy glyph-string.  This is completely different from


reply via email to

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