aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.c
diff options
context:
space:
mode:
authorRichard M. Stallman1993-05-16 22:31:48 +0000
committerRichard M. Stallman1993-05-16 22:31:48 +0000
commit61d54cd5408b730c86753aaf5c43a92b91f92b6f (patch)
tree50ad13537eb56a210c874ef93a053b1d8a66eb53 /src/buffer.c
parent9516fe943a05f036b42305626e68ae9ce3dd6d1c (diff)
downloademacs-61d54cd5408b730c86753aaf5c43a92b91f92b6f.tar.gz
emacs-61d54cd5408b730c86753aaf5c43a92b91f92b6f.zip
(overlays_at): New arg EXTEND.
(Foverlays_at, Fnext_overlay_change): Pass 1.
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c51
1 files changed, 39 insertions, 12 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 2104226b338..db9dfbcfed5 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1202,11 +1202,17 @@ a non-nil `permanent-local' property are not eliminated by this function.")
1202 or ZV if there are no more overlays. 1202 or ZV if there are no more overlays.
1203 1203
1204 *VEC_PTR and *LEN_PTR should contain a valid vector and size 1204 *VEC_PTR and *LEN_PTR should contain a valid vector and size
1205 when this function is called. */ 1205 when this function is called.
1206
1207 If EXTEND is non-zero, we make the vector bigger if necessary.
1208 If EXTEND is zero, we never extend the vector,
1209 and we store only as many overlays as will fit.
1210 But we still return the total number of overlays. */
1206 1211
1207int 1212int
1208overlays_at (pos, vec_ptr, len_ptr, next_ptr) 1213overlays_at (pos, extend, vec_ptr, len_ptr, next_ptr)
1209 int pos; 1214 int pos;
1215 int extend;
1210 Lisp_Object **vec_ptr; 1216 Lisp_Object **vec_ptr;
1211 int *len_ptr; 1217 int *len_ptr;
1212 int *next_ptr; 1218 int *next_ptr;
@@ -1216,6 +1222,8 @@ overlays_at (pos, vec_ptr, len_ptr, next_ptr)
1216 int len = *len_ptr; 1222 int len = *len_ptr;
1217 Lisp_Object *vec = *vec_ptr; 1223 Lisp_Object *vec = *vec_ptr;
1218 int next = ZV; 1224 int next = ZV;
1225 int inhibit_storing = 0;
1226
1219 for (tail = current_buffer->overlays_before; 1227 for (tail = current_buffer->overlays_before;
1220 CONSP (tail); 1228 CONSP (tail);
1221 tail = XCONS (tail)->cdr) 1229 tail = XCONS (tail)->cdr)
@@ -1235,11 +1243,22 @@ overlays_at (pos, vec_ptr, len_ptr, next_ptr)
1235 { 1243 {
1236 if (idx == len) 1244 if (idx == len)
1237 { 1245 {
1238 *len_ptr = len *= 2; 1246 /* The supplied vector is full.
1239 vec = (Lisp_Object *) xrealloc (vec, len * sizeof (Lisp_Object)); 1247 Either make it bigger, or don't store any more in it. */
1240 *vec_ptr = vec; 1248 if (extend)
1249 {
1250 *len_ptr = len *= 2;
1251 vec = (Lisp_Object *) xrealloc (vec, len * sizeof (Lisp_Object));
1252 *vec_ptr = vec;
1253 }
1254 else
1255 inhibit_storing = 1;
1241 } 1256 }
1242 vec[idx++] = overlay; 1257
1258 if (!inhibit_storing)
1259 vec[idx] = overlay;
1260 /* Keep counting overlays even if we can't return them all. */
1261 idx++;
1243 } 1262 }
1244 else if (startpos < next) 1263 else if (startpos < next)
1245 next = startpos; 1264 next = startpos;
@@ -1268,11 +1287,19 @@ overlays_at (pos, vec_ptr, len_ptr, next_ptr)
1268 { 1287 {
1269 if (idx == len) 1288 if (idx == len)
1270 { 1289 {
1271 *len_ptr = len *= 2; 1290 if (extend)
1272 vec = (Lisp_Object *) xrealloc (vec, len * sizeof (Lisp_Object)); 1291 {
1273 *vec_ptr = vec; 1292 *len_ptr = len *= 2;
1293 vec = (Lisp_Object *) xrealloc (vec, len * sizeof (Lisp_Object));
1294 *vec_ptr = vec;
1295 }
1296 else
1297 inhibit_storing = 1;
1274 } 1298 }
1275 vec[idx++] = overlay; 1299
1300 if (!inhibit_storing)
1301 vec[idx] = overlay;
1302 idx++;
1276 } 1303 }
1277 } 1304 }
1278 1305
@@ -1658,7 +1685,7 @@ DEFUN ("overlays-at", Foverlays_at, Soverlays_at, 1, 1, 0,
1658 1685
1659 /* Put all the overlays we want in a vector in overlay_vec. 1686 /* Put all the overlays we want in a vector in overlay_vec.
1660 Store the length in len. */ 1687 Store the length in len. */
1661 noverlays = overlays_at (XINT (pos), &overlay_vec, &len, &endpos); 1688 noverlays = overlays_at (XINT (pos), 1, &overlay_vec, &len, &endpos);
1662 1689
1663 /* Make a list of them all. */ 1690 /* Make a list of them all. */
1664 result = Flist (noverlays, overlay_vec); 1691 result = Flist (noverlays, overlay_vec);
@@ -1688,7 +1715,7 @@ DEFUN ("next-overlay-change", Fnext_overlay_change, Snext_overlay_change,
1688 /* Put all the overlays we want in a vector in overlay_vec. 1715 /* Put all the overlays we want in a vector in overlay_vec.
1689 Store the length in len. 1716 Store the length in len.
1690 endpos gets the position where the next overlay starts. */ 1717 endpos gets the position where the next overlay starts. */
1691 noverlays = overlays_at (XINT (pos), &overlay_vec, &len, &endpos); 1718 noverlays = overlays_at (XINT (pos), 1, &overlay_vec, &len, &endpos);
1692 1719
1693 /* If any of these overlays ends before endpos, 1720 /* If any of these overlays ends before endpos,
1694 use its ending point instead. */ 1721 use its ending point instead. */