Mercurial > hg > xemacs-beta
comparison src/search.c @ 867:804517e16990
[xemacs-hg @ 2002-06-05 09:54:39 by ben]
Textual renaming: text/char names
abbrev.c, alloc.c, buffer.c, buffer.h, bytecode.c, callint.c, casefiddle.c, casetab.c, charset.h, chartab.c, chartab.h, cmds.c, console-gtk.h, console-msw.c, console-msw.h, console-stream.c, console-tty.c, console-x.c, console-x.h, console.h, data.c, device-msw.c, device-x.c, dialog-msw.c, dired-msw.c, dired.c, doc.c, doprnt.c, editfns.c, eldap.c, emodules.c, eval.c, event-Xt.c, event-gtk.c, event-msw.c, event-stream.c, event-unixoid.c, events.c, events.h, file-coding.c, file-coding.h, fileio.c, filelock.c, fns.c, font-lock.c, frame-gtk.c, frame-msw.c, frame-x.c, frame.c, glyphs-eimage.c, glyphs-msw.c, glyphs-x.c, glyphs.c, glyphs.h, gpmevent.c, gui-x.c, gui-x.h, gui.c, gui.h, hpplay.c, indent.c, insdel.c, insdel.h, intl-win32.c, keymap.c, line-number.c, line-number.h, lisp-disunion.h, lisp-union.h, lisp.h, lread.c, lrecord.h, lstream.c, lstream.h, md5.c, menubar-msw.c, menubar-x.c, menubar.c, minibuf.c, mule-ccl.c, mule-charset.c, mule-coding.c, mule-wnnfns.c, ndir.h, nt.c, objects-gtk.c, objects-gtk.h, objects-msw.c, objects-tty.c, objects-x.c, objects.c, objects.h, postgresql.c, print.c, process-nt.c, process-unix.c, process.c, procimpl.h, realpath.c, redisplay-gtk.c, redisplay-msw.c, redisplay-output.c, redisplay-tty.c, redisplay-x.c, redisplay.c, redisplay.h, regex.c, search.c, select-common.h, select-gtk.c, select-x.c, sound.h, symbols.c, syntax.c, syntax.h, sysdep.c, sysdep.h, sysdir.h, sysfile.h, sysproc.h, syspwd.h, systime.h, syswindows.h, termcap.c, tests.c, text.c, text.h, toolbar-common.c, tooltalk.c, ui-gtk.c, unexnt.c, unicode.c, win32.c: Text/char naming rationalization.
[a] distinguish between "charptr" when it refers to operations on
the pointer itself and when it refers to operations on text; and
[b] use consistent naming for everything referring to internal
format, i.e.
Itext == text in internal format
Ibyte == a byte in such text
Ichar == a char as represented in internal character format
thus e.g.
set_charptr_emchar -> set_itext_ichar
The pre and post tags on either side of this change are:
pre-internal-format-textual-renaming
post-internal-format-textual-renaming
See the Internals Manual for details of exactly how this was done,
how to handle the change in your workspace, etc.
author | ben |
---|---|
date | Wed, 05 Jun 2002 09:58:45 +0000 |
parents | 2b6fa2618f76 |
children | 79c6ff3eef26 |
comparison
equal
deleted
inserted
replaced
866:613552a02607 | 867:804517e16990 |
---|---|
41 #include "regex.h" | 41 #include "regex.h" |
42 #include "casetab.h" | 42 #include "casetab.h" |
43 #include "chartab.h" | 43 #include "chartab.h" |
44 | 44 |
45 #define TRANSLATE(table, pos) \ | 45 #define TRANSLATE(table, pos) \ |
46 (!NILP (table) ? TRT_TABLE_OF (table, (Emchar) pos) : pos) | 46 (!NILP (table) ? TRT_TABLE_OF (table, (Ichar) pos) : pos) |
47 | 47 |
48 #define REGEXP_CACHE_SIZE 20 | 48 #define REGEXP_CACHE_SIZE 20 |
49 | 49 |
50 /* If the regexp is non-nil, then the buffer contains the compiled form | 50 /* If the regexp is non-nil, then the buffer contains the compiled form |
51 of that regexp, suitable for searching. */ | 51 of that regexp, suitable for searching. */ |
110 /* range table for use with skip_chars. Only needed for Mule. */ | 110 /* range table for use with skip_chars. Only needed for Mule. */ |
111 Lisp_Object Vskip_chars_range_table; | 111 Lisp_Object Vskip_chars_range_table; |
112 | 112 |
113 static void set_search_regs (struct buffer *buf, Charbpos beg, Charcount len); | 113 static void set_search_regs (struct buffer *buf, Charbpos beg, Charcount len); |
114 static void save_search_regs (void); | 114 static void save_search_regs (void); |
115 static Charbpos simple_search (struct buffer *buf, Intbyte *base_pat, | 115 static Charbpos simple_search (struct buffer *buf, Ibyte *base_pat, |
116 Bytecount len, Bytebpos pos, Bytebpos lim, | 116 Bytecount len, Bytebpos pos, Bytebpos lim, |
117 EMACS_INT n, Lisp_Object trt); | 117 EMACS_INT n, Lisp_Object trt); |
118 static Charbpos boyer_moore (struct buffer *buf, Intbyte *base_pat, | 118 static Charbpos boyer_moore (struct buffer *buf, Ibyte *base_pat, |
119 Bytecount len, Bytebpos pos, Bytebpos lim, | 119 Bytecount len, Bytebpos pos, Bytebpos lim, |
120 EMACS_INT n, Lisp_Object trt, | 120 EMACS_INT n, Lisp_Object trt, |
121 Lisp_Object inverse_trt, int charset_base); | 121 Lisp_Object inverse_trt, int charset_base); |
122 static Charbpos search_buffer (struct buffer *buf, Lisp_Object str, | 122 static Charbpos search_buffer (struct buffer *buf, Lisp_Object str, |
123 Charbpos charbpos, Charbpos buflim, EMACS_INT n, | 123 Charbpos charbpos, Charbpos buflim, EMACS_INT n, |
269 { | 269 { |
270 int i; | 270 int i; |
271 int num_regs = search_regs.num_regs; | 271 int num_regs = search_regs.num_regs; |
272 | 272 |
273 /* #### bytecount_to_charcount() is not that efficient. This function | 273 /* #### bytecount_to_charcount() is not that efficient. This function |
274 could be faster if it did its own conversion (using INC_CHARPTR() | 274 could be faster if it did its own conversion (using INC_IBYTEPTR() |
275 and such), because the register ends are likely to be somewhat ordered. | 275 and such), because the register ends are likely to be somewhat ordered. |
276 (Even if not, you could sort them.) | 276 (Even if not, you could sort them.) |
277 | 277 |
278 Think about this if this function is a time hog, which it's probably | 278 Think about this if this function is a time hog, which it's probably |
279 not. */ | 279 not. */ |
494 /* Match REGEXP against STRING, searching all of STRING, | 494 /* Match REGEXP against STRING, searching all of STRING, |
495 and return the index of the match, or negative on failure. | 495 and return the index of the match, or negative on failure. |
496 This does not clobber the match data. */ | 496 This does not clobber the match data. */ |
497 | 497 |
498 Bytecount | 498 Bytecount |
499 fast_string_match (Lisp_Object regexp, const Intbyte *nonreloc, | 499 fast_string_match (Lisp_Object regexp, const Ibyte *nonreloc, |
500 Lisp_Object reloc, Bytecount offset, | 500 Lisp_Object reloc, Bytecount offset, |
501 Bytecount length, int case_fold_search, | 501 Bytecount length, int case_fold_search, |
502 Error_Behavior errb, int no_quit) | 502 Error_Behavior errb, int no_quit) |
503 { | 503 { |
504 Bytecount val; | 504 Bytecount val; |
505 Intbyte *newnonreloc = (Intbyte *) nonreloc; | 505 Ibyte *newnonreloc = (Ibyte *) nonreloc; |
506 struct re_pattern_buffer *bufp; | 506 struct re_pattern_buffer *bufp; |
507 struct syntax_cache scache_struct; | 507 struct syntax_cache scache_struct; |
508 struct syntax_cache *scache = &scache_struct; | 508 struct syntax_cache *scache = &scache_struct; |
509 | 509 |
510 bufp = compile_pattern (regexp, 0, | 510 bufp = compile_pattern (regexp, 0, |
596 to the number of TARGETs left unfound, and return END. | 596 to the number of TARGETs left unfound, and return END. |
597 | 597 |
598 If ALLOW_QUIT is non-zero, call QUIT periodically. */ | 598 If ALLOW_QUIT is non-zero, call QUIT periodically. */ |
599 | 599 |
600 static Bytebpos | 600 static Bytebpos |
601 byte_scan_buffer (struct buffer *buf, Emchar target, Bytebpos st, Bytebpos en, | 601 byte_scan_buffer (struct buffer *buf, Ichar target, Bytebpos st, Bytebpos en, |
602 EMACS_INT count, EMACS_INT *shortage, int allow_quit) | 602 EMACS_INT count, EMACS_INT *shortage, int allow_quit) |
603 { | 603 { |
604 Bytebpos lim = en > 0 ? en : | 604 Bytebpos lim = en > 0 ? en : |
605 ((count > 0) ? BYTE_BUF_ZV (buf) : BYTE_BUF_BEGV (buf)); | 605 ((count > 0) ? BYTE_BUF_ZV (buf) : BYTE_BUF_BEGV (buf)); |
606 | 606 |
614 { | 614 { |
615 #ifdef MULE | 615 #ifdef MULE |
616 Internal_Format fmt = buf->text->format; | 616 Internal_Format fmt = buf->text->format; |
617 /* Check for char that's unrepresentable in the buffer -- it | 617 /* Check for char that's unrepresentable in the buffer -- it |
618 certainly can't be there. */ | 618 certainly can't be there. */ |
619 if (!emchar_fits_in_format (target, fmt, wrap_buffer (buf))) | 619 if (!ichar_fits_in_format (target, fmt, wrap_buffer (buf))) |
620 { | 620 { |
621 *shortage = count; | 621 *shortage = count; |
622 return lim; | 622 return lim; |
623 } | 623 } |
624 /* Due to the Mule representation of characters in a buffer, we can | 624 /* Due to the Mule representation of characters in a buffer, we can |
625 simply search for characters in the range 0 - 127 directly; for | 625 simply search for characters in the range 0 - 127 directly; for |
626 8-bit-fixed, we can do this for all characters. In other cases, | 626 8-bit-fixed, we can do this for all characters. In other cases, |
627 we do it the "hard" way. Note that this way works for all | 627 we do it the "hard" way. Note that this way works for all |
628 characters and all formats, but the other way is faster. */ | 628 characters and all formats, but the other way is faster. */ |
629 else if (! (fmt == FORMAT_8_BIT_FIXED || | 629 else if (! (fmt == FORMAT_8_BIT_FIXED || |
630 (fmt == FORMAT_DEFAULT && emchar_ascii_p (target)))) | 630 (fmt == FORMAT_DEFAULT && ichar_ascii_p (target)))) |
631 { | 631 { |
632 Raw_Emchar raw = emchar_to_raw (target, fmt, wrap_buffer (buf)); | 632 Raw_Ichar raw = ichar_to_raw (target, fmt, wrap_buffer (buf)); |
633 while (st < lim && count > 0) | 633 while (st < lim && count > 0) |
634 { | 634 { |
635 if (BYTE_BUF_FETCH_CHAR_RAW (buf, st) == raw) | 635 if (BYTE_BUF_FETCH_CHAR_RAW (buf, st) == raw) |
636 count--; | 636 count--; |
637 INC_BYTEBPOS (buf, st); | 637 INC_BYTEBPOS (buf, st); |
638 } | 638 } |
639 } | 639 } |
640 else | 640 else |
641 #endif | 641 #endif |
642 { | 642 { |
643 Raw_Emchar raw = emchar_to_raw (target, fmt, wrap_buffer (buf)); | 643 Raw_Ichar raw = ichar_to_raw (target, fmt, wrap_buffer (buf)); |
644 while (st < lim && count > 0) | 644 while (st < lim && count > 0) |
645 { | 645 { |
646 Bytebpos ceil; | 646 Bytebpos ceil; |
647 Intbyte *bufptr; | 647 Ibyte *bufptr; |
648 | 648 |
649 ceil = BYTE_BUF_CEILING_OF (buf, st); | 649 ceil = BYTE_BUF_CEILING_OF (buf, st); |
650 ceil = min (lim, ceil); | 650 ceil = min (lim, ceil); |
651 bufptr = (Intbyte *) memchr (BYTE_BUF_BYTE_ADDRESS (buf, st), | 651 bufptr = (Ibyte *) memchr (BYTE_BUF_BYTE_ADDRESS (buf, st), |
652 raw, ceil - st); | 652 raw, ceil - st); |
653 if (bufptr) | 653 if (bufptr) |
654 { | 654 { |
655 count--; | 655 count--; |
656 st = BYTE_BUF_PTR_BYTE_POS (buf, bufptr) + 1; | 656 st = BYTE_BUF_PTR_BYTE_POS (buf, bufptr) + 1; |
670 { | 670 { |
671 #ifdef MULE | 671 #ifdef MULE |
672 Internal_Format fmt = buf->text->format; | 672 Internal_Format fmt = buf->text->format; |
673 /* Check for char that's unrepresentable in the buffer -- it | 673 /* Check for char that's unrepresentable in the buffer -- it |
674 certainly can't be there. */ | 674 certainly can't be there. */ |
675 if (!emchar_fits_in_format (target, fmt, wrap_buffer (buf))) | 675 if (!ichar_fits_in_format (target, fmt, wrap_buffer (buf))) |
676 { | 676 { |
677 *shortage = -count; | 677 *shortage = -count; |
678 return lim; | 678 return lim; |
679 } | 679 } |
680 else if (! (fmt == FORMAT_8_BIT_FIXED || | 680 else if (! (fmt == FORMAT_8_BIT_FIXED || |
681 (fmt == FORMAT_DEFAULT && emchar_ascii_p (target)))) | 681 (fmt == FORMAT_DEFAULT && ichar_ascii_p (target)))) |
682 { | 682 { |
683 Raw_Emchar raw = emchar_to_raw (target, fmt, wrap_buffer (buf)); | 683 Raw_Ichar raw = ichar_to_raw (target, fmt, wrap_buffer (buf)); |
684 while (st > lim && count < 0) | 684 while (st > lim && count < 0) |
685 { | 685 { |
686 DEC_BYTEBPOS (buf, st); | 686 DEC_BYTEBPOS (buf, st); |
687 if (BYTE_BUF_FETCH_CHAR_RAW (buf, st) == raw) | 687 if (BYTE_BUF_FETCH_CHAR_RAW (buf, st) == raw) |
688 count++; | 688 count++; |
689 } | 689 } |
690 } | 690 } |
691 else | 691 else |
692 #endif | 692 #endif |
693 { | 693 { |
694 Raw_Emchar raw = emchar_to_raw (target, fmt, wrap_buffer (buf)); | 694 Raw_Ichar raw = ichar_to_raw (target, fmt, wrap_buffer (buf)); |
695 while (st > lim && count < 0) | 695 while (st > lim && count < 0) |
696 { | 696 { |
697 Bytebpos floor; | 697 Bytebpos floor; |
698 Intbyte *bufptr; | 698 Ibyte *bufptr; |
699 Intbyte *floorptr; | 699 Ibyte *floorptr; |
700 | 700 |
701 floor = BYTE_BUF_FLOOR_OF (buf, st); | 701 floor = BYTE_BUF_FLOOR_OF (buf, st); |
702 floor = max (lim, floor); | 702 floor = max (lim, floor); |
703 /* No memrchr() ... */ | 703 /* No memrchr() ... */ |
704 bufptr = BYTE_BUF_BYTE_ADDRESS_BEFORE (buf, st); | 704 bufptr = BYTE_BUF_BYTE_ADDRESS_BEFORE (buf, st); |
707 { | 707 { |
708 st--; | 708 st--; |
709 /* At this point, both ST and BUFPTR refer to the same | 709 /* At this point, both ST and BUFPTR refer to the same |
710 character. When the loop terminates, ST will | 710 character. When the loop terminates, ST will |
711 always point to the last character we tried. */ | 711 always point to the last character we tried. */ |
712 if (*bufptr == (Intbyte) raw) | 712 if (*bufptr == (Ibyte) raw) |
713 { | 713 { |
714 count++; | 714 count++; |
715 break; | 715 break; |
716 } | 716 } |
717 bufptr--; | 717 bufptr--; |
735 } | 735 } |
736 } | 736 } |
737 } | 737 } |
738 | 738 |
739 Charbpos | 739 Charbpos |
740 scan_buffer (struct buffer *buf, Emchar target, Charbpos start, Charbpos end, | 740 scan_buffer (struct buffer *buf, Ichar target, Charbpos start, Charbpos end, |
741 EMACS_INT count, EMACS_INT *shortage, int allow_quit) | 741 EMACS_INT count, EMACS_INT *shortage, int allow_quit) |
742 { | 742 { |
743 Bytebpos byte_retval; | 743 Bytebpos byte_retval; |
744 Bytebpos byte_start, byte_end; | 744 Bytebpos byte_start, byte_end; |
745 | 745 |
770 { | 770 { |
771 return scan_buffer (buf, '\n', from, 0, count, 0, 1); | 771 return scan_buffer (buf, '\n', from, 0, count, 0, 1); |
772 } | 772 } |
773 | 773 |
774 Bytecount | 774 Bytecount |
775 byte_find_next_emchar_in_string (Lisp_Object str, Emchar target, Bytecount st, | 775 byte_find_next_ichar_in_string (Lisp_Object str, Ichar target, Bytecount st, |
776 EMACS_INT count) | 776 EMACS_INT count) |
777 { | 777 { |
778 Bytebpos lim = XSTRING_LENGTH (str) -1; | 778 Bytebpos lim = XSTRING_LENGTH (str) -1; |
779 Intbyte *s = XSTRING_DATA (str); | 779 Ibyte *s = XSTRING_DATA (str); |
780 | 780 |
781 assert (count >= 0); | 781 assert (count >= 0); |
782 | 782 |
783 #ifdef MULE | 783 #ifdef MULE |
784 /* Due to the Mule representation of characters in a buffer, | 784 /* Due to the Mule representation of characters in a buffer, |
788 way is faster. */ | 788 way is faster. */ |
789 if (target >= 0200) | 789 if (target >= 0200) |
790 { | 790 { |
791 while (st < lim && count > 0) | 791 while (st < lim && count > 0) |
792 { | 792 { |
793 if (string_emchar (str, st) == target) | 793 if (string_ichar (str, st) == target) |
794 count--; | 794 count--; |
795 INC_BYTECOUNT (s, st); | 795 INC_BYTECOUNT (s, st); |
796 } | 796 } |
797 } | 797 } |
798 else | 798 else |
799 #endif | 799 #endif |
800 { | 800 { |
801 while (st < lim && count > 0) | 801 while (st < lim && count > 0) |
802 { | 802 { |
803 Intbyte *bufptr = (Intbyte *) memchr (charptr_n_addr (s, st), | 803 Ibyte *bufptr = (Ibyte *) memchr (itext_n_addr (s, st), |
804 (int) target, lim - st); | 804 (int) target, lim - st); |
805 if (bufptr) | 805 if (bufptr) |
806 { | 806 { |
807 count--; | 807 count--; |
808 st = (Bytebpos) (bufptr - s) + 1; | 808 st = (Bytebpos) (bufptr - s) + 1; |
832 | 832 |
833 static Lisp_Object | 833 static Lisp_Object |
834 skip_chars (struct buffer *buf, int forwardp, int syntaxp, | 834 skip_chars (struct buffer *buf, int forwardp, int syntaxp, |
835 Lisp_Object string, Lisp_Object lim) | 835 Lisp_Object string, Lisp_Object lim) |
836 { | 836 { |
837 REGISTER Intbyte *p, *pend; | 837 REGISTER Ibyte *p, *pend; |
838 REGISTER Emchar c; | 838 REGISTER Ichar c; |
839 /* We store the first 256 chars in an array here and the rest in | 839 /* We store the first 256 chars in an array here and the rest in |
840 a range table. */ | 840 a range table. */ |
841 unsigned char fastmap[0400]; | 841 unsigned char fastmap[0400]; |
842 int negate = 0; | 842 int negate = 0; |
843 REGISTER int i; | 843 REGISTER int i; |
873 If syntaxp, each character counts as itself. | 873 If syntaxp, each character counts as itself. |
874 Otherwise, handle backslashes and ranges specially */ | 874 Otherwise, handle backslashes and ranges specially */ |
875 | 875 |
876 while (p != pend) | 876 while (p != pend) |
877 { | 877 { |
878 c = charptr_emchar (p); | 878 c = itext_ichar (p); |
879 INC_CHARPTR (p); | 879 INC_IBYTEPTR (p); |
880 if (syntaxp) | 880 if (syntaxp) |
881 { | 881 { |
882 if (c < 0400 && syntax_spec_code[c] < (unsigned char) Smax) | 882 if (c < 0400 && syntax_spec_code[c] < (unsigned char) Smax) |
883 fastmap[c] = 1; | 883 fastmap[c] = 1; |
884 else | 884 else |
887 else | 887 else |
888 { | 888 { |
889 if (c == '\\') | 889 if (c == '\\') |
890 { | 890 { |
891 if (p == pend) break; | 891 if (p == pend) break; |
892 c = charptr_emchar (p); | 892 c = itext_ichar (p); |
893 INC_CHARPTR (p); | 893 INC_IBYTEPTR (p); |
894 } | 894 } |
895 if (p != pend && *p == '-') | 895 if (p != pend && *p == '-') |
896 { | 896 { |
897 Emchar cend; | 897 Ichar cend; |
898 | 898 |
899 p++; | 899 p++; |
900 if (p == pend) break; | 900 if (p == pend) break; |
901 cend = charptr_emchar (p); | 901 cend = itext_ichar (p); |
902 while (c <= cend && c < 0400) | 902 while (c <= cend && c < 0400) |
903 { | 903 { |
904 fastmap[c] = 1; | 904 fastmap[c] = 1; |
905 c++; | 905 c++; |
906 } | 906 } |
907 if (c <= cend) | 907 if (c <= cend) |
908 Fput_range_table (make_int (c), make_int (cend), Qt, | 908 Fput_range_table (make_int (c), make_int (cend), Qt, |
909 Vskip_chars_range_table); | 909 Vskip_chars_range_table); |
910 INC_CHARPTR (p); | 910 INC_IBYTEPTR (p); |
911 } | 911 } |
912 else | 912 else |
913 { | 913 { |
914 if (c < 0400) | 914 if (c < 0400) |
915 fastmap[c] = 1; | 915 fastmap[c] = 1; |
970 { | 970 { |
971 if (forwardp) | 971 if (forwardp) |
972 { | 972 { |
973 while (BUF_PT (buf) < limit) | 973 while (BUF_PT (buf) < limit) |
974 { | 974 { |
975 Emchar ch = BUF_FETCH_CHAR (buf, BUF_PT (buf)); | 975 Ichar ch = BUF_FETCH_CHAR (buf, BUF_PT (buf)); |
976 if ((ch < 0400) ? fastmap[ch] : | 976 if ((ch < 0400) ? fastmap[ch] : |
977 (NILP (Fget_range_table (make_int (ch), | 977 (NILP (Fget_range_table (make_int (ch), |
978 Vskip_chars_range_table, | 978 Vskip_chars_range_table, |
979 Qnil)) | 979 Qnil)) |
980 == negate)) | 980 == negate)) |
985 } | 985 } |
986 else | 986 else |
987 { | 987 { |
988 while (BUF_PT (buf) > limit) | 988 while (BUF_PT (buf) > limit) |
989 { | 989 { |
990 Emchar ch = BUF_FETCH_CHAR (buf, BUF_PT (buf) - 1); | 990 Ichar ch = BUF_FETCH_CHAR (buf, BUF_PT (buf) - 1); |
991 if ((ch < 0400) ? fastmap[ch] : | 991 if ((ch < 0400) ? fastmap[ch] : |
992 (NILP (Fget_range_table (make_int (ch), | 992 (NILP (Fget_range_table (make_int (ch), |
993 Vskip_chars_range_table, | 993 Vskip_chars_range_table, |
994 Qnil)) | 994 Qnil)) |
995 == negate)) | 995 == negate)) |
1133 | 1133 |
1134 static int | 1134 static int |
1135 trivial_regexp_p (Lisp_Object regexp) | 1135 trivial_regexp_p (Lisp_Object regexp) |
1136 { | 1136 { |
1137 Bytecount len = XSTRING_LENGTH (regexp); | 1137 Bytecount len = XSTRING_LENGTH (regexp); |
1138 Intbyte *s = XSTRING_DATA (regexp); | 1138 Ibyte *s = XSTRING_DATA (regexp); |
1139 while (--len >= 0) | 1139 while (--len >= 0) |
1140 { | 1140 { |
1141 switch (*s++) | 1141 switch (*s++) |
1142 { | 1142 { |
1143 case '.': case '*': case '+': case '?': case '[': case '^': case '$': | 1143 case '.': case '*': case '+': case '?': case '[': case '^': case '$': |
1183 search_buffer (struct buffer *buf, Lisp_Object string, Charbpos charbpos, | 1183 search_buffer (struct buffer *buf, Lisp_Object string, Charbpos charbpos, |
1184 Charbpos buflim, EMACS_INT n, int RE, Lisp_Object trt, | 1184 Charbpos buflim, EMACS_INT n, int RE, Lisp_Object trt, |
1185 Lisp_Object inverse_trt, int posix) | 1185 Lisp_Object inverse_trt, int posix) |
1186 { | 1186 { |
1187 Bytecount len = XSTRING_LENGTH (string); | 1187 Bytecount len = XSTRING_LENGTH (string); |
1188 Intbyte *base_pat = XSTRING_DATA (string); | 1188 Ibyte *base_pat = XSTRING_DATA (string); |
1189 REGISTER EMACS_INT i, j; | 1189 REGISTER EMACS_INT i, j; |
1190 Bytebpos p1, p2; | 1190 Bytebpos p1, p2; |
1191 Bytecount s1, s2; | 1191 Bytecount s1, s2; |
1192 Bytebpos pos, lim; | 1192 Bytebpos pos, lim; |
1193 | 1193 |
1276 } | 1276 } |
1277 else /* non-RE case */ | 1277 else /* non-RE case */ |
1278 { | 1278 { |
1279 int charset_base = -1; | 1279 int charset_base = -1; |
1280 int boyer_moore_ok = 1; | 1280 int boyer_moore_ok = 1; |
1281 Intbyte *pat = 0; | 1281 Ibyte *pat = 0; |
1282 Intbyte *patbuf = alloca_array (Intbyte, len * MAX_EMCHAR_LEN); | 1282 Ibyte *patbuf = alloca_array (Ibyte, len * MAX_ICHAR_LEN); |
1283 pat = patbuf; | 1283 pat = patbuf; |
1284 #ifdef MULE | 1284 #ifdef MULE |
1285 /* &&#### needs some 8-bit work here */ | 1285 /* &&#### needs some 8-bit work here */ |
1286 while (len > 0) | 1286 while (len > 0) |
1287 { | 1287 { |
1288 Intbyte tmp_str[MAX_EMCHAR_LEN]; | 1288 Ibyte tmp_str[MAX_ICHAR_LEN]; |
1289 Emchar c, translated, inverse; | 1289 Ichar c, translated, inverse; |
1290 Bytecount orig_bytelen, new_bytelen, inv_bytelen; | 1290 Bytecount orig_bytelen, new_bytelen, inv_bytelen; |
1291 | 1291 |
1292 /* If we got here and the RE flag is set, it's because | 1292 /* If we got here and the RE flag is set, it's because |
1293 we're dealing with a regexp known to be trivial, so the | 1293 we're dealing with a regexp known to be trivial, so the |
1294 backslash just quotes the next character. */ | 1294 backslash just quotes the next character. */ |
1295 if (RE && *base_pat == '\\') | 1295 if (RE && *base_pat == '\\') |
1296 { | 1296 { |
1297 len--; | 1297 len--; |
1298 base_pat++; | 1298 base_pat++; |
1299 } | 1299 } |
1300 c = charptr_emchar (base_pat); | 1300 c = itext_ichar (base_pat); |
1301 translated = TRANSLATE (trt, c); | 1301 translated = TRANSLATE (trt, c); |
1302 inverse = TRANSLATE (inverse_trt, c); | 1302 inverse = TRANSLATE (inverse_trt, c); |
1303 | 1303 |
1304 orig_bytelen = charptr_emchar_len (base_pat); | 1304 orig_bytelen = itext_ichar_len (base_pat); |
1305 inv_bytelen = set_charptr_emchar (tmp_str, inverse); | 1305 inv_bytelen = set_itext_ichar (tmp_str, inverse); |
1306 new_bytelen = set_charptr_emchar (tmp_str, translated); | 1306 new_bytelen = set_itext_ichar (tmp_str, translated); |
1307 | 1307 |
1308 if (new_bytelen != orig_bytelen || inv_bytelen != orig_bytelen) | 1308 if (new_bytelen != orig_bytelen || inv_bytelen != orig_bytelen) |
1309 boyer_moore_ok = 0; | 1309 boyer_moore_ok = 0; |
1310 if (translated != c || inverse != c) | 1310 if (translated != c || inverse != c) |
1311 { | 1311 { |
1312 /* Keep track of which character set row | 1312 /* Keep track of which character set row |
1313 contains the characters that need translation. */ | 1313 contains the characters that need translation. */ |
1314 int charset_base_code = c & ~EMCHAR_FIELD3_MASK; | 1314 int charset_base_code = c & ~ICHAR_FIELD3_MASK; |
1315 if (charset_base == -1) | 1315 if (charset_base == -1) |
1316 charset_base = charset_base_code; | 1316 charset_base = charset_base_code; |
1317 else if (charset_base != charset_base_code) | 1317 else if (charset_base != charset_base_code) |
1318 /* If two different rows appear, needing translation, | 1318 /* If two different rows appear, needing translation, |
1319 then we cannot use boyer_moore search. */ | 1319 then we cannot use boyer_moore search. */ |
1358 This kind of search works regardless of what is in PAT and | 1358 This kind of search works regardless of what is in PAT and |
1359 regardless of what is in TRT. It is used in cases where | 1359 regardless of what is in TRT. It is used in cases where |
1360 boyer_moore cannot work. */ | 1360 boyer_moore cannot work. */ |
1361 | 1361 |
1362 static Charbpos | 1362 static Charbpos |
1363 simple_search (struct buffer *buf, Intbyte *base_pat, Bytecount len, | 1363 simple_search (struct buffer *buf, Ibyte *base_pat, Bytecount len, |
1364 Bytebpos pos, Bytebpos lim, EMACS_INT n, Lisp_Object trt) | 1364 Bytebpos pos, Bytebpos lim, EMACS_INT n, Lisp_Object trt) |
1365 { | 1365 { |
1366 int forward = n > 0; | 1366 int forward = n > 0; |
1367 Bytecount buf_len = 0; /* Shut up compiler. */ | 1367 Bytecount buf_len = 0; /* Shut up compiler. */ |
1368 | 1368 |
1371 { | 1371 { |
1372 while (1) | 1372 while (1) |
1373 { | 1373 { |
1374 Bytecount this_len = len; | 1374 Bytecount this_len = len; |
1375 Bytebpos this_pos = pos; | 1375 Bytebpos this_pos = pos; |
1376 Intbyte *p = base_pat; | 1376 Ibyte *p = base_pat; |
1377 if (pos >= lim) | 1377 if (pos >= lim) |
1378 goto stop; | 1378 goto stop; |
1379 | 1379 |
1380 while (this_len > 0) | 1380 while (this_len > 0) |
1381 { | 1381 { |
1382 Emchar pat_ch, buf_ch; | 1382 Ichar pat_ch, buf_ch; |
1383 Bytecount pat_len; | 1383 Bytecount pat_len; |
1384 | 1384 |
1385 pat_ch = charptr_emchar (p); | 1385 pat_ch = itext_ichar (p); |
1386 buf_ch = BYTE_BUF_FETCH_CHAR (buf, this_pos); | 1386 buf_ch = BYTE_BUF_FETCH_CHAR (buf, this_pos); |
1387 | 1387 |
1388 buf_ch = TRANSLATE (trt, buf_ch); | 1388 buf_ch = TRANSLATE (trt, buf_ch); |
1389 | 1389 |
1390 if (buf_ch != pat_ch) | 1390 if (buf_ch != pat_ch) |
1391 break; | 1391 break; |
1392 | 1392 |
1393 pat_len = charptr_emchar_len (p); | 1393 pat_len = itext_ichar_len (p); |
1394 p += pat_len; | 1394 p += pat_len; |
1395 this_len -= pat_len; | 1395 this_len -= pat_len; |
1396 INC_BYTEBPOS (buf, this_pos); | 1396 INC_BYTEBPOS (buf, this_pos); |
1397 } | 1397 } |
1398 if (this_len == 0) | 1398 if (this_len == 0) |
1410 { | 1410 { |
1411 while (1) | 1411 while (1) |
1412 { | 1412 { |
1413 Bytecount this_len = len; | 1413 Bytecount this_len = len; |
1414 Bytebpos this_pos = pos; | 1414 Bytebpos this_pos = pos; |
1415 Intbyte *p; | 1415 Ibyte *p; |
1416 if (pos <= lim) | 1416 if (pos <= lim) |
1417 goto stop; | 1417 goto stop; |
1418 p = base_pat + len; | 1418 p = base_pat + len; |
1419 | 1419 |
1420 while (this_len > 0) | 1420 while (this_len > 0) |
1421 { | 1421 { |
1422 Emchar pat_ch, buf_ch; | 1422 Ichar pat_ch, buf_ch; |
1423 | 1423 |
1424 DEC_CHARPTR (p); | 1424 DEC_IBYTEPTR (p); |
1425 DEC_BYTEBPOS (buf, this_pos); | 1425 DEC_BYTEBPOS (buf, this_pos); |
1426 pat_ch = charptr_emchar (p); | 1426 pat_ch = itext_ichar (p); |
1427 buf_ch = BYTE_BUF_FETCH_CHAR (buf, this_pos); | 1427 buf_ch = BYTE_BUF_FETCH_CHAR (buf, this_pos); |
1428 | 1428 |
1429 buf_ch = TRANSLATE (trt, buf_ch); | 1429 buf_ch = TRANSLATE (trt, buf_ch); |
1430 | 1430 |
1431 if (buf_ch != pat_ch) | 1431 if (buf_ch != pat_ch) |
1432 break; | 1432 break; |
1433 | 1433 |
1434 this_len -= charptr_emchar_len (p); | 1434 this_len -= itext_ichar_len (p); |
1435 } | 1435 } |
1436 if (this_len == 0) | 1436 if (this_len == 0) |
1437 { | 1437 { |
1438 buf_len = pos - this_pos; | 1438 buf_len = pos - this_pos; |
1439 pos = this_pos; | 1439 pos = this_pos; |
1479 and do so after just a simple test of the context. | 1479 and do so after just a simple test of the context. |
1480 | 1480 |
1481 If that criterion is not satisfied, do not call this function. */ | 1481 If that criterion is not satisfied, do not call this function. */ |
1482 | 1482 |
1483 static Charbpos | 1483 static Charbpos |
1484 boyer_moore (struct buffer *buf, Intbyte *base_pat, Bytecount len, | 1484 boyer_moore (struct buffer *buf, Ibyte *base_pat, Bytecount len, |
1485 Bytebpos pos, Bytebpos lim, EMACS_INT n, Lisp_Object trt, | 1485 Bytebpos pos, Bytebpos lim, EMACS_INT n, Lisp_Object trt, |
1486 Lisp_Object inverse_trt, int charset_base) | 1486 Lisp_Object inverse_trt, int charset_base) |
1487 { | 1487 { |
1488 /* &&#### needs some 8-bit work here */ | 1488 /* &&#### needs some 8-bit work here */ |
1489 /* #### Someone really really really needs to comment the workings | 1489 /* #### Someone really really really needs to comment the workings |
1520 REGISTER Bytecount dirlen; | 1520 REGISTER Bytecount dirlen; |
1521 EMACS_INT infinity; | 1521 EMACS_INT infinity; |
1522 Bytebpos limit; | 1522 Bytebpos limit; |
1523 Bytecount stride_for_teases = 0; | 1523 Bytecount stride_for_teases = 0; |
1524 REGISTER EMACS_INT i, j; | 1524 REGISTER EMACS_INT i, j; |
1525 Intbyte *pat, *pat_end; | 1525 Ibyte *pat, *pat_end; |
1526 REGISTER Intbyte *cursor, *p_limit, *ptr2; | 1526 REGISTER Ibyte *cursor, *p_limit, *ptr2; |
1527 Intbyte simple_translate[0400]; | 1527 Ibyte simple_translate[0400]; |
1528 REGISTER int direction = ((n > 0) ? 1 : -1); | 1528 REGISTER int direction = ((n > 0) ? 1 : -1); |
1529 #ifdef MULE | 1529 #ifdef MULE |
1530 Intbyte translate_prev_byte = 0; | 1530 Ibyte translate_prev_byte = 0; |
1531 Intbyte translate_anteprev_byte = 0; | 1531 Ibyte translate_anteprev_byte = 0; |
1532 #endif | 1532 #endif |
1533 #ifdef C_ALLOCA | 1533 #ifdef C_ALLOCA |
1534 EMACS_INT BM_tab_space[0400]; | 1534 EMACS_INT BM_tab_space[0400]; |
1535 BM_tab = &BM_tab_space[0]; | 1535 BM_tab = &BM_tab_space[0]; |
1536 #else | 1536 #else |
1587 /* We use this for translation, instead of TRT itself. We | 1587 /* We use this for translation, instead of TRT itself. We |
1588 fill this in to handle the characters that actually occur | 1588 fill this in to handle the characters that actually occur |
1589 in the pattern. Others don't matter anyway! */ | 1589 in the pattern. Others don't matter anyway! */ |
1590 xzero (simple_translate); | 1590 xzero (simple_translate); |
1591 for (i = 0; i < 0400; i++) | 1591 for (i = 0; i < 0400; i++) |
1592 simple_translate[i] = (Intbyte) i; | 1592 simple_translate[i] = (Ibyte) i; |
1593 i = 0; | 1593 i = 0; |
1594 while (i != infinity) | 1594 while (i != infinity) |
1595 { | 1595 { |
1596 Intbyte *ptr = base_pat + i; | 1596 Ibyte *ptr = base_pat + i; |
1597 i += direction; | 1597 i += direction; |
1598 if (i == dirlen) | 1598 if (i == dirlen) |
1599 i = infinity; | 1599 i = infinity; |
1600 if (!NILP (trt)) | 1600 if (!NILP (trt)) |
1601 { | 1601 { |
1602 #ifdef MULE | 1602 #ifdef MULE |
1603 Emchar ch, untranslated; | 1603 Ichar ch, untranslated; |
1604 int this_translated = 1; | 1604 int this_translated = 1; |
1605 | 1605 |
1606 /* Is *PTR the last byte of a character? */ | 1606 /* Is *PTR the last byte of a character? */ |
1607 if (pat_end - ptr == 1 || intbyte_first_byte_p (ptr[1])) | 1607 if (pat_end - ptr == 1 || ibyte_first_byte_p (ptr[1])) |
1608 { | 1608 { |
1609 Intbyte *charstart = ptr; | 1609 Ibyte *charstart = ptr; |
1610 while (!intbyte_first_byte_p (*charstart)) | 1610 while (!ibyte_first_byte_p (*charstart)) |
1611 charstart--; | 1611 charstart--; |
1612 untranslated = charptr_emchar (charstart); | 1612 untranslated = itext_ichar (charstart); |
1613 if (charset_base == (untranslated & ~EMCHAR_FIELD3_MASK)) | 1613 if (charset_base == (untranslated & ~ICHAR_FIELD3_MASK)) |
1614 { | 1614 { |
1615 ch = TRANSLATE (trt, untranslated); | 1615 ch = TRANSLATE (trt, untranslated); |
1616 if (!intbyte_first_byte_p (*ptr)) | 1616 if (!ibyte_first_byte_p (*ptr)) |
1617 { | 1617 { |
1618 translate_prev_byte = ptr[-1]; | 1618 translate_prev_byte = ptr[-1]; |
1619 if (!intbyte_first_byte_p (translate_prev_byte)) | 1619 if (!ibyte_first_byte_p (translate_prev_byte)) |
1620 translate_anteprev_byte = ptr[-2]; | 1620 translate_anteprev_byte = ptr[-2]; |
1621 } | 1621 } |
1622 } | 1622 } |
1623 else | 1623 else |
1624 { | 1624 { |
1641 BM_tab[j] = dirlen - i; | 1641 BM_tab[j] = dirlen - i; |
1642 /* A translation table is accompanied by its inverse -- | 1642 /* A translation table is accompanied by its inverse -- |
1643 see comment in casetab.c. */ | 1643 see comment in casetab.c. */ |
1644 if (this_translated) | 1644 if (this_translated) |
1645 { | 1645 { |
1646 Emchar starting_ch = ch; | 1646 Ichar starting_ch = ch; |
1647 EMACS_INT starting_j = j; | 1647 EMACS_INT starting_j = j; |
1648 while (1) | 1648 while (1) |
1649 { | 1649 { |
1650 ch = TRANSLATE (inverse_trt, ch); | 1650 ch = TRANSLATE (inverse_trt, ch); |
1651 if (ch > 0400) | 1651 if (ch > 0400) |
1654 j = (unsigned char) ch; | 1654 j = (unsigned char) ch; |
1655 | 1655 |
1656 /* For all the characters that map into CH, | 1656 /* For all the characters that map into CH, |
1657 set up simple_translate to map the last byte | 1657 set up simple_translate to map the last byte |
1658 into STARTING_J. */ | 1658 into STARTING_J. */ |
1659 simple_translate[j] = (Intbyte) starting_j; | 1659 simple_translate[j] = (Ibyte) starting_j; |
1660 if (ch == starting_ch) | 1660 if (ch == starting_ch) |
1661 break; | 1661 break; |
1662 BM_tab[j] = dirlen - i; | 1662 BM_tab[j] = dirlen - i; |
1663 } | 1663 } |
1664 } | 1664 } |
1671 BM_tab[j] = dirlen - i; | 1671 BM_tab[j] = dirlen - i; |
1672 /* A translation table is accompanied by its inverse -- | 1672 /* A translation table is accompanied by its inverse -- |
1673 see comment in casetab.c. */ | 1673 see comment in casetab.c. */ |
1674 while ((j = TRANSLATE (inverse_trt, j)) != k) | 1674 while ((j = TRANSLATE (inverse_trt, j)) != k) |
1675 { | 1675 { |
1676 simple_translate[j] = (Intbyte) k; | 1676 simple_translate[j] = (Ibyte) k; |
1677 BM_tab[j] = dirlen - i; | 1677 BM_tab[j] = dirlen - i; |
1678 } | 1678 } |
1679 #endif | 1679 #endif |
1680 } | 1680 } |
1681 else | 1681 else |
1697 /* loop invariant - pos points at where last char (first char if | 1697 /* loop invariant - pos points at where last char (first char if |
1698 reverse) of pattern would align in a possible match. */ | 1698 reverse) of pattern would align in a possible match. */ |
1699 while (n != 0) | 1699 while (n != 0) |
1700 { | 1700 { |
1701 Bytebpos tail_end; | 1701 Bytebpos tail_end; |
1702 Intbyte *tail_end_ptr; | 1702 Ibyte *tail_end_ptr; |
1703 /* It's been reported that some (broken) compiler thinks | 1703 /* It's been reported that some (broken) compiler thinks |
1704 that Boolean expressions in an arithmetic context are | 1704 that Boolean expressions in an arithmetic context are |
1705 unsigned. Using an explicit ?1:0 prevents this. */ | 1705 unsigned. Using an explicit ?1:0 prevents this. */ |
1706 if ((lim - pos - ((direction > 0) ? 1 : 0)) * direction < 0) | 1706 if ((lim - pos - ((direction > 0) ? 1 : 0)) * direction < 0) |
1707 return n * (0 - direction); | 1707 return n * (0 - direction); |
1780 if (!NILP (trt)) | 1780 if (!NILP (trt)) |
1781 { | 1781 { |
1782 while ((i -= direction) + direction != 0) | 1782 while ((i -= direction) + direction != 0) |
1783 { | 1783 { |
1784 #ifdef MULE | 1784 #ifdef MULE |
1785 Emchar ch; | 1785 Ichar ch; |
1786 cursor -= direction; | 1786 cursor -= direction; |
1787 /* Translate only the last byte of a character. */ | 1787 /* Translate only the last byte of a character. */ |
1788 if ((cursor == tail_end_ptr | 1788 if ((cursor == tail_end_ptr |
1789 || intbyte_first_byte_p (cursor[1])) | 1789 || ibyte_first_byte_p (cursor[1])) |
1790 && (intbyte_first_byte_p (cursor[0]) | 1790 && (ibyte_first_byte_p (cursor[0]) |
1791 || (translate_prev_byte == cursor[-1] | 1791 || (translate_prev_byte == cursor[-1] |
1792 && (intbyte_first_byte_p (translate_prev_byte) | 1792 && (ibyte_first_byte_p (translate_prev_byte) |
1793 || translate_anteprev_byte == cursor[-2])))) | 1793 || translate_anteprev_byte == cursor[-2])))) |
1794 ch = simple_translate[*cursor]; | 1794 ch = simple_translate[*cursor]; |
1795 else | 1795 else |
1796 ch = *cursor; | 1796 ch = *cursor; |
1797 if (pat[i] != ch) | 1797 if (pat[i] != ch) |
1867 pos -= infinity; | 1867 pos -= infinity; |
1868 i = dirlen - direction; | 1868 i = dirlen - direction; |
1869 while ((i -= direction) + direction != 0) | 1869 while ((i -= direction) + direction != 0) |
1870 { | 1870 { |
1871 #ifdef MULE | 1871 #ifdef MULE |
1872 Emchar ch; | 1872 Ichar ch; |
1873 Intbyte *ptr; | 1873 Ibyte *ptr; |
1874 #endif | 1874 #endif |
1875 pos -= direction; | 1875 pos -= direction; |
1876 #ifdef MULE | 1876 #ifdef MULE |
1877 ptr = BYTE_BUF_BYTE_ADDRESS_NO_VERIFY (buf, pos); | 1877 ptr = BYTE_BUF_BYTE_ADDRESS_NO_VERIFY (buf, pos); |
1878 if ((ptr == tail_end_ptr | 1878 if ((ptr == tail_end_ptr |
1879 || intbyte_first_byte_p (ptr[1])) | 1879 || ibyte_first_byte_p (ptr[1])) |
1880 && (intbyte_first_byte_p (ptr[0]) | 1880 && (ibyte_first_byte_p (ptr[0]) |
1881 || (translate_prev_byte == ptr[-1] | 1881 || (translate_prev_byte == ptr[-1] |
1882 && (intbyte_first_byte_p (translate_prev_byte) | 1882 && (ibyte_first_byte_p (translate_prev_byte) |
1883 || translate_anteprev_byte == ptr[-2])))) | 1883 || translate_anteprev_byte == ptr[-2])))) |
1884 ch = simple_translate[*ptr]; | 1884 ch = simple_translate[*ptr]; |
1885 else | 1885 else |
1886 ch = *ptr; | 1886 ch = *ptr; |
1887 if (pat[i] != ch) | 1887 if (pat[i] != ch) |
1965 | 1965 |
1966 CHECK_STRING (string); | 1966 CHECK_STRING (string); |
1967 len = string_char_length (string); | 1967 len = string_char_length (string); |
1968 | 1968 |
1969 for (i = 0; i < len; i++) | 1969 for (i = 0; i < len; i++) |
1970 if (!WORD_SYNTAX_P (syntax_table, string_emchar (string, i))) | 1970 if (!WORD_SYNTAX_P (syntax_table, string_ichar (string, i))) |
1971 { | 1971 { |
1972 punct_count++; | 1972 punct_count++; |
1973 if (i > 0 && WORD_SYNTAX_P (syntax_table, | 1973 if (i > 0 && WORD_SYNTAX_P (syntax_table, |
1974 string_emchar (string, i - 1))) | 1974 string_ichar (string, i - 1))) |
1975 word_count++; | 1975 word_count++; |
1976 } | 1976 } |
1977 if (WORD_SYNTAX_P (syntax_table, string_emchar (string, len - 1))) | 1977 if (WORD_SYNTAX_P (syntax_table, string_ichar (string, len - 1))) |
1978 word_count++; | 1978 word_count++; |
1979 if (!word_count) return build_string (""); | 1979 if (!word_count) return build_string (""); |
1980 | 1980 |
1981 { | 1981 { |
1982 /* The following value is an upper bound on the amount of storage we | 1982 /* The following value is an upper bound on the amount of storage we |
1983 need. In non-Mule, it is exact. */ | 1983 need. In non-Mule, it is exact. */ |
1984 Intbyte *storage = | 1984 Ibyte *storage = |
1985 (Intbyte *) ALLOCA (XSTRING_LENGTH (string) - punct_count + | 1985 (Ibyte *) ALLOCA (XSTRING_LENGTH (string) - punct_count + |
1986 5 * (word_count - 1) + 4); | 1986 5 * (word_count - 1) + 4); |
1987 Intbyte *o = storage; | 1987 Ibyte *o = storage; |
1988 | 1988 |
1989 *o++ = '\\'; | 1989 *o++ = '\\'; |
1990 *o++ = 'b'; | 1990 *o++ = 'b'; |
1991 | 1991 |
1992 for (i = 0; i < len; i++) | 1992 for (i = 0; i < len; i++) |
1993 { | 1993 { |
1994 Emchar ch = string_emchar (string, i); | 1994 Ichar ch = string_ichar (string, i); |
1995 | 1995 |
1996 if (WORD_SYNTAX_P (syntax_table, ch)) | 1996 if (WORD_SYNTAX_P (syntax_table, ch)) |
1997 o += set_charptr_emchar (o, ch); | 1997 o += set_itext_ichar (o, ch); |
1998 else if (i > 0 | 1998 else if (i > 0 |
1999 && WORD_SYNTAX_P (syntax_table, | 1999 && WORD_SYNTAX_P (syntax_table, |
2000 string_emchar (string, i - 1)) | 2000 string_ichar (string, i - 1)) |
2001 && --word_count) | 2001 && --word_count) |
2002 { | 2002 { |
2003 *o++ = '\\'; | 2003 *o++ = '\\'; |
2004 *o++ = 'W'; | 2004 *o++ = 'W'; |
2005 *o++ = '\\'; | 2005 *o++ = '\\'; |
2285 Charbpos pos, last; | 2285 Charbpos pos, last; |
2286 int some_multiletter_word; | 2286 int some_multiletter_word; |
2287 int some_lowercase; | 2287 int some_lowercase; |
2288 int some_uppercase; | 2288 int some_uppercase; |
2289 int some_nonuppercase_initial; | 2289 int some_nonuppercase_initial; |
2290 Emchar c, prevc; | 2290 Ichar c, prevc; |
2291 Charcount inslen; | 2291 Charcount inslen; |
2292 struct buffer *buf; | 2292 struct buffer *buf; |
2293 Lisp_Object syntax_table; | 2293 Lisp_Object syntax_table; |
2294 int mc_count; | 2294 int mc_count; |
2295 Lisp_Object buffer; | 2295 Lisp_Object buffer; |
2373 for (pos = search_regs.start[sub]; pos < last; pos++) | 2373 for (pos = search_regs.start[sub]; pos < last; pos++) |
2374 { | 2374 { |
2375 if (NILP (string)) | 2375 if (NILP (string)) |
2376 c = BUF_FETCH_CHAR (buf, pos); | 2376 c = BUF_FETCH_CHAR (buf, pos); |
2377 else | 2377 else |
2378 c = string_emchar (string, pos); | 2378 c = string_ichar (string, pos); |
2379 | 2379 |
2380 if (LOWERCASEP (buf, c)) | 2380 if (LOWERCASEP (buf, c)) |
2381 { | 2381 { |
2382 /* Cannot be all caps if any original char is lower case */ | 2382 /* Cannot be all caps if any original char is lower case */ |
2383 | 2383 |
2458 /* If SUBSTART is set, we need to also insert the | 2458 /* If SUBSTART is set, we need to also insert the |
2459 text from SUBSTART to SUBEND in the original string. */ | 2459 text from SUBSTART to SUBEND in the original string. */ |
2460 Charcount substart = -1; | 2460 Charcount substart = -1; |
2461 Charcount subend = -1; | 2461 Charcount subend = -1; |
2462 | 2462 |
2463 c = string_emchar (replacement, strpos); | 2463 c = string_ichar (replacement, strpos); |
2464 if (c == '\\' && strpos < stlen - 1) | 2464 if (c == '\\' && strpos < stlen - 1) |
2465 { | 2465 { |
2466 c = string_emchar (replacement, ++strpos); | 2466 c = string_ichar (replacement, ++strpos); |
2467 if (c == '&') | 2467 if (c == '&') |
2468 { | 2468 { |
2469 literal_end = strpos - 1; | 2469 literal_end = strpos - 1; |
2470 substart = search_regs.start[0]; | 2470 substart = search_regs.start[0]; |
2471 subend = search_regs.end[0]; | 2471 subend = search_regs.end[0]; |
2551 Charcount stlen = string_char_length (replacement); | 2551 Charcount stlen = string_char_length (replacement); |
2552 Charcount strpos; | 2552 Charcount strpos; |
2553 | 2553 |
2554 for (strpos = 0; strpos < stlen; strpos++) | 2554 for (strpos = 0; strpos < stlen; strpos++) |
2555 { | 2555 { |
2556 Emchar curchar = string_emchar (replacement, strpos); | 2556 Ichar curchar = string_ichar (replacement, strpos); |
2557 Emchar newchar = -1; | 2557 Ichar newchar = -1; |
2558 if (i < Dynarr_length (ul_pos_dynarr) && | 2558 if (i < Dynarr_length (ul_pos_dynarr) && |
2559 strpos == Dynarr_at (ul_pos_dynarr, i)) | 2559 strpos == Dynarr_at (ul_pos_dynarr, i)) |
2560 { | 2560 { |
2561 int new_action = Dynarr_at (ul_action_dynarr, i); | 2561 int new_action = Dynarr_at (ul_action_dynarr, i); |
2562 i++; | 2562 i++; |
2612 exactly complementing BUF_SET_PT() above. | 2612 exactly complementing BUF_SET_PT() above. |
2613 During the loop, it keeps track of the amount inserted. | 2613 During the loop, it keeps track of the amount inserted. |
2614 */ | 2614 */ |
2615 Charcount offset = BUF_PT (buf) - search_regs.start[sub]; | 2615 Charcount offset = BUF_PT (buf) - search_regs.start[sub]; |
2616 | 2616 |
2617 c = string_emchar (replacement, strpos); | 2617 c = string_ichar (replacement, strpos); |
2618 if (c == '\\' && strpos < stlen - 1) | 2618 if (c == '\\' && strpos < stlen - 1) |
2619 { | 2619 { |
2620 /* XXX FIXME: replacing just a substring non-literally | 2620 /* XXX FIXME: replacing just a substring non-literally |
2621 using backslash refs to the match looks dangerous. But | 2621 using backslash refs to the match looks dangerous. But |
2622 <15366.18513.698042.156573@ns.caldera.de> from Torsten Duwe | 2622 <15366.18513.698042.156573@ns.caldera.de> from Torsten Duwe |
2623 <duwe@caldera.de> claims Finsert_buffer_substring already | 2623 <duwe@caldera.de> claims Finsert_buffer_substring already |
2624 handles this correctly. | 2624 handles this correctly. |
2625 */ | 2625 */ |
2626 c = string_emchar (replacement, ++strpos); | 2626 c = string_ichar (replacement, ++strpos); |
2627 if (c == '&') | 2627 if (c == '&') |
2628 Finsert_buffer_substring | 2628 Finsert_buffer_substring |
2629 (buffer, | 2629 (buffer, |
2630 make_int (search_regs.start[0] + offset), | 2630 make_int (search_regs.start[0] + offset), |
2631 make_int (search_regs.end[0] + offset)); | 2631 make_int (search_regs.end[0] + offset)); |
2684 int i = 0; | 2684 int i = 0; |
2685 int cur_action = 'E'; | 2685 int cur_action = 'E'; |
2686 | 2686 |
2687 for (pos = BUF_PT (buf) - inslen; pos < eend; pos++) | 2687 for (pos = BUF_PT (buf) - inslen; pos < eend; pos++) |
2688 { | 2688 { |
2689 Emchar curchar = BUF_FETCH_CHAR (buf, pos); | 2689 Ichar curchar = BUF_FETCH_CHAR (buf, pos); |
2690 Emchar newchar = -1; | 2690 Ichar newchar = -1; |
2691 if (i < Dynarr_length (ul_pos_dynarr) && | 2691 if (i < Dynarr_length (ul_pos_dynarr) && |
2692 pos == Dynarr_at (ul_pos_dynarr, i)) | 2692 pos == Dynarr_at (ul_pos_dynarr, i)) |
2693 { | 2693 { |
2694 int new_action = Dynarr_at (ul_action_dynarr, i); | 2694 int new_action = Dynarr_at (ul_action_dynarr, i); |
2695 i++; | 2695 i++; |
2961 DEFUN ("regexp-quote", Fregexp_quote, 1, 1, 0, /* | 2961 DEFUN ("regexp-quote", Fregexp_quote, 1, 1, 0, /* |
2962 Return a regexp string which matches exactly STRING and nothing else. | 2962 Return a regexp string which matches exactly STRING and nothing else. |
2963 */ | 2963 */ |
2964 (string)) | 2964 (string)) |
2965 { | 2965 { |
2966 REGISTER Intbyte *in, *out, *end; | 2966 REGISTER Ibyte *in, *out, *end; |
2967 REGISTER Intbyte *temp; | 2967 REGISTER Ibyte *temp; |
2968 | 2968 |
2969 CHECK_STRING (string); | 2969 CHECK_STRING (string); |
2970 | 2970 |
2971 temp = (Intbyte *) ALLOCA (XSTRING_LENGTH (string) * 2); | 2971 temp = (Ibyte *) ALLOCA (XSTRING_LENGTH (string) * 2); |
2972 | 2972 |
2973 /* Now copy the data into the new string, inserting escapes. */ | 2973 /* Now copy the data into the new string, inserting escapes. */ |
2974 | 2974 |
2975 in = XSTRING_DATA (string); | 2975 in = XSTRING_DATA (string); |
2976 end = in + XSTRING_LENGTH (string); | 2976 end = in + XSTRING_LENGTH (string); |
2977 out = temp; | 2977 out = temp; |
2978 | 2978 |
2979 while (in < end) | 2979 while (in < end) |
2980 { | 2980 { |
2981 Emchar c = charptr_emchar (in); | 2981 Ichar c = itext_ichar (in); |
2982 | 2982 |
2983 if (c == '[' || c == ']' | 2983 if (c == '[' || c == ']' |
2984 || c == '*' || c == '.' || c == '\\' | 2984 || c == '*' || c == '.' || c == '\\' |
2985 || c == '?' || c == '+' | 2985 || c == '?' || c == '+' |
2986 || c == '^' || c == '$') | 2986 || c == '^' || c == '$') |
2987 *out++ = '\\'; | 2987 *out++ = '\\'; |
2988 out += set_charptr_emchar (out, c); | 2988 out += set_itext_ichar (out, c); |
2989 INC_CHARPTR (in); | 2989 INC_IBYTEPTR (in); |
2990 } | 2990 } |
2991 | 2991 |
2992 return make_string (temp, out - temp); | 2992 return make_string (temp, out - temp); |
2993 } | 2993 } |
2994 | 2994 |