comparison src/search.c @ 422:95016f13131a r21-2-19

Import from CVS: tag r21-2-19
author cvs
date Mon, 13 Aug 2007 11:25:01 +0200
parents 697ef44129c6
children 11054d720c21
comparison
equal deleted inserted replaced
421:fff06e11db74 422:95016f13131a
696 696
697 Bufpos 697 Bufpos
698 find_next_newline (struct buffer *buf, Bufpos from, int count) 698 find_next_newline (struct buffer *buf, Bufpos from, int count)
699 { 699 {
700 return scan_buffer (buf, '\n', from, 0, count, 0, 1); 700 return scan_buffer (buf, '\n', from, 0, count, 0, 1);
701 }
702
703 Bytind
704 bi_find_next_emchar_in_string (struct Lisp_String* str, Emchar target, Bytind st,
705 EMACS_INT count)
706 {
707 /* This function has been Mule-ized. */
708 Bytind lim = string_length (str) -1;
709 Bufbyte* s = string_data (str);
710
711 assert (count >= 0);
712
713 #ifdef MULE
714 /* Due to the Mule representation of characters in a buffer,
715 we can simply search for characters in the range 0 - 127
716 directly. For other characters, we do it the "hard" way.
717 Note that this way works for all characters but the other
718 way is faster. */
719 if (target >= 0200)
720 {
721 while (st < lim && count > 0)
722 {
723 if (string_char (str, st) == target)
724 count--;
725 INC_CHARBYTIND (s, st);
726 }
727 }
728 else
729 #endif
730 {
731 while (st < lim && count > 0)
732 {
733 Bufbyte *bufptr = (Bufbyte *) memchr (charptr_n_addr (s, st),
734 (int) target, lim - st);
735 if (bufptr)
736 {
737 count--;
738 st = (Bytind)(bufptr - s) + 1;
739 }
740 else
741 st = lim;
742 }
743 }
744 return st;
701 } 745 }
702 746
703 /* Like find_next_newline, but returns position before the newline, 747 /* Like find_next_newline, but returns position before the newline,
704 not after, and only search up to TO. This isn't just 748 not after, and only search up to TO. This isn't just
705 find_next_newline (...)-1, because you might hit TO. */ 749 find_next_newline (...)-1, because you might hit TO. */