diff options
| author | Richard M. Stallman | 1994-12-14 14:23:04 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-12-14 14:23:04 +0000 |
| commit | c98da214420c9fd262e162f0e4678b1a4e1e1698 (patch) | |
| tree | 1fb8133f484e3eaa9406b73011223ff870f44f82 /src | |
| parent | 05469d1a1e2117d70f33ed030c12070819fd63a1 (diff) | |
| download | emacs-c98da214420c9fd262e162f0e4678b1a4e1e1698.tar.gz emacs-c98da214420c9fd262e162f0e4678b1a4e1e1698.zip | |
(add_properties): Add gcpro's.
(Fadd_text_properties, copy_text_properties): Likewise.
Diffstat (limited to 'src')
| -rw-r--r-- | src/textprop.c | 48 |
1 files changed, 40 insertions, 8 deletions
diff --git a/src/textprop.c b/src/textprop.c index cc252dacef1..379cd2a7f80 100644 --- a/src/textprop.c +++ b/src/textprop.c | |||
| @@ -331,9 +331,18 @@ add_properties (plist, i, object) | |||
| 331 | INTERVAL i; | 331 | INTERVAL i; |
| 332 | Lisp_Object object; | 332 | Lisp_Object object; |
| 333 | { | 333 | { |
| 334 | register Lisp_Object tail1, tail2, sym1, val1; | 334 | Lisp_Object tail1, tail2, sym1, val1; |
| 335 | register int changed = 0; | 335 | register int changed = 0; |
| 336 | register int found; | 336 | register int found; |
| 337 | struct gcpro gcpro1, gcpro2, gcpro3; | ||
| 338 | |||
| 339 | tail1 = plist; | ||
| 340 | sym1 = Qnil; | ||
| 341 | val1 = Qnil; | ||
| 342 | /* No need to protect OBJECT, because we can GC only in the case | ||
| 343 | where it is a buffer, and live buffers are always protected. | ||
| 344 | I and its plist are also protected, via OBJECT. */ | ||
| 345 | GCPRO3 (tail1, sym1, val1); | ||
| 337 | 346 | ||
| 338 | /* Go through each element of PLIST. */ | 347 | /* Go through each element of PLIST. */ |
| 339 | for (tail1 = plist; ! NILP (tail1); tail1 = Fcdr (Fcdr (tail1))) | 348 | for (tail1 = plist; ! NILP (tail1); tail1 = Fcdr (Fcdr (tail1))) |
| @@ -346,6 +355,8 @@ add_properties (plist, i, object) | |||
| 346 | for (tail2 = i->plist; ! NILP (tail2); tail2 = Fcdr (Fcdr (tail2))) | 355 | for (tail2 = i->plist; ! NILP (tail2); tail2 = Fcdr (Fcdr (tail2))) |
| 347 | if (EQ (sym1, Fcar (tail2))) | 356 | if (EQ (sym1, Fcar (tail2))) |
| 348 | { | 357 | { |
| 358 | /* No need to gcpro, because tail2 protects this | ||
| 359 | and it must be a cons cell (we get an error otherwise). */ | ||
| 349 | register Lisp_Object this_cdr; | 360 | register Lisp_Object this_cdr; |
| 350 | 361 | ||
| 351 | this_cdr = Fcdr (tail2); | 362 | this_cdr = Fcdr (tail2); |
| @@ -389,6 +400,8 @@ add_properties (plist, i, object) | |||
| 389 | } | 400 | } |
| 390 | } | 401 | } |
| 391 | 402 | ||
| 403 | UNGCPRO; | ||
| 404 | |||
| 392 | return changed; | 405 | return changed; |
| 393 | } | 406 | } |
| 394 | 407 | ||
| @@ -783,6 +796,8 @@ back past position LIMIT; return LIMIT if nothing is found until LIMIT.") | |||
| 783 | return pos; | 796 | return pos; |
| 784 | } | 797 | } |
| 785 | 798 | ||
| 799 | /* Callers note, this can GC when OBJECT is a buffer (or nil). */ | ||
| 800 | |||
| 786 | DEFUN ("add-text-properties", Fadd_text_properties, | 801 | DEFUN ("add-text-properties", Fadd_text_properties, |
| 787 | Sadd_text_properties, 3, 4, 0, | 802 | Sadd_text_properties, 3, 4, 0, |
| 788 | "Add properties to the text from START to END.\n\ | 803 | "Add properties to the text from START to END.\n\ |
| @@ -796,6 +811,7 @@ Return t if any property value actually changed, nil otherwise.") | |||
| 796 | { | 811 | { |
| 797 | register INTERVAL i, unchanged; | 812 | register INTERVAL i, unchanged; |
| 798 | register int s, len, modified = 0; | 813 | register int s, len, modified = 0; |
| 814 | struct gcpro gcpro1; | ||
| 799 | 815 | ||
| 800 | properties = validate_plist (properties); | 816 | properties = validate_plist (properties); |
| 801 | if (NILP (properties)) | 817 | if (NILP (properties)) |
| @@ -811,6 +827,10 @@ Return t if any property value actually changed, nil otherwise.") | |||
| 811 | s = XINT (start); | 827 | s = XINT (start); |
| 812 | len = XINT (end) - s; | 828 | len = XINT (end) - s; |
| 813 | 829 | ||
| 830 | /* No need to protect OBJECT, because we GC only if it's a buffer, | ||
| 831 | and live buffers are always protected. */ | ||
| 832 | GCPRO1 (properties); | ||
| 833 | |||
| 814 | /* If we're not starting on an interval boundary, we have to | 834 | /* If we're not starting on an interval boundary, we have to |
| 815 | split this interval. */ | 835 | split this interval. */ |
| 816 | if (i->position != s) | 836 | if (i->position != s) |
| @@ -841,6 +861,11 @@ Return t if any property value actually changed, nil otherwise.") | |||
| 841 | 861 | ||
| 842 | if (LENGTH (i) >= len) | 862 | if (LENGTH (i) >= len) |
| 843 | { | 863 | { |
| 864 | /* We can UNGCPRO safely here, because there will be just | ||
| 865 | one more chance to gc, in the next call to add_properties, | ||
| 866 | and after that we will not need PROPERTIES or OBJECT again. */ | ||
| 867 | UNGCPRO; | ||
| 868 | |||
| 844 | if (interval_has_all_properties (properties, i)) | 869 | if (interval_has_all_properties (properties, i)) |
| 845 | return modified ? Qt : Qnil; | 870 | return modified ? Qt : Qnil; |
| 846 | 871 | ||
| @@ -864,6 +889,8 @@ Return t if any property value actually changed, nil otherwise.") | |||
| 864 | } | 889 | } |
| 865 | } | 890 | } |
| 866 | 891 | ||
| 892 | /* Callers note, this can GC when OBJECT is a buffer (or nil). */ | ||
| 893 | |||
| 867 | DEFUN ("put-text-property", Fput_text_property, | 894 | DEFUN ("put-text-property", Fput_text_property, |
| 868 | Sput_text_property, 4, 5, 0, | 895 | Sput_text_property, 4, 5, 0, |
| 869 | "Set one property of the text from START to END.\n\ | 896 | "Set one property of the text from START to END.\n\ |
| @@ -1254,13 +1281,13 @@ is the string or buffer containing the text.") | |||
| 1254 | returns the text properties of a region as a list of ranges and | 1281 | returns the text properties of a region as a list of ranges and |
| 1255 | plists, and another which applies such a list to another object. */ | 1282 | plists, and another which applies such a list to another object. */ |
| 1256 | 1283 | ||
| 1257 | /* DEFUN ("copy-text-properties", Fcopy_text_properties, | 1284 | /* Add properties from SRC to SRC of SRC, starting at POS in DEST. |
| 1258 | Scopy_text_properties, 5, 6, 0, | 1285 | SRC and DEST may each refer to strings or buffers. |
| 1259 | "Add properties from SRC-START to SRC-END of SRC at DEST-POS of DEST.\n\ | 1286 | Optional sixth argument PROP causes only that property to be copied. |
| 1260 | SRC and DEST may each refer to strings or buffers.\n\ | 1287 | Properties are copied to DEST as if by `add-text-properties'. |
| 1261 | Optional sixth argument PROP causes only that property to be copied.\n\ | 1288 | Return t if any property value actually changed, nil otherwise. */ |
| 1262 | Properties are copied to DEST as if by `add-text-properties'.\n\ | 1289 | |
| 1263 | Return t if any property value actually changed, nil otherwise.") */ | 1290 | /* Note this can GC when DEST is a buffer. */ |
| 1264 | 1291 | ||
| 1265 | Lisp_Object | 1292 | Lisp_Object |
| 1266 | copy_text_properties (start, end, src, pos, dest, prop) | 1293 | copy_text_properties (start, end, src, pos, dest, prop) |
| @@ -1271,6 +1298,7 @@ copy_text_properties (start, end, src, pos, dest, prop) | |||
| 1271 | Lisp_Object stuff; | 1298 | Lisp_Object stuff; |
| 1272 | Lisp_Object plist; | 1299 | Lisp_Object plist; |
| 1273 | int s, e, e2, p, len, modified = 0; | 1300 | int s, e, e2, p, len, modified = 0; |
| 1301 | struct gcpro gcpro1, gcpro2; | ||
| 1274 | 1302 | ||
| 1275 | i = validate_interval_range (src, &start, &end, soft); | 1303 | i = validate_interval_range (src, &start, &end, soft); |
| 1276 | if (NULL_INTERVAL_P (i)) | 1304 | if (NULL_INTERVAL_P (i)) |
| @@ -1329,6 +1357,8 @@ copy_text_properties (start, end, src, pos, dest, prop) | |||
| 1329 | s = i->position; | 1357 | s = i->position; |
| 1330 | } | 1358 | } |
| 1331 | 1359 | ||
| 1360 | GCPRO2 (stuff, dest); | ||
| 1361 | |||
| 1332 | while (! NILP (stuff)) | 1362 | while (! NILP (stuff)) |
| 1333 | { | 1363 | { |
| 1334 | res = Fcar (stuff); | 1364 | res = Fcar (stuff); |
| @@ -1339,6 +1369,8 @@ copy_text_properties (start, end, src, pos, dest, prop) | |||
| 1339 | stuff = Fcdr (stuff); | 1369 | stuff = Fcdr (stuff); |
| 1340 | } | 1370 | } |
| 1341 | 1371 | ||
| 1372 | UNGCPRO; | ||
| 1373 | |||
| 1342 | return modified ? Qt : Qnil; | 1374 | return modified ? Qt : Qnil; |
| 1343 | } | 1375 | } |
| 1344 | 1376 | ||