}
re_match_object = Qnil;
-
+
i = re_match_2 (bufp, (char *) p1, s1, (char *) p2, s2,
PT_BYTE - BEGV_BYTE, &search_regs,
ZV_BYTE - BEGV_BYTE);
immediate_quit = 0;
-
+
if (i == -2)
matcher_overflow ();
STRING_MULTIBYTE (string));
immediate_quit = 1;
re_match_object = string;
-
+
val = re_search (bufp, (char *) SDATA (string),
SBYTES (string), pos_byte,
SBYTES (string) - pos_byte,
If third arg START is non-nil, start search at that index in STRING.
For index of first char beyond the match, do (match-end 0).
`match-end' and `match-beginning' also give indices of substrings
-matched by parenthesis constructs in the pattern. */)
+matched by parenthesis constructs in the pattern.
+
+You can use the function `match-string' to extract the substrings
+matched by the parenthesis constructions in REGEXP. */)
(regexp, string, start)
Lisp_Object regexp, string, start;
{
0, STRING_MULTIBYTE (string));
immediate_quit = 1;
re_match_object = string;
-
+
val = re_search (bufp, (char *) SDATA (string),
SBYTES (string), 0,
SBYTES (string), 0);
int
fast_c_string_match_ignore_case (regexp, string)
Lisp_Object regexp;
- char *string;
+ const char *string;
{
int val;
struct re_pattern_buffer *bufp;
int allow_quit;
{
struct region_cache *newline_cache;
- int direction;
+ int direction;
if (count > 0)
{
ceiling_byte = min (tem, ceiling_byte);
{
- /* The termination address of the dumb loop. */
+ /* The termination address of the dumb loop. */
register unsigned char *ceiling_addr
= BYTE_POS_ADDR (ceiling_byte) + 1;
register unsigned char *cursor
if (shortage == 0)
pos--;
-
+
return pos;
}
\f
s2 = 0;
}
re_match_object = Qnil;
-
+
while (n < 0)
{
int val;
int infinity, limit, stride_for_teases = 0;
register int *BM_tab;
int *BM_tab_base;
- register unsigned char *cursor, *p_limit;
+ register unsigned char *cursor, *p_limit;
register int i, j;
unsigned char *pat, *pat_end;
int multibyte = ! NILP (current_buffer->enable_multibyte_characters);
/* a single test, a test for having gone past the end of the */
/* permissible match region, to test for both possible matches (when */
/* the stride goes past the end immediately) and failure to */
- /* match (where you get nudged past the end one stride at a time). */
+ /* match (where you get nudged past the end one stride at a time). */
/* Here we make a "mickey mouse" BM table. The stride of the search */
/* is determined only by the last character of the putative match. */
/* If that character does not match, we will stride the proper */
/* distance to propose a match that superimposes it on the last */
/* instance of a character that matches it (per trt), or misses */
- /* it entirely if there is none. */
+ /* it entirely if there is none. */
dirlen = len_byte * direction;
infinity = dirlen - (lim_byte + pos_byte + len_byte + len_byte) * direction;
BM_tab[j] = dirlen - i;
/* A translation table is accompanied by its inverse -- see */
- /* comment following downcase_table for details */
+ /* comment following downcase_table for details */
if (this_translated)
{
int starting_ch = ch;
/* This loop can be coded for space rather than */
/* speed because it will usually run only once. */
/* (the reach is at most len + 21, and typically */
- /* does not exceed len) */
+ /* does not exceed len) */
while ((limit - pos_byte) * direction >= 0)
pos_byte += BM_tab[FETCH_BYTE (pos_byte)];
/* now run the same tests to distinguish going off the */
for (i = 0, i_byte = 0; i < len; )
{
int c;
-
+
FETCH_STRING_CHAR_ADVANCE (c, string, i, i_byte);
if (SYNTAX (c) != Sword)
{
int c;
int i_byte_orig = i_byte;
-
+
FETCH_STRING_CHAR_ADVANCE (c, string, i, i_byte);
if (SYNTAX (c) == Sword)
if (c == '\\')
{
FETCH_STRING_CHAR_ADVANCE (c, newtext, pos, pos_byte);
-
+
if (c == '&')
{
substart = search_regs.start[sub];
Fupcase_initials_region (make_number (search_regs.start[sub]),
make_number (newpoint));
+ /* 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;
+ }
+ }
+
/* Put point back where it was in the text. */
if (opoint <= 0)
TEMP_SET_PT (opoint + ZV);
/* Now move point "officially" to the start of the inserted replacement. */
move_if_not_intangible (newpoint);
-
+
return Qnil;
}
\f
Lisp_Object subexp;
{
return match_limit (subexp, 0);
-}
+}
DEFUN ("match-data", Fmatch_data, Smatch_data, 0, 2, 0,
doc: /* Return a list containing all info on what the last search matched.
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. */)
+to hold all the values, and if INTEGERS is non-nil, no consing is done.
+
+Return value is undefined if the last search failed. */)
(integers, reuse)
Lisp_Object integers, reuse;
{
last_thing_searched);
data[2 * i + 1] = Fmake_marker ();
Fset_marker (data[2 * i + 1],
- make_number (search_regs.end[i]),
+ make_number (search_regs.end[i]),
last_thing_searched);
}
else
if (!CONSP (list) && !NILP (list))
list = wrong_type_argument (Qconsp, list);
- /* Unless we find a marker with a buffer in LIST, assume that this
+ /* Unless we find a marker with a buffer in LIST, assume that this
match data came from a string. */
last_thing_searched = Qt;
list = Fcdr (list);
}
- return Qnil;
+ return Qnil;
}
/* If non-zero the match data have been saved in saved_search_regs
in = SDATA (string);
end = in + SBYTES (string);
- out = temp;
+ out = temp;
for (; in != end; in++)
{
out - temp,
STRING_MULTIBYTE (string));
}
-\f
+\f
void
syms_of_search ()
{