summaryrefslogtreecommitdiff
path: root/src/buffer.c
diff options
context:
space:
mode:
authorKarl Heuer <kwzh@gnu.org>1995-07-27 22:44:41 +0000
committerKarl Heuer <kwzh@gnu.org>1995-07-27 22:44:41 +0000
commit9cb2e8cffb9993e2f510176e9852a20cb5603648 (patch)
treecdb0942448661af67c2be247f364b8f1f07e5b4e /src/buffer.c
parent130b06dbf2023cbe94b28c0d9101761fd1696e4c (diff)
downloademacs-9cb2e8cffb9993e2f510176e9852a20cb5603648.tar.gz
(record_overlay_string, overlay_strings): Handle zero-sized overlays better.
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c54
1 files changed, 37 insertions, 17 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 129fee7c095..ee7dce84a5b 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1949,7 +1949,7 @@ sort_overlays (overlay_vec, noverlays, w)
struct sortstr
{
- Lisp_Object string;
+ Lisp_Object string, string2;
int size;
int priority;
};
@@ -1987,10 +1987,9 @@ cmp_for_strings (as1, as2)
}
static void
-record_overlay_string (ssl, str, pri, size)
+record_overlay_string (ssl, str, str2, pri, size)
struct sortstrlist *ssl;
- Lisp_Object str;
- Lisp_Object pri;
+ Lisp_Object str, str2, pri;
int size;
{
if (ssl->used == ssl->size)
@@ -2003,19 +2002,26 @@ record_overlay_string (ssl, str, pri, size)
xrealloc (ssl->buf, ssl->size * sizeof (struct sortstr)));
}
ssl->buf[ssl->used].string = str;
+ ssl->buf[ssl->used].string2 = str2;
ssl->buf[ssl->used].size = size;
ssl->buf[ssl->used].priority = (INTEGERP (pri) ? XINT (pri) : 0);
ssl->used++;
ssl->bytes += XSTRING (str)->size;
+ if (STRINGP (str2))
+ ssl->bytes += XSTRING (str2)->size;
}
/* Return the concatenation of the strings associated with overlays that
begin or end at POS, ignoring overlays that are specific to a window
other than W. The strings are concatenated in the appropriate order:
shorter overlays nest inside longer ones, and higher priority inside
- lower. Returns the string length, and stores the contents indirectly
- through PSTR, if that variable is non-null. The string may be
- overwritten by subsequent calls. */
+ lower. Normally all of the after-strings come first, but zero-sized
+ overlays have their after-strings ride along with the before-strings
+ because it would look strange to print them inside-out.
+
+ Returns the string length, and stores the contents indirectly through
+ PSTR, if that variable is non-null. The string may be overwritten by
+ subsequent calls. */
int
overlay_strings (pos, w, pstr)
int pos;
@@ -2042,14 +2048,17 @@ overlay_strings (pos, w, pstr)
window = Foverlay_get (overlay, Qwindow);
if (WINDOWP (window) && XWINDOW (window) != w)
continue;
- if (endpos == pos
- && (str = Foverlay_get (overlay, Qafter_string), STRINGP (str)))
- record_overlay_string (&overlay_tails, str,
- Foverlay_get (overlay, Qpriority),
- endpos - startpos);
if (startpos == pos
&& (str = Foverlay_get (overlay, Qbefore_string), STRINGP (str)))
record_overlay_string (&overlay_heads, str,
+ (startpos == endpos
+ ? Foverlay_get (overlay, Qafter_string)
+ : Qnil),
+ Foverlay_get (overlay, Qpriority),
+ endpos - startpos);
+ else if (endpos == pos
+ && (str = Foverlay_get (overlay, Qafter_string), STRINGP (str)))
+ record_overlay_string (&overlay_tails, str, Qnil,
Foverlay_get (overlay, Qpriority),
endpos - startpos);
}
@@ -2068,14 +2077,17 @@ overlay_strings (pos, w, pstr)
window = Foverlay_get (overlay, Qwindow);
if (WINDOWP (window) && XWINDOW (window) != w)
continue;
- if (endpos == pos
- && (str = Foverlay_get (overlay, Qafter_string), STRINGP (str)))
- record_overlay_string (&overlay_tails, str,
- Foverlay_get (overlay, Qpriority),
- endpos - startpos);
if (startpos == pos
&& (str = Foverlay_get (overlay, Qbefore_string), STRINGP (str)))
record_overlay_string (&overlay_heads, str,
+ (startpos == endpos
+ ? Foverlay_get (overlay, Qafter_string)
+ : Qnil),
+ Foverlay_get (overlay, Qpriority),
+ endpos - startpos);
+ else if (endpos == pos
+ && (str = Foverlay_get (overlay, Qafter_string), STRINGP (str)))
+ record_overlay_string (&overlay_tails, str, Qnil,
Foverlay_get (overlay, Qpriority),
endpos - startpos);
}
@@ -2107,7 +2119,15 @@ overlay_strings (pos, w, pstr)
tem = overlay_heads.buf[i].string;
bcopy (XSTRING (tem)->data, p, XSTRING (tem)->size);
p += XSTRING (tem)->size;
+ tem = overlay_heads.buf[i].string2;
+ if (STRINGP (tem))
+ {
+ bcopy (XSTRING (tem)->data, p, XSTRING (tem)->size);
+ p += XSTRING (tem)->size;
+ }
}
+ if (p != overlay_str_buf + total)
+ abort ();
if (pstr)
*pstr = overlay_str_buf;
return total;