* composite.c, data.c, dbusbind.c, dired.c: Use bool for booleans.
[bpt/emacs.git] / src / composite.c
index 90a2392..eddabb6 100644 (file)
@@ -1,5 +1,5 @@
 /* Composite sequence support.
-   Copyright (C) 2001-2011 Free Software Foundation, Inc.
+   Copyright (C) 2001-2012 Free Software Foundation, Inc.
    Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
      National Institute of Advanced Industrial Science and Technology (AIST)
      Registration Number H14PRO021
@@ -23,10 +23,13 @@ You should have received a copy of the GNU General Public License
 along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <config.h>
+
+#define COMPOSITE_INLINE EXTERN_INLINE
+
 #include <setjmp.h>
 #include "lisp.h"
-#include "buffer.h"
 #include "character.h"
+#include "buffer.h"
 #include "coding.h"
 #include "intervals.h"
 #include "window.h"
@@ -158,9 +161,6 @@ static Lisp_Object Qauto_composition_function;
    auto-compositions.  */
 #define MAX_AUTO_COMPOSITION_LOOKBACK 3
 
-static Lisp_Object Fcomposition_get_gstring (Lisp_Object, Lisp_Object,
-                                            Lisp_Object, Lisp_Object);
-
 /* Temporary variable used in macros COMPOSITION_XXX.  */
 Lisp_Object composition_temp;
 
@@ -240,13 +240,13 @@ get_composition_id (ptrdiff_t charpos, ptrdiff_t bytepos, ptrdiff_t nchars,
        for (i = 0; i < nchars; i++)
          {
            FETCH_STRING_CHAR_ADVANCE (ch, string, charpos, bytepos);
-           XVECTOR (key)->contents[i] = make_number (ch);
+           ASET (key, i, make_number (ch));
          }
       else
        for (i = 0; i < nchars; i++)
          {
            FETCH_CHAR_ADVANCE (ch, charpos, bytepos);
-           XVECTOR (key)->contents[i] = make_number (ch);
+           ASET (key, i, make_number (ch));
          }
     }
   else
