comparison src/editfns.c @ 826:6728e641994e

[xemacs-hg @ 2002-05-05 11:30:15 by ben] syntax cache, 8-bit-format, lots of code cleanup README.packages: Update info about --package-path. i.c: Create an inheritable event and pass it on to XEmacs, so that ^C can be handled properly. Intercept ^C and signal the event. "Stop Build" in VC++ now works. bytecomp-runtime.el: Doc string changes. compat.el: Some attempts to redo this to make it truly useful and fix the "multiple versions interacting with each other" problem. Not yet done. Currently doesn't work. files.el: Use with-obsolete-variable to avoid warnings in new revert-buffer code. xemacs.mak: Split up CFLAGS into a version without flags specifying the C library. The problem seems to be that minitar depends on zlib, which depends specifically on libc.lib, not on any of the other C libraries. Unless you compile with libc.lib, you get errors -- specifically, no _errno in the other libraries, which must make it something other than an int. (#### But this doesn't seem to obtain in XEmacs, which also uses zlib, and can be linked with any of the C libraries. Maybe zlib is used differently and doesn't need errno, or maybe XEmacs provides an int errno; ... I don't understand. Makefile.in.in: Fix so that packages are around when testing. abbrev.c, alloc.c, buffer.c, buffer.h, bytecode.c, callint.c, casefiddle.c, casetab.c, casetab.h, charset.h, chartab.c, chartab.h, cmds.c, console-msw.h, console-stream.c, console-x.c, console.c, console.h, data.c, device-msw.c, device.c, device.h, dialog-msw.c, dialog-x.c, dired-msw.c, dired.c, doc.c, doprnt.c, dumper.c, editfns.c, elhash.c, emacs.c, eval.c, event-Xt.c, event-gtk.c, event-msw.c, event-stream.c, events.c, events.h, extents.c, extents.h, faces.c, file-coding.c, file-coding.h, fileio.c, fns.c, font-lock.c, frame-gtk.c, frame-msw.c, frame-x.c, frame.c, frame.h, glade.c, glyphs-gtk.c, glyphs-msw.c, glyphs-msw.h, glyphs-x.c, glyphs.c, glyphs.h, gui-msw.c, gui-x.c, gui.h, gutter.h, hash.h, indent.c, insdel.c, intl-win32.c, intl.c, keymap.c, lisp-disunion.h, lisp-union.h, lisp.h, lread.c, lrecord.h, lstream.c, lstream.h, marker.c, menubar-gtk.c, menubar-msw.c, menubar-x.c, menubar.c, minibuf.c, mule-ccl.c, mule-charset.c, mule-coding.c, mule-wnnfns.c, nas.c, objects-msw.c, objects-x.c, opaque.c, postgresql.c, print.c, process-nt.c, process-unix.c, process.c, process.h, profile.c, rangetab.c, redisplay-gtk.c, redisplay-msw.c, redisplay-output.c, redisplay-x.c, redisplay.c, redisplay.h, regex.c, regex.h, scrollbar-msw.c, search.c, select-x.c, specifier.c, specifier.h, symbols.c, symsinit.h, syntax.c, syntax.h, syswindows.h, tests.c, text.c, text.h, tooltalk.c, ui-byhand.c, ui-gtk.c, unicode.c, win32.c, window.c: Another big Ben patch. -- FUNCTIONALITY CHANGES: add partial support for 8-bit-fixed, 16-bit-fixed, and 32-bit-fixed formats. not quite done yet. (in particular, needs functions to actually convert the buffer.) NOTE: lots of changes to regex.c here. also, many new *_fmt() inline funs that take an Internal_Format argument. redo syntax cache code. make the cache per-buffer; keep the cache valid across calls to functions that use it. also keep it valid across insertions/deletions and extent changes, as much as is possible. eliminate the junky regex-reentrancy code by passing in the relevant lisp info to the regex routines as local vars. add general mechanism in extents code for signalling extent changes. fix numerous problems with the case-table implementation; yoshiki never properly transferred many algorithms from old-style to new-style case tables. redo char tables to support a default argument, so that mapping only occurs over changed args. change many chartab functions to accept Lisp_Object instead of Lisp_Char_Table *. comment out the code in font-lock.c by default, because font-lock.el no longer uses it. we should consider eliminating it entirely. Don't output bell as ^G in console-stream when not a TTY. add -mswindows-termination-handle to interface with i.c, so we can properly kill a build. add more error-checking to buffer/string macros. add some additional buffer_or_string_() funs. -- INTERFACE CHANGES AFFECTING MORE CODE: switch the arguments of write_c_string and friends to be consistent with write_fmt_string, which must have printcharfun first. change BI_* macros to BYTE_* for increased clarity; similarly for bi_* local vars. change VOID_TO_LISP to be a one-argument function. eliminate no-longer-needed CVOID_TO_LISP. -- char/string macro changes: rename MAKE_CHAR() to make_emchar() for slightly less confusion with make_char(). (The former generates an Emchar, the latter a Lisp object. Conceivably we should rename make_char() -> wrap_char() and similarly for make_int(), make_float().) Similar changes for other *CHAR* macros -- we now consistently use names with `emchar' whenever we are working with Emchars. Any remaining name with just `char' always refers to a Lisp object. rename macros with XSTRING_* to string_* except for those that reference actual fields in the Lisp_String object, following conventions used elsewhere. rename set_string_{data,length} macros (the only ones to work with a Lisp_String_* instead of a Lisp_Object) to set_lispstringp_* to make the difference clear. try to be consistent about caps vs. lowercase in macro/inline-fun names for chars and such, which wasn't the case before. we now reserve caps either for XFOO_ macros that reference object fields (e.g. XSTRING_DATA) or for things that have non-function semantics, e.g. directly modifying an arg (BREAKUP_EMCHAR) or evaluating an arg (any arg) more than once. otherwise, use lowercase. here is a summary of most of the macros/inline funs changed by all of the above changes: BYTE_*_P -> byte_*_p XSTRING_BYTE -> string_byte set_string_data/length -> set_lispstringp_data/length XSTRING_CHAR_LENGTH -> string_char_length XSTRING_CHAR -> string_emchar INTBYTE_FIRST_BYTE_P -> intbyte_first_byte_p INTBYTE_LEADING_BYTE_P -> intbyte_leading_byte_p charptr_copy_char -> charptr_copy_emchar LEADING_BYTE_* -> leading_byte_* CHAR_* -> EMCHAR_* *_CHAR_* -> *_EMCHAR_* *_CHAR -> *_EMCHAR CHARSET_BY_ -> charset_by_* BYTE_SHIFT_JIS* -> byte_shift_jis* BYTE_BIG5* -> byte_big5* REP_BYTES_BY_FIRST_BYTE -> rep_bytes_by_first_byte char_to_unicode -> emchar_to_unicode valid_char_p -> valid_emchar_p Change intbyte_strcmp -> qxestrcmp_c (duplicated functionality). -- INTERFACE CHANGES AFFECTING LESS CODE: use DECLARE_INLINE_HEADER in various places. remove '#ifdef emacs' from XEmacs-only files. eliminate CHAR_TABLE_VALUE(), which duplicated the functionality of get_char_table(). add BUFFER_TEXT_LOOP to simplify iterations over buffer text. define typedefs for signed and unsigned types of fixed sizes (INT_32_BIT, UINT_32_BIT, etc.). create ALIGN_FOR_TYPE as a higher-level interface onto ALIGN_SIZE; fix code to use it. add charptr_emchar_len to return the text length of the character pointed to by a ptr; use it in place of charcount_to_bytecount(..., 1). add emchar_len to return the text length of a given character. add types Bytexpos and Charxpos to generalize Bytebpos/Bytecount and Charbpos/Charcount, in code (particularly, the extents code and redisplay code) that works with either kind of index. rename redisplay struct params with names such as `charbpos' to e.g. `charpos' when they are e.g. a Charxpos, not a Charbpos. eliminate xxDEFUN in place of DEFUN; no longer necessary with changes awhile back to doc.c. split up big ugly combined list of EXFUNs in lisp.h on a file-by-file basis, since other prototypes are similarly split. rewrite some "*_UNSAFE" macros as inline funs and eliminate the _UNSAFE suffix. move most string code from lisp.h to text.h; the string code and text.h code is now intertwined in such a fashion that they need to be in the same place and partially interleaved. (you can't create forward references for inline funs) automated/lisp-tests.el, automated/symbol-tests.el, automated/test-harness.el: Fix test harness to output FAIL messages to stderr when in batch mode. Fix up some problems in lisp-tests/symbol-tests that were causing spurious failures.
author ben
date Sun, 05 May 2002 11:33:57 +0000
parents a634e3b7acc8
children 047d37eb70d7
comparison
equal deleted inserted replaced
825:eb3bc15a6e0f 826:6728e641994e
132 (string)) 132 (string))
133 { 133 {
134 CHECK_STRING (string); 134 CHECK_STRING (string);
135 135
136 if (XSTRING_LENGTH (string) != 0) 136 if (XSTRING_LENGTH (string) != 0)
137 return make_char (XSTRING_CHAR (string, 0)); 137 return make_char (string_emchar (string, 0));
138 else 138 else
139 /* This used to return Qzero. That is broken, broken, broken. */ 139 /* This used to return Qzero. That is broken, broken, broken. */
140 /* It might be kinder to signal an error directly. -slb */ 140 /* It might be kinder to signal an error directly. -slb */
141 return Qnil; 141 return Qnil;
142 } 142 }
174 struct buffer *b = decode_buffer (buffer, 1); 174 struct buffer *b = decode_buffer (buffer, 1);
175 if (NILP (dont_copy_p)) 175 if (NILP (dont_copy_p))
176 return Fcopy_marker (b->point_marker, Qnil); 176 return Fcopy_marker (b->point_marker, Qnil);
177 else 177 else
178 return b->point_marker; 178 return b->point_marker;
179 }
180
181 /* The following two functions end up being identical but it's
182 cleaner to declare them separately. */
183
184 Charbpos
185 charbpos_clip_to_bounds (Charbpos lower, Charbpos num, Charbpos upper)
186 {
187 return (num < lower ? lower :
188 num > upper ? upper :
189 num);
190 }
191
192 Bytebpos
193 bytebpos_clip_to_bounds (Bytebpos lower, Bytebpos num, Bytebpos upper)
194 {
195 return (num < lower ? lower :
196 num > upper ? upper :
197 num);
198 } 179 }
199 180
200 /* 181 /*
201 * Chuck says: 182 * Chuck says:
202 * There is no absolute way to determine if goto-char is the function 183 * There is no absolute way to determine if goto-char is the function
1854 1835
1855 get_buffer_range_char (buf, start, end, &pos, &stop, 0); 1836 get_buffer_range_char (buf, start, end, &pos, &stop, 0);
1856 mc_count = begin_multiple_change (buf, pos, stop); 1837 mc_count = begin_multiple_change (buf, pos, stop);
1857 if (STRINGP (table)) 1838 if (STRINGP (table))
1858 { 1839 {
1859 Charcount size = XSTRING_CHAR_LENGTH (table); 1840 Charcount size = string_char_length (table);
1860 #ifdef MULE 1841 #ifdef MULE
1861 /* Under Mule, XSTRING_CHAR(n) is O(n), so for large tables or 1842 /* Under Mule, string_emchar(n) is O(n), so for large tables or
1862 large regions it makes sense to create an array of Emchars. */ 1843 large regions it makes sense to create an array of Emchars. */
1863 if (size * (stop - pos) > 65536) 1844 if (size * (stop - pos) > 65536)
1864 { 1845 {
1865 Emchar *etable = alloca_array (Emchar, size); 1846 Emchar *etable = alloca_array (Emchar, size);
1866 convert_intbyte_string_into_emchar_string 1847 convert_intbyte_string_into_emchar_string
1883 { 1864 {
1884 for (; pos < stop && (oc = BUF_FETCH_CHAR (buf, pos), 1); pos++) 1865 for (; pos < stop && (oc = BUF_FETCH_CHAR (buf, pos), 1); pos++)
1885 { 1866 {
1886 if (oc < size) 1867 if (oc < size)
1887 { 1868 {
1888 Emchar nc = XSTRING_CHAR (table, oc); 1869 Emchar nc = string_emchar (table, oc);
1889 if (nc != oc) 1870 if (nc != oc)
1890 { 1871 {
1891 buffer_replace_char (buf, pos, nc, 0, 0); 1872 buffer_replace_char (buf, pos, nc, 0, 0);
1892 ++cnt; 1873 ++cnt;
1893 } 1874 }
1915 ++cnt; 1896 ++cnt;
1916 } 1897 }
1917 } 1898 }
1918 else if (STRINGP (replacement)) 1899 else if (STRINGP (replacement))
1919 { 1900 {
1920 Charcount incr = XSTRING_CHAR_LENGTH (replacement) - 1; 1901 Charcount incr = string_char_length (replacement) - 1;
1921 buffer_delete_range (buf, pos, pos + 1, 0); 1902 buffer_delete_range (buf, pos, pos + 1, 0);
1922 buffer_insert_lisp_string_1 (buf, pos, replacement, 0); 1903 buffer_insert_lisp_string_1 (buf, pos, replacement, 0);
1923 pos += incr, stop += incr; 1904 pos += incr, stop += incr;
1924 ++cnt; 1905 ++cnt;
1925 } 1906 }
1933 } 1914 }
1934 else if (CHAR_TABLEP (table) 1915 else if (CHAR_TABLEP (table)
1935 && (XCHAR_TABLE_TYPE (table) == CHAR_TABLE_TYPE_GENERIC 1916 && (XCHAR_TABLE_TYPE (table) == CHAR_TABLE_TYPE_GENERIC
1936 || XCHAR_TABLE_TYPE (table) == CHAR_TABLE_TYPE_CHAR)) 1917 || XCHAR_TABLE_TYPE (table) == CHAR_TABLE_TYPE_CHAR))
1937 { 1918 {
1938 Lisp_Char_Table *ctable = XCHAR_TABLE (table);
1939 1919
1940 for (; pos < stop && (oc = BUF_FETCH_CHAR (buf, pos), 1); pos++) 1920 for (; pos < stop && (oc = BUF_FETCH_CHAR (buf, pos), 1); pos++)
1941 { 1921 {
1942 Lisp_Object replacement = get_char_table (oc, ctable); 1922 Lisp_Object replacement = get_char_table (oc, table);
1943 retry2: 1923 retry2:
1944 if (CHAR_OR_CHAR_INTP (replacement)) 1924 if (CHAR_OR_CHAR_INTP (replacement))
1945 { 1925 {
1946 Emchar nc = XCHAR_OR_CHAR_INT (replacement); 1926 Emchar nc = XCHAR_OR_CHAR_INT (replacement);
1947 if (nc != oc) 1927 if (nc != oc)
1950 ++cnt; 1930 ++cnt;
1951 } 1931 }
1952 } 1932 }
1953 else if (STRINGP (replacement)) 1933 else if (STRINGP (replacement))
1954 { 1934 {
1955 Charcount incr = XSTRING_CHAR_LENGTH (replacement) - 1; 1935 Charcount incr = string_char_length (replacement) - 1;
1956 buffer_delete_range (buf, pos, pos + 1, 0); 1936 buffer_delete_range (buf, pos, pos + 1, 0);
1957 buffer_insert_lisp_string_1 (buf, pos, replacement, 0); 1937 buffer_insert_lisp_string_1 (buf, pos, replacement, 0);
1958 pos += incr, stop += incr; 1938 pos += incr, stop += incr;
1959 ++cnt; 1939 ++cnt;
1960 } 1940 }
1961 else if (!NILP (replacement)) 1941 else if (!NILP (replacement))
1962 { 1942 {
1963 replacement = wrong_type_argument (Qchar_or_string_p, replacement); 1943 replacement = wrong_type_argument (Qchar_or_string_p,
1944 replacement);
1964 goto retry2; 1945 goto retry2;
1965 } 1946 }
1966 } 1947 }
1967 } 1948 }
1968 else 1949 else
1979 If optional third arg BUFFER is nil, the current buffer is assumed. 1960 If optional third arg BUFFER is nil, the current buffer is assumed.
1980 */ 1961 */
1981 (start, end, buffer)) 1962 (start, end, buffer))
1982 { 1963 {
1983 /* This function can GC */ 1964 /* This function can GC */
1984 Charbpos bp_start, bp_end; 1965 Charbpos char_start, char_end;
1985 struct buffer *buf = decode_buffer (buffer, 1); 1966 struct buffer *buf = decode_buffer (buffer, 1);
1986 1967
1987 get_buffer_range_char (buf, start, end, &bp_start, &bp_end, 0); 1968 get_buffer_range_char (buf, start, end, &char_start, &char_end, 0);
1988 buffer_delete_range (buf, bp_start, bp_end, 0); 1969 buffer_delete_range (buf, char_start, char_end, 0);
1989 return Qnil; 1970 return Qnil;
1990 } 1971 }
1991 1972
1992 void 1973 void
1993 widen_buffer (struct buffer *b, int no_clip) 1974 widen_buffer (struct buffer *b, int no_clip)
1994 { 1975 {
1995 if (BUF_BEGV (b) != BUF_BEG (b)) 1976 if (BUF_BEGV (b) != BUF_BEG (b))
1996 { 1977 {
1997 clip_changed = 1; 1978 clip_changed = 1;
1998 SET_BOTH_BUF_BEGV (b, BUF_BEG (b), BI_BUF_BEG (b)); 1979 SET_BOTH_BUF_BEGV (b, BUF_BEG (b), BYTE_BUF_BEG (b));
1999 } 1980 }
2000 if (BUF_ZV (b) != BUF_Z (b)) 1981 if (BUF_ZV (b) != BUF_Z (b))
2001 { 1982 {
2002 clip_changed = 1; 1983 clip_changed = 1;
2003 SET_BOTH_BUF_ZV (b, BUF_Z (b), BI_BUF_Z (b)); 1984 SET_BOTH_BUF_ZV (b, BUF_Z (b), BYTE_BUF_Z (b));
2004 } 1985 }
2005 if (clip_changed) 1986 if (clip_changed)
2006 { 1987 {
2007 if (!no_clip) 1988 if (!no_clip)
2008 MARK_CLIP_CHANGED; 1989 MARK_CLIP_CHANGED;
2036 When calling from a program, pass two arguments; positions (integers 2017 When calling from a program, pass two arguments; positions (integers
2037 or markers) bounding the text that should remain visible. 2018 or markers) bounding the text that should remain visible.
2038 */ 2019 */
2039 (start, end, buffer)) 2020 (start, end, buffer))
2040 { 2021 {
2041 Charbpos bp_start, bp_end; 2022 Charbpos char_start, char_end;
2042 struct buffer *buf = decode_buffer (buffer, 1); 2023 struct buffer *buf = decode_buffer (buffer, 1);
2043 Bytebpos bi_start, bi_end; 2024 Bytebpos byte_start, byte_end;
2044 2025
2045 get_buffer_range_char (buf, start, end, &bp_start, &bp_end, 2026 get_buffer_range_char (buf, start, end, &char_start, &char_end,
2046 GB_ALLOW_PAST_ACCESSIBLE); 2027 GB_ALLOW_PAST_ACCESSIBLE);
2047 bi_start = charbpos_to_bytebpos (buf, bp_start); 2028 byte_start = charbpos_to_bytebpos (buf, char_start);
2048 bi_end = charbpos_to_bytebpos (buf, bp_end); 2029 byte_end = charbpos_to_bytebpos (buf, char_end);
2049 2030
2050 SET_BOTH_BUF_BEGV (buf, bp_start, bi_start); 2031 SET_BOTH_BUF_BEGV (buf, char_start, byte_start);
2051 SET_BOTH_BUF_ZV (buf, bp_end, bi_end); 2032 SET_BOTH_BUF_ZV (buf, char_end, byte_end);
2052 if (BUF_PT (buf) < bp_start) 2033 if (BUF_PT (buf) < char_start)
2053 BUF_SET_PT (buf, bp_start); 2034 BUF_SET_PT (buf, char_start);
2054 if (BUF_PT (buf) > bp_end) 2035 if (BUF_PT (buf) > char_end)
2055 BUF_SET_PT (buf, bp_end); 2036 BUF_SET_PT (buf, char_end);
2056 MARK_CLIP_CHANGED; 2037 MARK_CLIP_CHANGED;
2057 /* Changing the buffer bounds invalidates any recorded current column. */ 2038 /* Changing the buffer bounds invalidates any recorded current column. */
2058 invalidate_current_column (); 2039 invalidate_current_column ();
2059 narrow_line_number_cache (buf); 2040 narrow_line_number_cache (buf);
2060 return Qnil; 2041 return Qnil;
2102 newtail = 0; 2083 newtail = 0;
2103 } 2084 }
2104 2085
2105 { 2086 {
2106 Charbpos start, end; 2087 Charbpos start, end;
2107 Bytebpos bi_start, bi_end; 2088 Bytebpos byte_start, byte_end;
2108 2089
2109 start = BUF_BEG (buf) + newhead; 2090 start = BUF_BEG (buf) + newhead;
2110 end = BUF_Z (buf) - newtail; 2091 end = BUF_Z (buf) - newtail;
2111 2092
2112 bi_start = charbpos_to_bytebpos (buf, start); 2093 byte_start = charbpos_to_bytebpos (buf, start);
2113 bi_end = charbpos_to_bytebpos (buf, end); 2094 byte_end = charbpos_to_bytebpos (buf, end);
2114 2095
2115 if (BUF_BEGV (buf) != start) 2096 if (BUF_BEGV (buf) != start)
2116 { 2097 {
2117 local_clip_changed = 1; 2098 local_clip_changed = 1;
2118 SET_BOTH_BUF_BEGV (buf, start, bi_start); 2099 SET_BOTH_BUF_BEGV (buf, start, byte_start);
2119 narrow_line_number_cache (buf); 2100 narrow_line_number_cache (buf);
2120 } 2101 }
2121 if (BUF_ZV (buf) != end) 2102 if (BUF_ZV (buf) != end)
2122 { 2103 {
2123 local_clip_changed = 1; 2104 local_clip_changed = 1;
2124 SET_BOTH_BUF_ZV (buf, end, bi_end); 2105 SET_BOTH_BUF_ZV (buf, end, byte_end);
2125 } 2106 }
2126 } 2107 }
2127 if (local_clip_changed) 2108 if (local_clip_changed)
2128 MARK_CLIP_CHANGED; 2109 MARK_CLIP_CHANGED;
2129 2110