Hi, XEmacs!
On Sat, Mar 16, 2013 at 05:47:38PM +0000, Alan Mackenzie wrote:
1. Using an up to date XEmacs and Packages, create the following
Objective C file, class-30.m:
#########################################################################
@interface Foo
(Bar)
<X, Y, Z>
@end
@interface Foo (Bar)
<X, Y, Z>
@end
#########################################################################
2. Kill the buffer and reload the file freshly.
3. M-: (scan-lists 1 1 -1). This (correctly) returns 17, just after
the
"(" on L2.
4. Put point at BOL3 ("<X ,Y, Z>"). Narrow to the
first two lines with
M-<, C-x n n.
5. With point at BOL3, (point-max), do M-: (looking-at
c-opt-cpp-start).
6. M-: (scan-lists 1 1 -1). This now (buggily) returns 2.
N.B. c-opt-cpp-start is "\\s *#\\s *\\([a-zA-Z0-9]+\\)".
Speculation: the regexp code shares the use of the syntax cache with
the
syntax code, and somehow the `looking-at' call has fouled up the syntax
cache for `scan-lists'.
I've now diagnosed this problem. The fault is in update_syntax_cache
(syntax.c) in the following statement:
tmp_table = get_char_property (pos, Qsyntax_table, cache->object,
EXTENT_AT_AFTER, 0);
When `cpos' is at (point-max) and the character just after (point-max) has
an extent with a syntax-table property, get_char_property returns that
extent's property, even though that extent lies wholly in the inaccessible
portion of the buffer. In the above bug, tmp_table gets a cons (the
internal representation of the "open paren" syntax).
Later on, CONSP (tmp_table) is detected, causing it to mark the
syntax_cache as being at a syntax-table property. Sadly, the region it
marks as being thus propertised is the entire visible buffer portion.
The following clumsy "proof of concept" patch sort of fixes this bug. It
also extends `syntax-cache-info' to output components ->source and
->syntax_code.
A fully worked out patch, to make CC Mode work again, would be
appreciated.
diff -r 4521c9dc64f6 src/syntax.c
--- a/src/syntax.c Tue Mar 12 17:14:44 2013 -0400
+++ b/src/syntax.c Mon Mar 18 22:19:47 2013 +0000
@@ -194,8 +194,11 @@
{
struct buffer *buf = decode_buffer (buffer, 0);
struct syntax_cache *cache = buf->syntax_cache;
- return list4 (cache->start, cache->end, make_fixnum (cache->prev_change),
- make_fixnum (cache->next_change));
+ /* return list4 (cache->start, cache->end, make_fixnum (cache->prev_change),
*/
+ /* make_fixnum (cache->next_change)); */
+ return list6 (make_fixnum (cache->source), make_fixnum (cache->syntax_code),
+ cache->start, cache->end, make_fixnum (cache->prev_change),
+ make_fixnum (cache->next_change));
}
#endif /* DEBUG_XEMACS */
@@ -454,8 +457,12 @@
pos = buffer_or_string_charxpos_to_bytexpos (cache->object, cpos);
- tmp_table = get_char_property (pos, Qsyntax_table, cache->object,
- EXTENT_AT_AFTER, 0);
+/* ACM changes here */
+ if (BUFFERP (cache->object) && (cpos >= XFIXNUM (Fpoint_max
(cache->object))))
+ tmp_table = Qnil;
+ else
+ tmp_table = get_char_property (pos, Qsyntax_table, cache->object,
+ EXTENT_AT_AFTER, 0);
lim = next_previous_single_property_change (pos, Qsyntax_table,
cache->object, -1, 1, 0);
if (lim < 0)
--
Alan Mackenzie (Nuremberg, Germany).
_______________________________________________
XEmacs-Beta mailing list
XEmacs-Beta(a)xemacs.org
http://lists.xemacs.org/mailman/listinfo/xemacs-beta