/[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.171 by rms, Sun Nov 24 19:04:57 2002 UTC revision 1.172 by lektu, Tue Feb 4 14:03:13 2003 UTC
# 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 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 *) SDATA (string),    val = re_search (bufp, (char *) SDATA (string),
395                     SBYTES (string), pos_byte,                     SBYTES (string), pos_byte,
396                     SBYTES (string) - pos_byte,                     SBYTES (string) - pos_byte,
# Line 458  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 *) SDATA (string),    val = re_search (bufp, (char *) SDATA (string),
463                     SBYTES (string), 0,                     SBYTES (string), 0,
464                     SBYTES (string), 0);                     SBYTES (string), 0);
# Line 550  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 611  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 856  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 1062  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 1528  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 1561  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 1656  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 1844  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 1957  wordify (string) Line 1957  wordify (string)
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 1992  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)
# Line 2360  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 2593  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 2639  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 2687  to hold all the values, and if INTEGERS Line 2687  to hold all the values, and if INTEGERS
2687                             last_thing_searched);                             last_thing_searched);
2688                data[2 * i + 1] = Fmake_marker ();                data[2 * i + 1] = Fmake_marker ();
2689                Fset_marker (data[2 * i + 1],                Fset_marker (data[2 * i + 1],
2690                             make_number (search_regs.end[i]),                             make_number (search_regs.end[i]),
2691                             last_thing_searched);                             last_thing_searched);
2692              }              }
2693            else            else
# Line 2740  LIST should have been created by calling Line 2740  LIST should have been created by calling
2740    if (!CONSP (list) && !NILP (list))    if (!CONSP (list) && !NILP (list))
2741      list = wrong_type_argument (Qconsp, list);      list = wrong_type_argument (Qconsp, list);
2742    
2743    /* 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
2744       match data came from a string.  */       match data came from a string.  */
2745    last_thing_searched = Qt;    last_thing_searched = Qt;
2746    
# Line 2809  LIST should have been created by calling Line 2809  LIST should have been created by calling
2809        list = Fcdr (list);        list = Fcdr (list);
2810      }      }
2811    
2812    return Qnil;      return Qnil;
2813  }  }
2814    
2815  /* 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 2873  DEFUN ("regexp-quote", Fregexp_quote, Sr Line 2873  DEFUN ("regexp-quote", Fregexp_quote, Sr
2873    
2874    in = SDATA (string);    in = SDATA (string);
2875    end = in + SBYTES (string);    end = in + SBYTES (string);
2876    out = temp;    out = temp;
2877    
2878    for (; in != end; in++)    for (; in != end; in++)
2879      {      {
# Line 2890  DEFUN ("regexp-quote", Fregexp_quote, Sr Line 2890  DEFUN ("regexp-quote", Fregexp_quote, Sr
2890                                  out - temp,                                  out - temp,
2891                                  STRING_MULTIBYTE (string));                                  STRING_MULTIBYTE (string));
2892  }  }
2893      
2894  void  void
2895  syms_of_search ()  syms_of_search ()
2896  {  {

Legend:
Removed from v.1.171  
changed lines
  Added in v.1.172

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