/[emacs]/emacs/src/search.c
ViewVC logotype

Diff of /emacs/src/search.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.164 by handa, Mon May 13 00:06:01 2002 UTC revision 1.164.2.1 by miles, Fri Apr 4 06:21:03 2003 UTC
# Line 128  compile_pattern_1 (cp, pattern, translat Line 128  compile_pattern_1 (cp, pattern, translat
128    
129    if (multibyte == STRING_MULTIBYTE (pattern))    if (multibyte == STRING_MULTIBYTE (pattern))
130      {      {
131        raw_pattern = (unsigned char *) XSTRING (pattern)->data;        raw_pattern = (unsigned char *) SDATA (pattern);
132        raw_pattern_size = STRING_BYTES (XSTRING (pattern));        raw_pattern_size = SBYTES (pattern);
133      }      }
134    else if (multibyte)    else if (multibyte)
135      {      {
136        raw_pattern_size = count_size_as_multibyte (XSTRING (pattern)->data,        raw_pattern_size = count_size_as_multibyte (SDATA (pattern),
137                                                    XSTRING (pattern)->size);                                                    SCHARS (pattern));
138        raw_pattern = (unsigned char *) alloca (raw_pattern_size + 1);        raw_pattern = (unsigned char *) alloca (raw_pattern_size + 1);
139        copy_text (XSTRING (pattern)->data, raw_pattern,        copy_text (SDATA (pattern), raw_pattern,
140                   XSTRING (pattern)->size, 0, 1);                   SCHARS (pattern), 0, 1);
141      }      }
142    else    else
143      {      {
# Line 147  compile_pattern_1 (cp, pattern, translat Line 147  compile_pattern_1 (cp, pattern, translat
147           by subtracting nonascii-insert-offset from each non-ASCII char,           by subtracting nonascii-insert-offset from each non-ASCII char,
148           so that only the multibyte chars which really correspond to           so that only the multibyte chars which really correspond to
149           the chosen single-byte character set can possibly match.  */           the chosen single-byte character set can possibly match.  */
150        raw_pattern_size = XSTRING (pattern)->size;        raw_pattern_size = SCHARS (pattern);
151        raw_pattern = (unsigned char *) alloca (raw_pattern_size + 1);        raw_pattern = (unsigned char *) alloca (raw_pattern_size + 1);
152        copy_text (XSTRING (pattern)->data, raw_pattern,        copy_text (SDATA (pattern), raw_pattern,
153                   STRING_BYTES (XSTRING (pattern)), 1, 0);                   SBYTES (pattern), 1, 0);
154      }      }
155    
156    cp->regexp = Qnil;    cp->regexp = Qnil;
# Line 212  compile_pattern (pattern, regp, translat Line 212  compile_pattern (pattern, regp, translat
212        cp = *cpp;        cp = *cpp;
213        /* Entries are initialized to nil, and may be set to nil by        /* Entries are initialized to nil, and may be set to nil by
214           compile_pattern_1 if the pattern isn't valid.  Don't apply           compile_pattern_1 if the pattern isn't valid.  Don't apply
215           XSTRING in those cases.  However, compile_pattern_1 is only           string accessors in those cases.  However, compile_pattern_1
216           applied to the cache entry we pick here to reuse.  So nil           is only applied to the cache entry we pick here to reuse.  So
217           should never appear before a non-nil entry.  */           nil should never appear before a non-nil entry.  */
218        if (NILP (cp->regexp))        if (NILP (cp->regexp))
219          goto compile_it;          goto compile_it;
220        if (XSTRING (cp->regexp)->size == XSTRING (pattern)->size        if (SCHARS (cp->regexp) == SCHARS (pattern)
221            && STRING_MULTIBYTE (cp->regexp) == STRING_MULTIBYTE (pattern)            && STRING_MULTIBYTE (cp->regexp) == STRING_MULTIBYTE (pattern)
222            && !NILP (Fstring_equal (cp->regexp, pattern))            && !NILP (Fstring_equal (cp->regexp, pattern))
223            && EQ (cp->buf.translate, (! NILP (translate) ? translate : make_number (0)))            && EQ (cp->buf.translate, (! NILP (translate) ? translate : make_number (0)))
# Line 306  looking_at_1 (string, posix) Line 306  looking_at_1 (string, posix)
306      }      }
307    
308    re_match_object = Qnil;    re_match_object = Qnil;
309      
310    i = re_match_2 (bufp, (char *) p1, s1, (char *) p2, s2,    i = re_match_2 (bufp, (char *) p1, s1, (char *) p2, s2,
311                    PT_BYTE - BEGV_BYTE, &search_regs,                    PT_BYTE - BEGV_BYTE, &search_regs,
312                    ZV_BYTE - BEGV_BYTE);                    ZV_BYTE - BEGV_BYTE);
313    immediate_quit = 0;    immediate_quit = 0;
314      
315    if (i == -2)    if (i == -2)
316      matcher_overflow ();      matcher_overflow ();
317    
# Line 372  string_match_1 (regexp, string, start, p Line 372  string_match_1 (regexp, string, start, p
372      pos = 0, pos_byte = 0;      pos = 0, pos_byte = 0;
373    else    else
374      {      {
375        int len = XSTRING (string)->size;        int len = SCHARS (string);
376    
377        CHECK_NUMBER (start);        CHECK_NUMBER (start);
378        pos = XINT (start);        pos = XINT (start);
# Line 390  string_match_1 (regexp, string, start, p Line 390  string_match_1 (regexp, string, start, p
390                            STRING_MULTIBYTE (string));                            STRING_MULTIBYTE (string));
391    immediate_quit = 1;    immediate_quit = 1;
392    re_match_object = string;    re_match_object = string;
393      
394    val = re_search (bufp, (char *) XSTRING (string)->data,    val = re_search (bufp, (char *) SDATA (string),
395                     STRING_BYTES (XSTRING (string)), pos_byte,                     SBYTES (string), pos_byte,
396                     STRING_BYTES (XSTRING (string)) - pos_byte,                     SBYTES (string) - pos_byte,
397                     &search_regs);                     &search_regs);
398    immediate_quit = 0;    immediate_quit = 0;
399    last_thing_searched = Qt;    last_thing_searched = Qt;
# Line 419  Case is ignored if `case-fold-search' is Line 419  Case is ignored if `case-fold-search' is
419  If third arg START is non-nil, start search at that index in STRING.  If third arg START is non-nil, start search at that index in STRING.
420  For index of first char beyond the match, do (match-end 0).  For index of first char beyond the match, do (match-end 0).
421  `match-end' and `match-beginning' also give indices of substrings  `match-end' and `match-beginning' also give indices of substrings
422  matched by parenthesis constructs in the pattern.  */)  matched by parenthesis constructs in the pattern.
423    
424    You can use the function `match-string' to extract the substrings
425    matched by the parenthesis constructions in REGEXP. */)
426       (regexp, string, start)       (regexp, string, start)
427       Lisp_Object regexp, string, start;       Lisp_Object regexp, string, start;
428  {  {
# Line 455  fast_string_match (regexp, string) Line 458  fast_string_match (regexp, string)
458                            0, STRING_MULTIBYTE (string));                            0, STRING_MULTIBYTE (string));
459    immediate_quit = 1;    immediate_quit = 1;
460    re_match_object = string;    re_match_object = string;
461      
462    val = re_search (bufp, (char *) XSTRING (string)->data,    val = re_search (bufp, (char *) SDATA (string),
463                     STRING_BYTES (XSTRING (string)), 0,                     SBYTES (string), 0,
464                     STRING_BYTES (XSTRING (string)), 0);                     SBYTES (string), 0);
465    immediate_quit = 0;    immediate_quit = 0;
466    return val;    return val;
467  }  }
# Line 473  extern Lisp_Object Vascii_downcase_table Line 476  extern Lisp_Object Vascii_downcase_table
476  int  int
477  fast_c_string_match_ignore_case (regexp, string)  fast_c_string_match_ignore_case (regexp, string)
478       Lisp_Object regexp;       Lisp_Object regexp;
479       char *string;       const char *string;
480  {  {
481    int val;    int val;
482    struct re_pattern_buffer *bufp;    struct re_pattern_buffer *bufp;
# Line 547  scan_buffer (target, start, end, count, Line 550  scan_buffer (target, start, end, count,
550       int allow_quit;       int allow_quit;
551  {  {
552    struct region_cache *newline_cache;    struct region_cache *newline_cache;
553    int direction;    int direction;
554    
555    if (count > 0)    if (count > 0)
556      {      {
# Line 608  scan_buffer (target, start, end, count, Line 611  scan_buffer (target, start, end, count,
611          ceiling_byte = min (tem, ceiling_byte);          ceiling_byte = min (tem, ceiling_byte);
612    
613          {          {
614            /* The termination address of the dumb loop.  */            /* The termination address of the dumb loop.  */
615            register unsigned char *ceiling_addr            register unsigned char *ceiling_addr
616              = BYTE_POS_ADDR (ceiling_byte) + 1;              = BYTE_POS_ADDR (ceiling_byte) + 1;
617            register unsigned char *cursor            register unsigned char *cursor
# Line 853  find_before_next_newline (from, to, cnt) Line 856  find_before_next_newline (from, to, cnt)
856    
857    if (shortage == 0)    if (shortage == 0)
858      pos--;      pos--;
859      
860    return pos;    return pos;
861  }  }
862    
# Line 939  static int Line 942  static int
942  trivial_regexp_p (regexp)  trivial_regexp_p (regexp)
943       Lisp_Object regexp;       Lisp_Object regexp;
944  {  {
945    int len = STRING_BYTES (XSTRING (regexp));    int len = SBYTES (regexp);
946    unsigned char *s = XSTRING (regexp)->data;    unsigned char *s = SDATA (regexp);
947    while (--len >= 0)    while (--len >= 0)
948      {      {
949        switch (*s++)        switch (*s++)
# Line 1011  search_buffer (string, pos, pos_byte, li Line 1014  search_buffer (string, pos, pos_byte, li
1014       Lisp_Object inverse_trt;       Lisp_Object inverse_trt;
1015       int posix;       int posix;
1016  {  {
1017    int len = XSTRING (string)->size;    int len = SCHARS (string);
1018    int len_byte = STRING_BYTES (XSTRING (string));    int len_byte = SBYTES (string);
1019    register int i;    register int i;
1020    
1021    if (running_asynch_code)    if (running_asynch_code)
# Line 1059  search_buffer (string, pos, pos_byte, li Line 1062  search_buffer (string, pos, pos_byte, li
1062            s2 = 0;            s2 = 0;
1063          }          }
1064        re_match_object = Qnil;        re_match_object = Qnil;
1065      
1066        while (n < 0)        while (n < 0)
1067          {          {
1068            int val;            int val;
# Line 1136  search_buffer (string, pos, pos_byte, li Line 1139  search_buffer (string, pos, pos_byte, li
1139        int raw_pattern_size_byte;        int raw_pattern_size_byte;
1140        unsigned char *patbuf;        unsigned char *patbuf;
1141        int multibyte = !NILP (current_buffer->enable_multibyte_characters);        int multibyte = !NILP (current_buffer->enable_multibyte_characters);
1142        unsigned char *base_pat = XSTRING (string)->data;        unsigned char *base_pat = SDATA (string);
1143        int charset_base = -1;        int charset_base = -1;
1144        int boyer_moore_ok = 1;        int boyer_moore_ok = 1;
1145    
# Line 1146  search_buffer (string, pos, pos_byte, li Line 1149  search_buffer (string, pos, pos_byte, li
1149    
1150        if (multibyte == STRING_MULTIBYTE (string))        if (multibyte == STRING_MULTIBYTE (string))
1151          {          {
1152            raw_pattern = (unsigned char *) XSTRING (string)->data;            raw_pattern = (unsigned char *) SDATA (string);
1153            raw_pattern_size = XSTRING (string)->size;            raw_pattern_size = SCHARS (string);
1154            raw_pattern_size_byte = STRING_BYTES (XSTRING (string));            raw_pattern_size_byte = SBYTES (string);
1155          }          }
1156        else if (multibyte)        else if (multibyte)
1157          {          {
1158            raw_pattern_size = XSTRING (string)->size;            raw_pattern_size = SCHARS (string);
1159            raw_pattern_size_byte            raw_pattern_size_byte
1160              = count_size_as_multibyte (XSTRING (string)->data,              = count_size_as_multibyte (SDATA (string),
1161                                         raw_pattern_size);                                         raw_pattern_size);
1162            raw_pattern = (unsigned char *) alloca (raw_pattern_size_byte + 1);            raw_pattern = (unsigned char *) alloca (raw_pattern_size_byte + 1);
1163            copy_text (XSTRING (string)->data, raw_pattern,            copy_text (SDATA (string), raw_pattern,
1164                       XSTRING (string)->size, 0, 1);                       SCHARS (string), 0, 1);
1165          }          }
1166        else        else
1167          {          {
# Line 1168  search_buffer (string, pos, pos_byte, li Line 1171  search_buffer (string, pos, pos_byte, li
1171               by subtracting nonascii-insert-offset from each non-ASCII char,               by subtracting nonascii-insert-offset from each non-ASCII char,
1172               so that only the multibyte chars which really correspond to               so that only the multibyte chars which really correspond to
1173               the chosen single-byte character set can possibly match.  */               the chosen single-byte character set can possibly match.  */
1174            raw_pattern_size = XSTRING (string)->size;            raw_pattern_size = SCHARS (string);
1175            raw_pattern_size_byte = XSTRING (string)->size;            raw_pattern_size_byte = SCHARS (string);
1176            raw_pattern = (unsigned char *) alloca (raw_pattern_size + 1);            raw_pattern = (unsigned char *) alloca (raw_pattern_size + 1);
1177            copy_text (XSTRING (string)->data, raw_pattern,            copy_text (SDATA (string), raw_pattern,
1178                       STRING_BYTES (XSTRING (string)), 1, 0);                       SBYTES (string), 1, 0);
1179          }          }
1180    
1181        /* Copy and optionally translate the pattern.  */        /* Copy and optionally translate the pattern.  */
# Line 1525  boyer_moore (n, base_pat, len, len_byte, Line 1528  boyer_moore (n, base_pat, len, len_byte,
1528    int infinity, limit, stride_for_teases = 0;    int infinity, limit, stride_for_teases = 0;
1529    register int *BM_tab;    register int *BM_tab;
1530    int *BM_tab_base;    int *BM_tab_base;
1531    register unsigned char *cursor, *p_limit;      register unsigned char *cursor, *p_limit;
1532    register int i, j;    register int i, j;
1533    unsigned char *pat, *pat_end;    unsigned char *pat, *pat_end;
1534    int multibyte = ! NILP (current_buffer->enable_multibyte_characters);    int multibyte = ! NILP (current_buffer->enable_multibyte_characters);
# Line 1558  boyer_moore (n, base_pat, len, len_byte, Line 1561  boyer_moore (n, base_pat, len, len_byte,
1561    /* a single test, a test for having gone past the end of the */    /* a single test, a test for having gone past the end of the */
1562    /* permissible match region, to test for both possible matches (when */    /* permissible match region, to test for both possible matches (when */
1563    /* the stride goes past the end immediately) and failure to */    /* the stride goes past the end immediately) and failure to */
1564    /* 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). */
1565    
1566    /* Here we make a "mickey mouse" BM table.  The stride of the search */    /* Here we make a "mickey mouse" BM table.  The stride of the search */
1567    /* is determined only by the last character of the putative match. */    /* is determined only by the last character of the putative match. */
1568    /* If that character does not match, we will stride the proper */    /* If that character does not match, we will stride the proper */
1569    /* distance to propose a match that superimposes it on the last */    /* distance to propose a match that superimposes it on the last */
1570    /* instance of a character that matches it (per trt), or misses */    /* instance of a character that matches it (per trt), or misses */
1571    /* it entirely if there is none. */      /* it entirely if there is none. */
1572    
1573    dirlen = len_byte * direction;    dirlen = len_byte * direction;
1574    infinity = dirlen - (lim_byte + pos_byte + len_byte + len_byte) * direction;    infinity = dirlen - (lim_byte + pos_byte + len_byte + len_byte) * direction;
# Line 1653  boyer_moore (n, base_pat, len, len_byte, Line 1656  boyer_moore (n, base_pat, len, len_byte,
1656    
1657            BM_tab[j] = dirlen - i;            BM_tab[j] = dirlen - i;
1658            /* A translation table is accompanied by its inverse -- see */            /* A translation table is accompanied by its inverse -- see */
1659            /* comment following downcase_table for details */            /* comment following downcase_table for details */
1660            if (this_translated)            if (this_translated)
1661              {              {
1662                int starting_ch = ch;                int starting_ch = ch;
# Line 1841  boyer_moore (n, base_pat, len, len_byte, Line 1844  boyer_moore (n, base_pat, len, len_byte,
1844                /* This loop can be coded for space rather than */                /* This loop can be coded for space rather than */
1845                /* speed because it will usually run only once. */                /* speed because it will usually run only once. */
1846                /* (the reach is at most len + 21, and typically */                /* (the reach is at most len + 21, and typically */
1847                /* does not exceed len) */                    /* does not exceed len) */
1848                while ((limit - pos_byte) * direction >= 0)                while ((limit - pos_byte) * direction >= 0)
1849                  pos_byte += BM_tab[FETCH_BYTE (pos_byte)];                  pos_byte += BM_tab[FETCH_BYTE (pos_byte)];
1850                /* now run the same tests to distinguish going off the */                /* now run the same tests to distinguish going off the */
# Line 1948  wordify (string) Line 1951  wordify (string)
1951    int adjust;    int adjust;
1952    
1953    CHECK_STRING (string);    CHECK_STRING (string);
1954    p = XSTRING (string)->data;    p = SDATA (string);
1955    len = XSTRING (string)->size;    len = SCHARS (string);
1956    
1957    for (i = 0, i_byte = 0; i < len; )    for (i = 0, i_byte = 0; i < len; )
1958      {      {
1959        int c;        int c;
1960          
1961        FETCH_STRING_CHAR_ADVANCE (c, string, i, i_byte);        FETCH_STRING_CHAR_ADVANCE (c, string, i, i_byte);
1962    
1963        if (SYNTAX (c) != Sword)        if (SYNTAX (c) != Sword)
# Line 1975  wordify (string) Line 1978  wordify (string)
1978    adjust = - punct_count + 5 * (word_count - 1) + 4;    adjust = - punct_count + 5 * (word_count - 1) + 4;
1979    if (STRING_MULTIBYTE (string))    if (STRING_MULTIBYTE (string))
1980      val = make_uninit_multibyte_string (len + adjust,      val = make_uninit_multibyte_string (len + adjust,
1981                                          STRING_BYTES (XSTRING (string))                                          SBYTES (string)
1982                                          + adjust);                                          + adjust);
1983    else    else
1984      val = make_uninit_string (len + adjust);      val = make_uninit_string (len + adjust);
1985    
1986    o = XSTRING (val)->data;    o = SDATA (val);
1987    *o++ = '\\';    *o++ = '\\';
1988    *o++ = 'b';    *o++ = 'b';
1989    prev_c = 0;    prev_c = 0;
# Line 1989  wordify (string) Line 1992  wordify (string)
1992      {      {
1993        int c;        int c;
1994        int i_byte_orig = i_byte;        int i_byte_orig = i_byte;
1995          
1996        FETCH_STRING_CHAR_ADVANCE (c, string, i, i_byte);        FETCH_STRING_CHAR_ADVANCE (c, string, i, i_byte);
1997    
1998        if (SYNTAX (c) == Sword)        if (SYNTAX (c) == Sword)
1999          {          {
2000            bcopy (&XSTRING (string)->data[i_byte_orig], o,            bcopy (SDATA (string) + i_byte_orig, o,
2001                   i_byte - i_byte_orig);                   i_byte - i_byte_orig);
2002            o += i_byte - i_byte_orig;            o += i_byte - i_byte_orig;
2003          }          }
# Line 2242  since only regular expressions have dist Line 2245  since only regular expressions have dist
2245      {      {
2246        if (search_regs.start[sub] < 0        if (search_regs.start[sub] < 0
2247            || search_regs.start[sub] > search_regs.end[sub]            || search_regs.start[sub] > search_regs.end[sub]
2248            || search_regs.end[sub] > XSTRING (string)->size)            || search_regs.end[sub] > SCHARS (string))
2249          args_out_of_range (make_number (search_regs.start[sub]),          args_out_of_range (make_number (search_regs.start[sub]),
2250                             make_number (search_regs.end[sub]));                             make_number (search_regs.end[sub]));
2251      }      }
# Line 2342  since only regular expressions have dist Line 2345  since only regular expressions have dist
2345            /* We build up the substituted string in ACCUM.  */            /* We build up the substituted string in ACCUM.  */
2346            Lisp_Object accum;            Lisp_Object accum;
2347            Lisp_Object middle;            Lisp_Object middle;
2348            int length = STRING_BYTES (XSTRING (newtext));            int length = SBYTES (newtext);
2349    
2350            accum = Qnil;            accum = Qnil;
2351    
# Line 2357  since only regular expressions have dist Line 2360  since only regular expressions have dist
2360                if (c == '\\')                if (c == '\\')
2361                  {                  {
2362                    FETCH_STRING_CHAR_ADVANCE (c, newtext, pos, pos_byte);                    FETCH_STRING_CHAR_ADVANCE (c, newtext, pos, pos_byte);
2363                          
2364                    if (c == '&')                    if (c == '&')
2365                      {                      {
2366                        substart = search_regs.start[sub];                        substart = search_regs.start[sub];
# Line 2434  since only regular expressions have dist Line 2437  since only regular expressions have dist
2437       perform substitution on the replacement string.  */       perform substitution on the replacement string.  */
2438    if (NILP (literal))    if (NILP (literal))
2439      {      {
2440        int length = STRING_BYTES (XSTRING (newtext));        int length = SBYTES (newtext);
2441        unsigned char *substed;        unsigned char *substed;
2442        int substed_alloc_size, substed_len;        int substed_alloc_size, substed_len;
2443        int buf_multibyte = !NILP (current_buffer->enable_multibyte_characters);        int buf_multibyte = !NILP (current_buffer->enable_multibyte_characters);
# Line 2471  since only regular expressions have dist Line 2474  since only regular expressions have dist
2474            else            else
2475              {              {
2476                /* Note that we don't have to increment POS.  */                /* Note that we don't have to increment POS.  */
2477                c = XSTRING (newtext)->data[pos_byte++];                c = SREF (newtext, pos_byte++);
2478                if (buf_multibyte)                if (buf_multibyte)
2479                  c = unibyte_char_to_multibyte (c);                  c = unibyte_char_to_multibyte (c);
2480              }              }
# Line 2493  since only regular expressions have dist Line 2496  since only regular expressions have dist
2496                  }                  }
2497                else                else
2498                  {                  {
2499                    c = XSTRING (newtext)->data[pos_byte++];                    c = SREF (newtext, pos_byte++);
2500                    if (buf_multibyte)                    if (buf_multibyte)
2501                      c = unibyte_char_to_multibyte (c);                      c = unibyte_char_to_multibyte (c);
2502                  }                  }
# Line 2558  since only regular expressions have dist Line 2561  since only regular expressions have dist
2561    /* Replace the old text with the new in the cleanest possible way.  */    /* Replace the old text with the new in the cleanest possible way.  */
2562    replace_range (search_regs.start[sub], search_regs.end[sub],    replace_range (search_regs.start[sub], search_regs.end[sub],
2563                   newtext, 1, 0, 1);                   newtext, 1, 0, 1);
2564    newpoint = search_regs.start[sub] + XSTRING (newtext)->size;    newpoint = search_regs.start[sub] + SCHARS (newtext);
2565    
2566    if (case_action == all_caps)    if (case_action == all_caps)
2567      Fupcase_region (make_number (search_regs.start[sub]),      Fupcase_region (make_number (search_regs.start[sub]),
# Line 2567  since only regular expressions have dist Line 2570  since only regular expressions have dist
2570      Fupcase_initials_region (make_number (search_regs.start[sub]),      Fupcase_initials_region (make_number (search_regs.start[sub]),
2571                               make_number (newpoint));                               make_number (newpoint));
2572    
2573      /* Adjust search data for this change.  */
2574      {
2575        int oldend = search_regs.end[sub];
2576        int change = newpoint - search_regs.end[sub];
2577        int i;
2578    
2579        for (i = 0; i < search_regs.num_regs; i++)
2580          {
2581            if (search_regs.start[i] > oldend)
2582              search_regs.start[i] += change;
2583            if (search_regs.end[i] > oldend)
2584              search_regs.end[i] += change;
2585          }
2586      }
2587    
2588    /* Put point back where it was in the text.  */    /* Put point back where it was in the text.  */
2589    if (opoint <= 0)    if (opoint <= 0)
2590      TEMP_SET_PT (opoint + ZV);      TEMP_SET_PT (opoint + ZV);
# Line 2575  since only regular expressions have dist Line 2593  since only regular expressions have dist
2593    
2594    /* Now move point "officially" to the start of the inserted replacement.  */    /* Now move point "officially" to the start of the inserted replacement.  */
2595    move_if_not_intangible (newpoint);    move_if_not_intangible (newpoint);
2596      
2597    return Qnil;    return Qnil;
2598  }  }
2599    
# Line 2621  Zero means the entire text matched by th Line 2639  Zero means the entire text matched by th
2639       Lisp_Object subexp;       Lisp_Object subexp;
2640  {  {
2641    return match_limit (subexp, 0);    return match_limit (subexp, 0);
2642  }  }
2643    
2644  DEFUN ("match-data", Fmatch_data, Smatch_data, 0, 2, 0,  DEFUN ("match-data", Fmatch_data, Smatch_data, 0, 2, 0,
2645         doc: /* Return a list containing all info on what the last search matched.         doc: /* Return a list containing all info on what the last search matched.
# Line 2633  Use `store-match-data' to reinstate the Line 2651  Use `store-match-data' to reinstate the
2651  If INTEGERS (the optional first argument) is non-nil, always use integers  If INTEGERS (the optional first argument) is non-nil, always use integers
2652  \(rather than markers) to represent buffer positions.  \(rather than markers) to represent buffer positions.
2653  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
2654  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.
2655    
2656    Return value is undefined if the last search failed.  */)
2657       (integers, reuse)       (integers, reuse)
2658       Lisp_Object integers, reuse;       Lisp_Object integers, reuse;
2659  {  {
# Line 2669  to hold all the values, and if INTEGERS Line 2689  to hold all the values, and if INTEGERS
2689                             last_thing_searched);                             last_thing_searched);
2690                data[2 * i + 1] = Fmake_marker ();                data[2 * i + 1] = Fmake_marker ();
2691                Fset_marker (data[2 * i + 1],                Fset_marker (data[2 * i + 1],
2692                             make_number (search_regs.end[i]),                             make_number (search_regs.end[i]),
2693                             last_thing_searched);                             last_thing_searched);
2694              }              }
2695            else            else
# Line 2722  LIST should have been created by calling Line 2742  LIST should have been created by calling
2742    if (!CONSP (list) && !NILP (list))    if (!CONSP (list) && !NILP (list))
2743      list = wrong_type_argument (Qconsp, list);      list = wrong_type_argument (Qconsp, list);
2744    
2745    /* 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
2746       match data came from a string.  */       match data came from a string.  */
2747    last_thing_searched = Qt;    last_thing_searched = Qt;
2748    
# Line 2791  LIST should have been created by calling Line 2811  LIST should have been created by calling
2811        list = Fcdr (list);        list = Fcdr (list);
2812      }      }
2813    
2814    return Qnil;      return Qnil;
2815  }  }
2816    
2817  /* If non-zero the match data have been saved in saved_search_regs  /* If non-zero the match data have been saved in saved_search_regs
# Line 2849  DEFUN ("regexp-quote", Fregexp_quote, Sr Line 2869  DEFUN ("regexp-quote", Fregexp_quote, Sr
2869    
2870    CHECK_STRING (string);    CHECK_STRING (string);
2871    
2872    temp = (unsigned char *) alloca (STRING_BYTES (XSTRING (string)) * 2);    temp = (unsigned char *) alloca (SBYTES (string) * 2);
2873    
2874    /* Now copy the data into the new string, inserting escapes. */    /* Now copy the data into the new string, inserting escapes. */
2875    
2876    in = XSTRING (string)->data;    in = SDATA (string);
2877    end = in + STRING_BYTES (XSTRING (string));    end = in + SBYTES (string);
2878    out = temp;    out = temp;
2879    
2880    for (; in != end; in++)    for (; in != end; in++)
2881      {      {
# Line 2868  DEFUN ("regexp-quote", Fregexp_quote, Sr Line 2888  DEFUN ("regexp-quote", Fregexp_quote, Sr
2888      }      }
2889    
2890    return make_specified_string (temp,    return make_specified_string (temp,
2891                                  XSTRING (string)->size + backslashes_added,                                  SCHARS (string) + backslashes_added,
2892                                  out - temp,                                  out - temp,
2893                                  STRING_MULTIBYTE (string));                                  STRING_MULTIBYTE (string));
2894  }  }
2895      
2896  void  void
2897  syms_of_search ()  syms_of_search ()
2898  {  {

Legend:
Removed from v.1.164  
changed lines
  Added in v.1.164.2.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26