[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/src/search.c [emacs-unicode-2]
From: |
Miles Bader |
Subject: |
[Emacs-diffs] Changes to emacs/src/search.c [emacs-unicode-2] |
Date: |
Tue, 29 Jun 2004 13:08:11 -0400 |
Index: emacs/src/search.c
diff -c emacs/src/search.c:1.174.2.4 emacs/src/search.c:1.174.2.5
*** emacs/src/search.c:1.174.2.4 Mon Jun 28 07:29:24 2004
--- emacs/src/search.c Tue Jun 29 16:46:05 2004
***************
*** 2543,2557 ****
/* Adjust search data for this change. */
{
int oldend = search_regs.end[sub];
int change = newpoint - search_regs.end[sub];
int i;
for (i = 0; i < search_regs.num_regs; i++)
{
! if (search_regs.start[i] > oldend)
search_regs.start[i] += change;
! if (search_regs.end[i] > oldend)
search_regs.end[i] += change;
}
}
--- 2543,2562 ----
/* Adjust search data for this change. */
{
int oldend = search_regs.end[sub];
+ int oldstart = search_regs.start[sub];
int change = newpoint - search_regs.end[sub];
int i;
for (i = 0; i < search_regs.num_regs; i++)
{
! if (search_regs.start[i] >= oldend)
search_regs.start[i] += change;
! else if (search_regs.start[i] > oldstart)
! search_regs.start[i] = oldstart;
! if (search_regs.end[i] >= oldend)
search_regs.end[i] += change;
+ else if (search_regs.end[i] > oldstart)
+ search_regs.end[i] = oldstart;
}
}
***************
*** 2620,2627 ****
if the last match was on a buffer; integers or nil if a string was matched.
Use `store-match-data' to reinstate the data in this list.
! If INTEGERS (the optional first argument) is non-nil, always use integers
! \(rather than markers) to represent buffer positions.
If REUSE is a list, reuse it as part of the value. If REUSE is long enough
to hold all the values, and if INTEGERS is non-nil, no consing is done.
--- 2625,2635 ----
if the last match was on a buffer; integers or nil if a string was matched.
Use `store-match-data' to reinstate the data in this list.
! If INTEGERS (the optional first argument) is non-nil, always use
! integers \(rather than markers) to represent buffer positions. In
! this case, and if the last match was in a buffer, the buffer will get
! stored as one additional element at the end of the list.
!
If REUSE is a list, reuse it as part of the value. If REUSE is long enough
to hold all the values, and if INTEGERS is non-nil, no consing is done.
***************
*** 2638,2647 ****
prev = Qnil;
! data = (Lisp_Object *) alloca ((2 * search_regs.num_regs)
* sizeof (Lisp_Object));
! len = -1;
for (i = 0; i < search_regs.num_regs; i++)
{
int start = search_regs.start[i];
--- 2646,2655 ----
prev = Qnil;
! data = (Lisp_Object *) alloca ((2 * search_regs.num_regs + 1)
* sizeof (Lisp_Object));
! len = 0;
for (i = 0; i < search_regs.num_regs; i++)
{
int start = search_regs.start[i];
***************
*** 2668,2689 ****
/* last_thing_searched must always be Qt, a buffer, or Qnil. */
abort ();
! len = i;
}
else
data[2 * i] = data [2 * i + 1] = Qnil;
}
/* If REUSE is not usable, cons up the values and return them. */
if (! CONSP (reuse))
! return Flist (2 * len + 2, data);
/* If REUSE is a list, store as many value elements as will fit
into the elements of REUSE. */
for (i = 0, tail = reuse; CONSP (tail);
i++, tail = XCDR (tail))
{
! if (i < 2 * len + 2)
XSETCAR (tail, data[i]);
else
XSETCAR (tail, Qnil);
--- 2676,2704 ----
/* last_thing_searched must always be Qt, a buffer, or Qnil. */
abort ();
! len = 2*(i+1);
}
else
data[2 * i] = data [2 * i + 1] = Qnil;
}
+ if (BUFFERP(last_thing_searched)
+ && ! NILP (integers))
+ {
+ XSETBUFFER(data[len], last_thing_searched);
+ len++;
+ }
+
/* If REUSE is not usable, cons up the values and return them. */
if (! CONSP (reuse))
! return Flist (len, data);
/* If REUSE is a list, store as many value elements as will fit
into the elements of REUSE. */
for (i = 0, tail = reuse; CONSP (tail);
i++, tail = XCDR (tail))
{
! if (i < len)
XSETCAR (tail, data[i]);
else
XSETCAR (tail, Qnil);
***************
*** 2692,2699 ****
/* If we couldn't fit all value elements into REUSE,
cons up the rest of them and add them to the end of REUSE. */
! if (i < 2 * len + 2)
! XSETCDR (prev, Flist (2 * len + 2 - i, data + i));
return reuse;
}
--- 2707,2714 ----
/* If we couldn't fit all value elements into REUSE,
cons up the rest of them and add them to the end of REUSE. */
! if (i < len)
! XSETCDR (prev, Flist (len - i, data + i));
return reuse;
}
***************
*** 2714,2721 ****
if (!CONSP (list) && !NILP (list))
list = wrong_type_argument (Qconsp, list);
! /* Unless we find a marker with a buffer in LIST, assume that this
! match data came from a string. */
last_thing_searched = Qt;
/* Allocate registers if they don't already exist. */
--- 2729,2736 ----
if (!CONSP (list) && !NILP (list))
list = wrong_type_argument (Qconsp, list);
! /* Unless we find a marker with a buffer or an explicit buffer
! in LIST, assume that this match data came from a string. */
last_thing_searched = Qt;
/* Allocate registers if they don't already exist. */
***************
*** 2746,2787 ****
search_regs.num_regs = length;
}
- }
-
- for (i = 0; i < search_regs.num_regs; i++)
- {
- marker = Fcar (list);
- if (NILP (marker))
- {
- search_regs.start[i] = -1;
- list = Fcdr (list);
- }
- else
- {
- int from;
! if (MARKERP (marker))
! {
! if (XMARKER (marker)->buffer == 0)
! XSETFASTINT (marker, 0);
! else
! XSETBUFFER (last_thing_searched, XMARKER (marker)->buffer);
! }
! CHECK_NUMBER_COERCE_MARKER (marker);
! from = XINT (marker);
! list = Fcdr (list);
!
! marker = Fcar (list);
! if (MARKERP (marker) && XMARKER (marker)->buffer == 0)
! XSETFASTINT (marker, 0);
!
! CHECK_NUMBER_COERCE_MARKER (marker);
! search_regs.start[i] = from;
! search_regs.end[i] = XINT (marker);
! }
! list = Fcdr (list);
! }
return Qnil;
}
--- 2761,2812 ----
search_regs.num_regs = length;
}
! for (i = 0;; i++)
! {
! marker = Fcar (list);
! if (BUFFERP(marker))
! {
! XSETBUFFER(last_thing_searched, marker);
! break;
! }
! if (i >= length)
! break;
! if (NILP (marker))
! {
! search_regs.start[i] = -1;
! list = Fcdr (list);
! }
! else
! {
! int from;
!
! if (MARKERP (marker))
! {
! if (XMARKER (marker)->buffer == 0)
! XSETFASTINT (marker, 0);
! else
! XSETBUFFER (last_thing_searched, XMARKER (marker)->buffer);
! }
!
! CHECK_NUMBER_COERCE_MARKER (marker);
! from = XINT (marker);
! list = Fcdr (list);
!
! marker = Fcar (list);
! if (MARKERP (marker) && XMARKER (marker)->buffer == 0)
! XSETFASTINT (marker, 0);
!
! CHECK_NUMBER_COERCE_MARKER (marker);
! search_regs.start[i] = from;
! search_regs.end[i] = XINT (marker);
! }
! list = Fcdr (list);
! }
! for (; i < search_regs.num_regs; i++)
! search_regs.start[i] = -1;
! }
return Qnil;
}
***************
*** 2790,2795 ****
--- 2815,2821 ----
during the execution of a sentinel or filter. */
static int search_regs_saved;
static struct re_registers saved_search_regs;
+ static Lisp_Object saved_last_thing_searched;
/* Called from Flooking_at, Fstring_match, search_buffer, Fstore_match_data
if asynchronous code (filter or sentinel) is running. */
***************
*** 2801,2806 ****
--- 2827,2834 ----
saved_search_regs.num_regs = search_regs.num_regs;
saved_search_regs.start = search_regs.start;
saved_search_regs.end = search_regs.end;
+ saved_last_thing_searched = last_thing_searched;
+ last_thing_searched = Qnil;
search_regs.num_regs = 0;
search_regs.start = 0;
search_regs.end = 0;
***************
*** 2823,2829 ****
search_regs.num_regs = saved_search_regs.num_regs;
search_regs.start = saved_search_regs.start;
search_regs.end = saved_search_regs.end;
!
search_regs_saved = 0;
}
}
--- 2851,2858 ----
search_regs.num_regs = saved_search_regs.num_regs;
search_regs.start = saved_search_regs.start;
search_regs.end = saved_search_regs.end;
! last_thing_searched = saved_last_thing_searched;
! saved_last_thing_searched = Qnil;
search_regs_saved = 0;
}
}