X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Fsearch.c;h=445bd879942b1fa2ba0fe8a829e6d369f1e7076b;hb=f8c889244f022ae695ea8dc67267499286921903;hp=cb66c4f5d6ce9fa98bfac47ca1b9a6cd29771890;hpb=77dcef404dc78635f6ffa8f71a803d2bc7cc8921;p=chise%2Fxemacs-chise.git- diff --git a/src/search.c b/src/search.c index cb66c4f..445bd87 100644 --- a/src/search.c +++ b/src/search.c @@ -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. */ @@ -1963,7 +2007,7 @@ and you do not need to specify it.) Charcount subend = -1; c = string_char (XSTRING (newtext), strpos); - if (c == '\\') + if (c == '\\' && strpos < stlen - 1) { c = string_char (XSTRING (newtext), ++strpos); if (c == '&') @@ -2109,7 +2153,7 @@ and you do not need to specify it.) Charcount offset = BUF_PT (buf) - search_regs.start[0]; c = string_char (XSTRING (newtext), strpos); - if (c == '\\') + if (c == '\\' && strpos < stlen - 1) { c = string_char (XSTRING (newtext), ++strpos); if (c == '&')