2543 |
/* Adjust search data for this change. */ |
/* Adjust search data for this change. */ |
2544 |
{ |
{ |
2545 |
int oldend = search_regs.end[sub]; |
int oldend = search_regs.end[sub]; |
2546 |
|
int oldstart = search_regs.start[sub]; |
2547 |
int change = newpoint - search_regs.end[sub]; |
int change = newpoint - search_regs.end[sub]; |
2548 |
int i; |
int i; |
2549 |
|
|
2550 |
for (i = 0; i < search_regs.num_regs; i++) |
for (i = 0; i < search_regs.num_regs; i++) |
2551 |
{ |
{ |
2552 |
if (search_regs.start[i] > oldend) |
if (search_regs.start[i] >= oldend) |
2553 |
search_regs.start[i] += change; |
search_regs.start[i] += change; |
2554 |
if (search_regs.end[i] > oldend) |
else if (search_regs.start[i] > oldstart) |
2555 |
|
search_regs.start[i] = oldstart; |
2556 |
|
if (search_regs.end[i] >= oldend) |
2557 |
search_regs.end[i] += change; |
search_regs.end[i] += change; |
2558 |
|
else if (search_regs.end[i] > oldstart) |
2559 |
|
search_regs.end[i] = oldstart; |
2560 |
} |
} |
2561 |
} |
} |
2562 |
|
|
2625 |
if the last match was on a buffer; integers or nil if a string was matched. |
if the last match was on a buffer; integers or nil if a string was matched. |
2626 |
Use `store-match-data' to reinstate the data in this list. |
Use `store-match-data' to reinstate the data in this list. |
2627 |
|
|
2628 |
If INTEGERS (the optional first argument) is non-nil, always use integers |
If INTEGERS (the optional first argument) is non-nil, always use |
2629 |
\(rather than markers) to represent buffer positions. |
integers \(rather than markers) to represent buffer positions. In |
2630 |
|
this case, and if the last match was in a buffer, the buffer will get |
2631 |
|
stored as one additional element at the end of the list. |
2632 |
|
|
2633 |
If REUSE is a list, reuse it as part of the value. If REUSE is long enough |
If REUSE is a list, reuse it as part of the value. If REUSE is long enough |
2634 |
to hold all the values, and if INTEGERS is non-nil, no consing is done. |
to hold all the values, and if INTEGERS is non-nil, no consing is done. |
2635 |
|
|
2646 |
|
|
2647 |
prev = Qnil; |
prev = Qnil; |
2648 |
|
|
2649 |
data = (Lisp_Object *) alloca ((2 * search_regs.num_regs) |
data = (Lisp_Object *) alloca ((2 * search_regs.num_regs + 1) |
2650 |
* sizeof (Lisp_Object)); |
* sizeof (Lisp_Object)); |
2651 |
|
|
2652 |
len = -1; |
len = 0; |
2653 |
for (i = 0; i < search_regs.num_regs; i++) |
for (i = 0; i < search_regs.num_regs; i++) |
2654 |
{ |
{ |
2655 |
int start = search_regs.start[i]; |
int start = search_regs.start[i]; |
2676 |
/* last_thing_searched must always be Qt, a buffer, or Qnil. */ |
/* last_thing_searched must always be Qt, a buffer, or Qnil. */ |
2677 |
abort (); |
abort (); |
2678 |
|
|
2679 |
len = i; |
len = 2*(i+1); |
2680 |
} |
} |
2681 |
else |
else |
2682 |
data[2 * i] = data [2 * i + 1] = Qnil; |
data[2 * i] = data [2 * i + 1] = Qnil; |
2683 |
} |
} |
2684 |
|
|
2685 |
|
if (BUFFERP(last_thing_searched) |
2686 |
|
&& ! NILP (integers)) |
2687 |
|
{ |
2688 |
|
XSETBUFFER(data[len], last_thing_searched); |
2689 |
|
len++; |
2690 |
|
} |
2691 |
|
|
2692 |
/* If REUSE is not usable, cons up the values and return them. */ |
/* If REUSE is not usable, cons up the values and return them. */ |
2693 |
if (! CONSP (reuse)) |
if (! CONSP (reuse)) |
2694 |
return Flist (2 * len + 2, data); |
return Flist (len, data); |
2695 |
|
|
2696 |
/* If REUSE is a list, store as many value elements as will fit |
/* If REUSE is a list, store as many value elements as will fit |
2697 |
into the elements of REUSE. */ |
into the elements of REUSE. */ |
2698 |
for (i = 0, tail = reuse; CONSP (tail); |
for (i = 0, tail = reuse; CONSP (tail); |
2699 |
i++, tail = XCDR (tail)) |
i++, tail = XCDR (tail)) |
2700 |
{ |
{ |
2701 |
if (i < 2 * len + 2) |
if (i < len) |
2702 |
XSETCAR (tail, data[i]); |
XSETCAR (tail, data[i]); |
2703 |
else |
else |
2704 |
XSETCAR (tail, Qnil); |
XSETCAR (tail, Qnil); |
2707 |
|
|
2708 |
/* If we couldn't fit all value elements into REUSE, |
/* If we couldn't fit all value elements into REUSE, |
2709 |
cons up the rest of them and add them to the end of REUSE. */ |
cons up the rest of them and add them to the end of REUSE. */ |
2710 |
if (i < 2 * len + 2) |
if (i < len) |
2711 |
XSETCDR (prev, Flist (2 * len + 2 - i, data + i)); |
XSETCDR (prev, Flist (len - i, data + i)); |
2712 |
|
|
2713 |
return reuse; |
return reuse; |
2714 |
} |
} |
2729 |
if (!CONSP (list) && !NILP (list)) |
if (!CONSP (list) && !NILP (list)) |
2730 |
list = wrong_type_argument (Qconsp, list); |
list = wrong_type_argument (Qconsp, list); |
2731 |
|
|
2732 |
/* Unless we find a marker with a buffer in LIST, assume that this |
/* Unless we find a marker with a buffer or an explicit buffer |
2733 |
match data came from a string. */ |
in LIST, assume that this match data came from a string. */ |
2734 |
last_thing_searched = Qt; |
last_thing_searched = Qt; |
2735 |
|
|
2736 |
/* Allocate registers if they don't already exist. */ |
/* Allocate registers if they don't already exist. */ |
2761 |
|
|
2762 |
search_regs.num_regs = length; |
search_regs.num_regs = length; |
2763 |
} |
} |
|
} |
|
|
|
|
|
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; |
|
2764 |
|
|
2765 |
if (MARKERP (marker)) |
for (i = 0;; i++) |
2766 |
{ |
{ |
2767 |
if (XMARKER (marker)->buffer == 0) |
marker = Fcar (list); |
2768 |
XSETFASTINT (marker, 0); |
if (BUFFERP(marker)) |
2769 |
else |
{ |
2770 |
XSETBUFFER (last_thing_searched, XMARKER (marker)->buffer); |
XSETBUFFER(last_thing_searched, marker); |
2771 |
} |
break; |
2772 |
|
} |
2773 |
|
if (i >= length) |
2774 |
|
break; |
2775 |
|
if (NILP (marker)) |
2776 |
|
{ |
2777 |
|
search_regs.start[i] = -1; |
2778 |
|
list = Fcdr (list); |
2779 |
|
} |
2780 |
|
else |
2781 |
|
{ |
2782 |
|
int from; |
2783 |
|
|
2784 |
|
if (MARKERP (marker)) |
2785 |
|
{ |
2786 |
|
if (XMARKER (marker)->buffer == 0) |
2787 |
|
XSETFASTINT (marker, 0); |
2788 |
|
else |
2789 |
|
XSETBUFFER (last_thing_searched, XMARKER (marker)->buffer); |
2790 |
|
} |
2791 |
|
|
2792 |
|
CHECK_NUMBER_COERCE_MARKER (marker); |
2793 |
|
from = XINT (marker); |
2794 |
|
list = Fcdr (list); |
2795 |
|
|
2796 |
|
marker = Fcar (list); |
2797 |
|
if (MARKERP (marker) && XMARKER (marker)->buffer == 0) |
2798 |
|
XSETFASTINT (marker, 0); |
2799 |
|
|
2800 |
|
CHECK_NUMBER_COERCE_MARKER (marker); |
2801 |
|
search_regs.start[i] = from; |
2802 |
|
search_regs.end[i] = XINT (marker); |
2803 |
|
} |
2804 |
|
list = Fcdr (list); |
2805 |
|
} |
2806 |
|
|
2807 |
CHECK_NUMBER_COERCE_MARKER (marker); |
for (; i < search_regs.num_regs; i++) |
2808 |
from = XINT (marker); |
search_regs.start[i] = -1; |
2809 |
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); |
|
|
} |
|
2810 |
|
|
2811 |
return Qnil; |
return Qnil; |
2812 |
} |
} |
2815 |
during the execution of a sentinel or filter. */ |
during the execution of a sentinel or filter. */ |
2816 |
static int search_regs_saved; |
static int search_regs_saved; |
2817 |
static struct re_registers saved_search_regs; |
static struct re_registers saved_search_regs; |
2818 |
|
static Lisp_Object saved_last_thing_searched; |
2819 |
|
|
2820 |
/* Called from Flooking_at, Fstring_match, search_buffer, Fstore_match_data |
/* Called from Flooking_at, Fstring_match, search_buffer, Fstore_match_data |
2821 |
if asynchronous code (filter or sentinel) is running. */ |
if asynchronous code (filter or sentinel) is running. */ |
2827 |
saved_search_regs.num_regs = search_regs.num_regs; |
saved_search_regs.num_regs = search_regs.num_regs; |
2828 |
saved_search_regs.start = search_regs.start; |
saved_search_regs.start = search_regs.start; |
2829 |
saved_search_regs.end = search_regs.end; |
saved_search_regs.end = search_regs.end; |
2830 |
|
saved_last_thing_searched = last_thing_searched; |
2831 |
|
last_thing_searched = Qnil; |
2832 |
search_regs.num_regs = 0; |
search_regs.num_regs = 0; |
2833 |
search_regs.start = 0; |
search_regs.start = 0; |
2834 |
search_regs.end = 0; |
search_regs.end = 0; |
2851 |
search_regs.num_regs = saved_search_regs.num_regs; |
search_regs.num_regs = saved_search_regs.num_regs; |
2852 |
search_regs.start = saved_search_regs.start; |
search_regs.start = saved_search_regs.start; |
2853 |
search_regs.end = saved_search_regs.end; |
search_regs.end = saved_search_regs.end; |
2854 |
|
last_thing_searched = saved_last_thing_searched; |
2855 |
|
saved_last_thing_searched = Qnil; |
2856 |
search_regs_saved = 0; |
search_regs_saved = 0; |
2857 |
} |
} |
2858 |
} |
} |