]> code.delx.au - gnu-emacs/blobdiff - src/intervals.c
(xg_separator_p) <separator_names>: Move to file scope.
[gnu-emacs] / src / intervals.c
index e69ff701387d500eeb08970dcb1319a2bdd30cc8..a695976b8b73af951feee62b8507657373fbe1e1 100644 (file)
@@ -1,12 +1,12 @@
 /* Code for doing intervals.
-   Copyright (C) 1993, 1994, 1995, 1997, 1998, 2002, 2003, 2004,
-                 2005, 2006 Free Software Foundation, Inc.
+   Copyright (C) 1993, 1994, 1995, 1997, 1998, 2001, 2002, 2003, 2004,
+                 2005, 2006, 2007  Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
 GNU Emacs is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
+the Free Software Foundation; either version 3, or (at your option)
 any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
@@ -125,18 +125,24 @@ merge_properties (source, target)
   while (CONSP (o))
     {
       sym = XCAR (o);
-      val = Fmemq (sym, target->plist);
+      o = XCDR (o);
+      CHECK_CONS (o);
+
+      val = target->plist;
+      while (CONSP (val) && !EQ (XCAR (val), sym))
+       {
+         val = XCDR (val);
+         if (!CONSP (val))
+           break;
+         val = XCDR (val);
+       }
 
       if (NILP (val))
        {
-         o = XCDR (o);
-         CHECK_CONS (o);
          val = XCAR (o);
          target->plist = Fcons (sym, Fcons (val, target->plist));
-         o = XCDR (o);
        }
-      else
-       o = Fcdr (XCDR (o));
+      o = XCDR (o);
     }
 }
 
@@ -147,8 +153,8 @@ int
 intervals_equal (i0, i1)
      INTERVAL i0, i1;
 {
-  register Lisp_Object i0_cdr, i0_sym, i1_val;
-  register int i1_len;
+  register Lisp_Object i0_cdr, i0_sym;
+  register Lisp_Object i1_cdr, i1_val;
 
   if (DEFAULT_INTERVAL_P (i0) && DEFAULT_INTERVAL_P (i1))
     return 1;
@@ -156,39 +162,43 @@ intervals_equal (i0, i1)
   if (DEFAULT_INTERVAL_P (i0) || DEFAULT_INTERVAL_P (i1))
     return 0;
 
-  i1_len = XFASTINT (Flength (i1->plist));
-  if (i1_len & 0x1)            /* Paranoia -- plists are always even */
-    abort ();
-  i1_len /= 2;
   i0_cdr = i0->plist;
-  while (CONSP (i0_cdr))
+  i1_cdr = i1->plist;
+  while (CONSP (i0_cdr) && CONSP (i1_cdr))
     {
-      /* Lengths of the two plists were unequal.  */
-      if (i1_len == 0)
-       return 0;
-
       i0_sym = XCAR (i0_cdr);
-      i1_val = Fmemq (i0_sym, i1->plist);
+      i0_cdr = XCDR (i0_cdr);
+      if (!CONSP (i0_cdr))
+       return 0;               /* abort (); */
+      i1_val = i1->plist;
+      while (CONSP (i1_val) && !EQ (XCAR (i1_val), i0_sym))
+       {
+         i1_val = XCDR (i1_val);
+         if (!CONSP (i1_val))
+           return 0;           /* abort (); */
+         i1_val = XCDR (i1_val);
+       }
 
       /* i0 has something i1 doesn't.  */
       if (EQ (i1_val, Qnil))
        return 0;
 
       /* i0 and i1 both have sym, but it has different values in each.  */
-      i0_cdr = XCDR (i0_cdr);
-      CHECK_CONS (i0_cdr);
-      if (!EQ (Fcar (Fcdr (i1_val)), XCAR (i0_cdr)))
+      if (!CONSP (i1_val)
+         || (i1_val = XCDR (i1_val), !CONSP (i1_val))
+         || !EQ (XCAR (i1_val), XCAR (i0_cdr)))
        return 0;
 
       i0_cdr = XCDR (i0_cdr);
-      i1_len--;
-    }
 
-  /* Lengths of the two plists were unequal.  */
-  if (i1_len > 0)
-    return 0;
+      i1_cdr = XCDR (i1_cdr);
+      if (!CONSP (i1_cdr))
+       return 0;               /* abort (); */
+      i1_cdr = XCDR (i1_cdr);
+    }
 
-  return 1;
+  /* Lengths of the two plists were equal.  */
+  return (NILP (i0_cdr) && NILP (i1_cdr));
 }
 \f
 
@@ -2016,6 +2026,10 @@ set_point_both (buffer, charpos, bytepos)
   register INTERVAL to, from, toprev, fromprev;
   int buffer_point;
   int old_position = BUF_PT (buffer);
+  /* This ensures that we move forward past intangible text when the
+     initial position is the same as the destination, in the rare
+     instances where this is important, e.g. in line-move-finish
+     (simple.el).  */
   int backwards = (charpos < old_position ? 1 : 0);
   int have_overlays;
   int original_position;
@@ -2186,7 +2200,7 @@ set_point_both (buffer, charpos, bytepos)
 
   temp_set_point_both (buffer, charpos, bytepos);
 
-  /* We run point-left and point-entered hooks here, iff the
+  /* We run point-left and point-entered hooks here, if the
      two intervals are not equivalent.  These hooks take
      (old_point, new_point) as arguments.  */
   if (NILP (Vinhibit_point_motion_hooks)
@@ -2534,7 +2548,7 @@ set_intervals_multibyte_1 (i, multi_flag, start, start_byte, end, end_byte)
          temp = CHAR_TO_BYTE (left_end);
 
          /* If LEFT_END_BYTE is in the middle of a character,
-            adjust it and LEFT_END to a char boundary.  */ 
+            adjust it and LEFT_END to a char boundary.  */
          if (left_end_byte > temp)
            {
              left_end_byte = temp;
@@ -2566,7 +2580,7 @@ set_intervals_multibyte_1 (i, multi_flag, start, start_byte, end, end_byte)
          right_start = BYTE_TO_CHAR (right_start_byte);
 
          /* If RIGHT_START_BYTE is in the middle of a character,
-            adjust it and RIGHT_START to a char boundary.  */ 
+            adjust it and RIGHT_START to a char boundary.  */
          temp = CHAR_TO_BYTE (right_start);
 
          if (right_start_byte < temp)