User: stephent
Date: 06/02/21 12:33:53
Modified: xemacs/src ChangeLog extents.c insdel.c lisp.h syntax.c
syntax.h
Log:
Commit syntax-cache fixes. <87oe11ne10.fsf(a)tleepslib.sk.tsukuba.ac.jp>
Revision Changes Path
1.922 +31 -0 XEmacs/xemacs/src/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/ChangeLog,v
retrieving revision 1.921
retrieving revision 1.922
diff -u -p -r1.921 -r1.922
--- ChangeLog 2006/02/17 11:19:17 1.921
+++ ChangeLog 2006/02/21 11:33:41 1.922
@@ -1,3 +1,34 @@
+2006-02-19 Stephen J. Turnbull <stephen(a)xemacs.org>
+
+ Fix crash (cf. Holger Schauer <yxz7j7xzk97.fsf(a)gimli.holgi.priv>).
+ Improve nomenclature (some identifiers were misnamed with
+ "syntax_table" although they are purely related to syntax cache).
+ Add lots of comments explaining logic and use of arguments.
+
+ * syntax.c (setup_syntax_cache): Fix broken logic that
+ initialized prev_change and next_change members to Qnil for syntax
+ caches associated with buffers, triggering an assertion because
+ the update functions expect those members to markers.
+
+ * syntax.c (signal_syntax_cache_extent_changed):
+ * syntax.c (reset_buffer_syntax_cache_range):
+ Rename reset_buffer_cache_range to reset_buffer_syntax_cache_range.
+
+ * lisp.h (signal_syntax_cache_extent_changed):
+ * syntax.c (signal_syntax_cache_extent_changed)
+ * syntax.c (update_syntax_cache):
+ * extents.c (signal_single_extent_changed):
+ Rename signal_syntax_table_extent_changed to
+ signal_syntax_cache_extent_changed.
+
+ * lisp.h (signal_syntax_cache_extent_adjust):
+ * syntax.c (signal_syntax_cache_extent_adjust):
+ * insdel.c (buffer_delete_range, buffer_insert_string_1):
+ Rename signal_syntax_table_extent_adjust to
+ signal_syntax_cache_extent_adjust.
+
+ * syntax.h (update_syntax_cache): Fix typo in comment.
+
2006-02-16 Marcus Crestani <crestani(a)xemacs.org>
* xgccache.c (gc_cache_lookup): Remove "Cache full" warning.
1.64 +1 -1 XEmacs/xemacs/src/extents.c
Index: extents.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/extents.c,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -p -r1.63 -r1.64
--- extents.c 2005/11/25 01:42:01 1.63
+++ extents.c 2006/02/21 11:33:45 1.64
@@ -1922,7 +1922,7 @@ signal_single_extent_changed (EXTENT ext
if (NILP (property) ? !NILP (Fextent_property (wrap_extent (extent),
Qsyntax_table, Qnil)) :
EQ (property, Qsyntax_table))
- signal_syntax_table_extent_changed (extent);
+ signal_syntax_cache_extent_changed (extent);
}
/* Make note that a change has happened in EXTENT. The change was either
1.35 +2 -2 XEmacs/xemacs/src/insdel.c
Index: insdel.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/insdel.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -p -r1.34 -r1.35
--- insdel.c 2005/01/24 23:33:59 1.34
+++ insdel.c 2006/02/21 11:33:45 1.35
@@ -1265,7 +1265,7 @@ buffer_insert_string_1 (struct buffer *b
MAP_INDIRECT_BUFFERS (buf, mbuf, bufcons)
{
- signal_syntax_table_extent_adjust (mbuf);
+ signal_syntax_cache_extent_adjust (mbuf);
}
signal_after_change (buf, pos, pos, pos + cclen);
@@ -1546,7 +1546,7 @@ buffer_delete_range (struct buffer *buf,
MAP_INDIRECT_BUFFERS (buf, mbuf, bufcons)
{
- signal_syntax_table_extent_adjust (mbuf);
+ signal_syntax_cache_extent_adjust (mbuf);
}
/* &&#### Here we consider converting the buffer from default to
1.137 +2 -2 XEmacs/xemacs/src/lisp.h
Index: lisp.h
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/lisp.h,v
retrieving revision 1.136
retrieving revision 1.137
diff -u -p -r1.136 -r1.137
--- lisp.h 2005/11/26 11:46:09 1.136
+++ lisp.h 2006/02/21 11:33:46 1.137
@@ -5279,8 +5279,8 @@ Charbpos scan_words (struct buffer *, Ch
EXFUN (Fchar_syntax, 2);
EXFUN (Fforward_word, 2);
extern Lisp_Object Vstandard_syntax_table;
-void signal_syntax_table_extent_changed (EXTENT extent);
-void signal_syntax_table_extent_adjust (struct buffer *buf);
+void signal_syntax_cache_extent_changed (EXTENT extent);
+void signal_syntax_cache_extent_adjust (struct buffer *buf);
void init_buffer_syntax_cache (struct buffer *buf);
void mark_buffer_syntax_cache (struct buffer *buf);
void uninit_buffer_syntax_cache (struct buffer *buf);
1.27 +55 -17 XEmacs/xemacs/src/syntax.c
Index: syntax.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/syntax.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -p -r1.26 -r1.27
--- syntax.c 2005/12/18 22:55:52 1.26
+++ syntax.c 2006/02/21 11:33:46 1.27
@@ -254,6 +254,11 @@ init_syntax_cache (struct syntax_cache *
BUFFER_MIRROR_SYNTAX_TABLE (cache->buffer);
cache->start = Qnil;
cache->end = Qnil;
+ /* #### I'm not sure what INFINITE is for, but it's apparently needed by
+ setup_syntax_cache(). It looks like it's supposed to guarantee that
+ the test for POS outside of cache-valid range will never succeed, so
+ that update_syntax_cache won't get called, but it's hard to be sure.
+ Cf reset_buffer_syntax_cache_range. -- sjt */
if (infinite)
{
cache->prev_change = EMACS_INT_MIN;
@@ -266,15 +271,29 @@ init_syntax_cache (struct syntax_cache *
}
}
-struct syntax_cache *
-setup_syntax_cache (struct syntax_cache *cache, Lisp_Object object,
- struct buffer *buffer, Charxpos from, int count)
+/* #### This function and associated logic still needs work, and especially
+ documentation. */
+struct syntax_cache * /* return CACHE or the cache of OBJECT */
+setup_syntax_cache (struct syntax_cache *cache, /* syntax cache, may be NULL
+ if OBJECT is a buffer */
+ Lisp_Object object, /* the object (if any) cache
+ is associated with */
+ struct buffer *buffer, /* the buffer to use as source
+ of the syntax table */
+ Charxpos from, /* initial position of cache */
+ int count) /* direction? see code */
{
+ /* If OBJECT is a buffer, use its cache. Initialize cache. Make it valid
+ for the whole buffer if the syntax-table property is not being respected.
+ Else if OBJECT is not a buffer, initialize the cache passed in CACHE.
+ If the syntax-table property is being respected, update the cache. */
if (BUFFERP (object))
- cache = XBUFFER (object)->syntax_cache;
- if (!lookup_syntax_properties)
- init_syntax_cache (cache, object, buffer, 1);
- else if (!BUFFERP (object))
+ {
+ cache = XBUFFER (object)->syntax_cache;
+ if (!lookup_syntax_properties)
+ reset_buffer_syntax_cache_range (cache, object, 1);
+ }
+ else
init_syntax_cache (cache, object, buffer, 0);
if (lookup_syntax_properties)
{
@@ -339,14 +358,25 @@ mark_buffer_syntax_cache (struct buffer
}
static void
-reset_buffer_cache_range (struct syntax_cache *cache, Lisp_Object buffer)
+reset_buffer_syntax_cache_range (struct syntax_cache *cache,
+ Lisp_Object buffer, int infinite)
{
Fset_marker (cache->start, make_int (1), buffer);
Fset_marker (cache->end, make_int (1), buffer);
Fset_marker_insertion_type (cache->start, Qt);
Fset_marker_insertion_type (cache->end, Qnil);
- cache->prev_change = -1;
- cache->next_change = -1;
+ /* #### Should we "cache->no_syntax_table_prop = 1;" here? */
+ /* #### Cf comment on INFINITE in init_syntax_cache. -- sjt */
+ if (infinite)
+ {
+ cache->prev_change = EMACS_INT_MIN;
+ cache->next_change = EMACS_INT_MAX;
+ }
+ else
+ {
+ cache->prev_change = -1;
+ cache->next_change = -1;
+ }
}
void
@@ -367,9 +397,10 @@ init_buffer_syntax_cache (struct buffer
cache->mirror_table = BUFFER_MIRROR_SYNTAX_TABLE (cache->buffer);
cache->start = Fmake_marker ();
cache->end = Fmake_marker ();
- reset_buffer_cache_range (cache, cache->object);
+ reset_buffer_syntax_cache_range (cache, cache->object, 0);
}
+/* finalize the syntax cache for BUF */
void
uninit_buffer_syntax_cache (struct buffer *buf)
{
@@ -401,27 +432,34 @@ syntax_cache_table_was_changed (struct b
the value of EXTENT's syntax-table property is changing. */
void
-signal_syntax_table_extent_changed (EXTENT extent)
+signal_syntax_cache_extent_changed (EXTENT extent)
{
Lisp_Object buffer = Fextent_object (wrap_extent (extent));
if (BUFFERP (buffer))
{
+ /* This was getting called with the buffer's start and end null, eg in
+ cperl mode, which triggers an assert in byte_marker_position. Cf
+ thread rooted at <yxz7j7xzk97.fsf(a)gimli.holgi.priv> on xemacs-beta.
+ <yxzfymklb6p.fsf(a)gimli.holgi.priv> has a recipe, but you also need
+ to delete or type SPC to get the crash.
+ #### Delete this comment when setup_syntax_cache is made sane. */
struct syntax_cache *cache = XBUFFER (buffer)->syntax_cache;
+ /* #### would this be slower or less accurate in character terms? */
Bytexpos start = extent_endpoint_byte (extent, 0);
Bytexpos end = extent_endpoint_byte (extent, 1);
Bytexpos start2 = byte_marker_position (cache->start);
Bytexpos end2 = byte_marker_position (cache->end);
- /* If the extent is entirely before or entirely after the cache range,
- it doesn't overlap. Otherwise, invalidate the range. */
+ /* If the extent is entirely before or entirely after the cache
+ range, it doesn't overlap. Otherwise, invalidate the range. */
if (!(end < start2 || start > end2))
- reset_buffer_cache_range (cache, buffer);
+ reset_buffer_syntax_cache_range (cache, buffer, 0);
}
}
/* Extents have been adjusted for insertion or deletion, so we need to
refetch the start and end position of the extent */
void
-signal_syntax_table_extent_adjust (struct buffer *buf)
+signal_syntax_cache_extent_adjust (struct buffer *buf)
{
struct syntax_cache *cache = buf->syntax_cache;
/* If the cache was invalid before, leave it that way. We only want
@@ -499,7 +537,7 @@ update_syntax_cache (struct syntax_cache
a zero-length `syntax-table' extent there (highly unlikely); if not,
then we can safely make the end closed, so it will take in newly
inserted text. (If such an extent is inserted, we will be informed
- through signal_syntax_table_extent_changed().) */
+ through signal_syntax_cache_extent_changed().) */
Fset_marker (cache->start, make_int (cache->prev_change), cache->object);
Fset_marker_insertion_type
(cache->start,
1.14 +1 -1 XEmacs/xemacs/src/syntax.h
Index: syntax.h
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/syntax.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -p -r1.13 -r1.14
--- syntax.h 2005/11/25 01:42:07 1.13
+++ syntax.h 2006/02/21 11:33:46 1.14
@@ -354,7 +354,7 @@ DECLARE_LRECORD (syntax_cache, Lisp_Synt
extern const struct sized_memory_description syntax_cache_description;
/* Note that the external interface to the syntax-cache uses charpos's, but
- intnernally we use bytepos's, for speed. */
+ internally we use bytepos's, for speed. */
void update_syntax_cache (struct syntax_cache *cache, Charxpos pos, int count);
struct syntax_cache *setup_syntax_cache (struct syntax_cache *cache,