X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Fsearch.c;h=a66abc06ffe4a093c8dfff7809700ec4d2c24867;hb=ea1ea793fe6e244ef5555ed983423a204101af13;hp=051fded200a7b5be3829d9502095067057c25b01;hpb=f3ec20f455f3f1212d2c5ee4cadc984330da9c38;p=chise%2Fxemacs-chise.git.1 diff --git a/src/search.c b/src/search.c index 051fded..a66abc0 100644 --- a/src/search.c +++ b/src/search.c @@ -54,10 +54,10 @@ struct regexp_cache { }; /* The instances of that struct. */ -struct regexp_cache searchbufs[REGEXP_CACHE_SIZE]; +static struct regexp_cache searchbufs[REGEXP_CACHE_SIZE]; /* The head of the linked list; points to the most recently used buffer. */ -struct regexp_cache *searchbuf_head; +static struct regexp_cache *searchbuf_head; /* Every call to re_match, etc., must pass &search_regs as the regs @@ -700,6 +700,50 @@ find_next_newline (struct buffer *buf, Bufpos from, int count) return scan_buffer (buf, '\n', from, 0, count, 0, 1); } +Bytind +bi_find_next_emchar_in_string (struct Lisp_String* str, Emchar target, Bytind st, + EMACS_INT count) +{ + /* This function has been Mule-ized. */ + Bytind lim = string_length (str) -1; + Bufbyte* s = string_data (str); + + assert (count >= 0); + +#ifdef MULE + /* Due to the Mule representation of characters in a buffer, + we can simply search for characters in the range 0 - 127 + directly. For other characters, we do it the "hard" way. + Note that this way works for all characters but the other + way is faster. */ + if (target >= 0200) + { + while (st < lim && count > 0) + { + if (string_char (str, st) == target) + count--; + INC_CHARBYTIND (s, st); + } + } + else +#endif + { + while (st < lim && count > 0) + { + Bufbyte *bufptr = (Bufbyte *) memchr (charptr_n_addr (s, st), + (int) target, lim - st); + if (bufptr) + { + count--; + st = (Bytind)(bufptr - s) + 1; + } + else + st = lim; + } + } + return st; +} + /* Like find_next_newline, but returns position before the newline, not after, and only search up to TO. This isn't just find_next_newline (...)-1, because you might hit TO. */ @@ -2530,9 +2574,12 @@ syms_of_search (void) } void -vars_of_search (void) +reinit_vars_of_search (void) { - REGISTER int i; + int i; + + last_thing_searched = Qnil; + staticpro_nodump (&last_thing_searched); for (i = 0; i < REGEXP_CACHE_SIZE; ++i) { @@ -2540,13 +2587,16 @@ vars_of_search (void) searchbufs[i].buf.buffer = (unsigned char *) xmalloc (100); searchbufs[i].buf.fastmap = searchbufs[i].fastmap; searchbufs[i].regexp = Qnil; - staticpro (&searchbufs[i].regexp); + staticpro_nodump (&searchbufs[i].regexp); searchbufs[i].next = (i == REGEXP_CACHE_SIZE-1 ? 0 : &searchbufs[i+1]); } searchbuf_head = &searchbufs[0]; +} - last_thing_searched = Qnil; - staticpro (&last_thing_searched); +void +vars_of_search (void) +{ + reinit_vars_of_search (); DEFVAR_LISP ("forward-word-regexp", &Vforward_word_regexp /* *Regular expression to be used in `forward-word'.