@@ -329,7 +329,7 @@ get_composition_id (ptrdiff_t charpos, ptrdiff_t bytepos, ptrdiff_t nchars,
     memory_full (SIZE_MAX);
 
   /* Register the composition in composition_table.  */
-  cmp = (struct composition *) xmalloc (sizeof (struct composition));
+  cmp = xmalloc (sizeof *cmp);
 
   cmp->method = method;
   cmp->hash_index = hash_index;
@@ -355,7 +355,7 @@ get_composition_id (ptrdiff_t charpos, ptrdiff_t bytepos, ptrdiff_t nchars,
   else
     {
       /* Rule-base composition.  */
-      float leftmost = 0.0, rightmost;
+      double leftmost = 0.0, rightmost;
 
       ch = XINT (key_contents[0]);
       rightmost = ch != '\t' ? CHAR_WIDTH (ch) : 1;
@@ -364,7 +364,7 @@ get_composition_id (ptrdiff_t charpos, ptrdiff_t bytepos, ptrdiff_t nchars,
        {
          int rule, gref, nref;
          int this_width;
-         float this_left;
+         double this_left;
 
          rule = XINT (key_contents[i]);
          ch = XINT (key_contents[i + 1]);
@@ -428,7 +428,7 @@ get_composition_id (ptrdiff_t charpos, ptrdiff_t bytepos, ptrdiff_t nchars,
 
    This doesn't check the validity of composition.  */
 
-int
+bool
 find_composition (ptrdiff_t pos, ptrdiff_t limit,
                  ptrdiff_t *start, ptrdiff_t *end,
                  Lisp_Object *prop, Lisp_Object object)
@@ -709,7 +709,7 @@ static Lisp_Object fill_gstring_header (Lisp_Object, Lisp_Object,
                                         Lisp_Object, Lisp_Object,
                                         Lisp_Object);
 
-int
+bool
 composition_gstring_p (Lisp_Object gstring)
 {
   Lisp_Object header;
@@ -765,7 +765,7 @@ composition_gstring_width (Lisp_Object gstring, ptrdiff_t from, ptrdiff_t to,
        }
       metrics->width = metrics->lbearing = metrics->rbearing = 0;
     }
-  for (glyph = &LGSTRING_GLYPH (gstring, from); from < to; from++, glyph++)
+  for (glyph = lgstring_glyph_addr (gstring, from); from < to; from++, glyph++)
     {
       int x;
 
@@ -950,23 +950,12 @@ autocmp_chars (Lisp_Object rule, ptrdiff_t charpos, ptrdiff_t bytepos, ptrdiff_t
                                       string);
   if (NILP (LGSTRING_ID (lgstring)))
     {
-      Lisp_Object args[6];
-
       /* Save point as marker before calling out to lisp.  */
       if (NILP (string))
-       {
-         Lisp_Object m = Fmake_marker ();
-         set_marker_both (m, Qnil, pt, pt_byte);
-         record_unwind_protect (restore_point_unwind, m);
-       }
-
-      args[0] = Vauto_composition_function;
-      args[1] = AREF (rule, 2);
-      args[2] = pos;
-      args[3] = make_number (to);
-      args[4] = font_object;
-      args[5] = string;
-      lgstring = safe_call (6, args);
+       record_unwind_protect (restore_point_unwind,
+                              build_marker (current_buffer, pt, pt_byte));
+      lgstring = safe_call (6, Vauto_composition_function, AREF (rule, 2),
+                           pos, make_number (to), font_object, string);
     }
   return unbind_to (count, lgstring);
 }
@@ -1223,11 +1212,13 @@ composition_compute_stop_pos (struct composition_it *cmp_it, ptrdiff_t charpos,
    string.  In that case, FACE must not be NULL.
 
    If the character is composed, setup members of CMP_IT (id, nglyphs,
-   from, to, reversed_p), and return 1.  Otherwise, update
-   CMP_IT->stop_pos, and return 0.  */
+   from, to, reversed_p), and return true.  Otherwise, update
+   CMP_IT->stop_pos, and return false.  */
 
-int
-composition_reseat_it (struct composition_it *cmp_it, ptrdiff_t charpos, ptrdiff_t bytepos, ptrdiff_t endpos, struct window *w, struct face *face, Lisp_Object string)
+bool
+composition_reseat_it (struct composition_it *cmp_it, ptrdiff_t charpos,
+                      ptrdiff_t bytepos, ptrdiff_t endpos, struct window *w,
+                      struct face *face, Lisp_Object string)
 {
   if (endpos < 0)
     endpos = NILP (string) ? BEGV : 0;
@@ -1308,7 +1299,7 @@ composition_reseat_it (struct composition_it *cmp_it, ptrdiff_t charpos, ptrdiff
              if (cmp_it->lookback == 0)
                goto no_composition;
              lgstring = Qnil;
-             /* Try to find a shorter compostion that starts after CPOS.  */
+             /* Try to find a shorter composition that starts after CPOS.  */
              composition_compute_stop_pos (cmp_it, charpos, bytepos, cpos,
                                            string);
              if (cmp_it->ch == -2 || cmp_it->stop_pos < charpos)
@@ -1493,10 +1484,10 @@ struct position_record
 /* This is like find_composition, but find an automatic composition
    instead.  It is assured that POS is not within a static
    composition.  If found, set *GSTRING to the glyph-string
-   representing the composition, and return 1.  Otherwise, *GSTRING to
-   Qnil, and return 0.  */
+   representing the composition, and return true.  Otherwise, *GSTRING to
+   Qnil, and return false.  */
 
-static int
+static bool
 find_automatic_composition (ptrdiff_t pos, ptrdiff_t limit,
                            ptrdiff_t *start, ptrdiff_t *end,
                            Lisp_Object *gstring, Lisp_Object string)
@@ -1509,7 +1500,7 @@ find_automatic_composition (ptrdiff_t pos, ptrdiff_t limit,
   int c;
   Lisp_Object window;
   struct window *w;
-  int need_adjustment = 0;
+  bool need_adjustment = 0;
 
   window = Fget_buffer_window (Fcurrent_buffer (), Qnil);
   if (NILP (window))