diff options
| author | Dmitry Antipov | 2012-08-08 14:23:04 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2012-08-08 14:23:04 +0400 |
| commit | ad8c997f72c95b7351eab4c8ea2ac8c667545e6f (patch) | |
| tree | 95f6da158be105a5a83a31c087764ce1d7eb7944 /src | |
| parent | ce0fcefa27728a4e83e10962075c388c8a6da87a (diff) | |
| download | emacs-ad8c997f72c95b7351eab4c8ea2ac8c667545e6f.tar.gz emacs-ad8c997f72c95b7351eab4c8ea2ac8c667545e6f.zip | |
Inline functions to examine and change string intervals.
* lisp.h (STRING_INTERVALS, STRING_SET_INTERVALS): Remove.
(string_get_intervals, string_set_intervals): New function.
* alloc.c, buffer.c, editfns.c, fns.c, insdel.c, intervals.c:
* lread.c, print.c, textprop.c: Adjust users.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 8 | ||||
| -rw-r--r-- | src/alloc.c | 2 | ||||
| -rw-r--r-- | src/buffer.c | 4 | ||||
| -rw-r--r-- | src/editfns.c | 4 | ||||
| -rw-r--r-- | src/fns.c | 6 | ||||
| -rw-r--r-- | src/insdel.c | 4 | ||||
| -rw-r--r-- | src/intervals.c | 14 | ||||
| -rw-r--r-- | src/lisp.h | 22 | ||||
| -rw-r--r-- | src/lread.c | 2 | ||||
| -rw-r--r-- | src/print.c | 10 | ||||
| -rw-r--r-- | src/textprop.c | 8 |
11 files changed, 51 insertions, 33 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index e68c6edc8d5..20bb917f1a1 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2012-08-08 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 2 | |||
| 3 | Inline functions to examine and change string intervals. | ||
| 4 | * lisp.h (STRING_INTERVALS, STRING_SET_INTERVALS): Remove. | ||
| 5 | (string_get_intervals, string_set_intervals): New function. | ||
| 6 | * alloc.c, buffer.c, editfns.c, fns.c, insdel.c, intervals.c: | ||
| 7 | * lread.c, print.c, textprop.c: Adjust users. | ||
| 8 | |||
| 1 | 2012-08-08 Glenn Morris <rgm@gnu.org> | 9 | 2012-08-08 Glenn Morris <rgm@gnu.org> |
| 2 | 10 | ||
| 3 | * lisp.mk (lisp): Remove language/persian.elc. | 11 | * lisp.mk (lisp): Remove language/persian.elc. |
diff --git a/src/alloc.c b/src/alloc.c index d342a722ca6..95309f076d4 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -6102,7 +6102,7 @@ mark_object (Lisp_Object arg) | |||
| 6102 | } | 6102 | } |
| 6103 | if (!PURE_POINTER_P (XSTRING (ptr->name))) | 6103 | if (!PURE_POINTER_P (XSTRING (ptr->name))) |
| 6104 | MARK_STRING (XSTRING (ptr->name)); | 6104 | MARK_STRING (XSTRING (ptr->name)); |
| 6105 | MARK_INTERVAL_TREE (STRING_INTERVALS (ptr->name)); | 6105 | MARK_INTERVAL_TREE (string_get_intervals (ptr->name)); |
| 6106 | 6106 | ||
| 6107 | ptr = ptr->next; | 6107 | ptr = ptr->next; |
| 6108 | if (ptr) | 6108 | if (ptr) |
diff --git a/src/buffer.c b/src/buffer.c index ad28b69b972..395ca48680f 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -384,7 +384,7 @@ even if it is dead. The return value is never nil. */) | |||
| 384 | BVAR (b, zv_marker) = Qnil; | 384 | BVAR (b, zv_marker) = Qnil; |
| 385 | 385 | ||
| 386 | name = Fcopy_sequence (buffer_or_name); | 386 | name = Fcopy_sequence (buffer_or_name); |
| 387 | STRING_SET_INTERVALS (name, NULL); | 387 | string_set_intervals (name, NULL); |
| 388 | BVAR (b, name) = name; | 388 | BVAR (b, name) = name; |
| 389 | 389 | ||
| 390 | BVAR (b, undo_list) = (SREF (name, 0) != ' ') ? Qnil : Qt; | 390 | BVAR (b, undo_list) = (SREF (name, 0) != ' ') ? Qnil : Qt; |
| @@ -589,7 +589,7 @@ CLONE nil means the indirect buffer's state is reset to default values. */) | |||
| 589 | all_buffers = b; | 589 | all_buffers = b; |
| 590 | 590 | ||
| 591 | name = Fcopy_sequence (name); | 591 | name = Fcopy_sequence (name); |
| 592 | STRING_SET_INTERVALS (name, NULL); | 592 | string_set_intervals (name, NULL); |
| 593 | BVAR (b, name) = name; | 593 | BVAR (b, name) = name; |
| 594 | 594 | ||
| 595 | reset_buffer (b); | 595 | reset_buffer (b); |
diff --git a/src/editfns.c b/src/editfns.c index 9d74563ca9d..3bcc1a57a7e 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -3933,7 +3933,7 @@ usage: (format STRING &rest OBJECTS) */) | |||
| 3933 | 3933 | ||
| 3934 | /* If this argument has text properties, record where | 3934 | /* If this argument has text properties, record where |
| 3935 | in the result string it appears. */ | 3935 | in the result string it appears. */ |
| 3936 | if (STRING_INTERVALS (args[n])) | 3936 | if (string_get_intervals (args[n])) |
| 3937 | info[n].intervals = arg_intervals = 1; | 3937 | info[n].intervals = arg_intervals = 1; |
| 3938 | 3938 | ||
| 3939 | continue; | 3939 | continue; |
| @@ -4277,7 +4277,7 @@ usage: (format STRING &rest OBJECTS) */) | |||
| 4277 | arguments has text properties, set up text properties of the | 4277 | arguments has text properties, set up text properties of the |
| 4278 | result string. */ | 4278 | result string. */ |
| 4279 | 4279 | ||
| 4280 | if (STRING_INTERVALS (args[0]) || arg_intervals) | 4280 | if (string_get_intervals (args[0]) || arg_intervals) |
| 4281 | { | 4281 | { |
| 4282 | Lisp_Object len, new_len, props; | 4282 | Lisp_Object len, new_len, props; |
| 4283 | struct gcpro gcpro1; | 4283 | struct gcpro gcpro1; |
| @@ -628,7 +628,7 @@ concat (ptrdiff_t nargs, Lisp_Object *args, | |||
| 628 | ptrdiff_t thislen_byte = SBYTES (this); | 628 | ptrdiff_t thislen_byte = SBYTES (this); |
| 629 | 629 | ||
| 630 | memcpy (SDATA (val) + toindex_byte, SDATA (this), SBYTES (this)); | 630 | memcpy (SDATA (val) + toindex_byte, SDATA (this), SBYTES (this)); |
| 631 | if (STRING_INTERVALS (this)) | 631 | if (string_get_intervals (this)) |
| 632 | { | 632 | { |
| 633 | textprops[num_textprops].argnum = argnum; | 633 | textprops[num_textprops].argnum = argnum; |
| 634 | textprops[num_textprops].from = 0; | 634 | textprops[num_textprops].from = 0; |
| @@ -640,7 +640,7 @@ concat (ptrdiff_t nargs, Lisp_Object *args, | |||
| 640 | /* Copy a single-byte string to a multibyte string. */ | 640 | /* Copy a single-byte string to a multibyte string. */ |
| 641 | else if (STRINGP (this) && STRINGP (val)) | 641 | else if (STRINGP (this) && STRINGP (val)) |
| 642 | { | 642 | { |
| 643 | if (STRING_INTERVALS (this)) | 643 | if (string_get_intervals (this)) |
| 644 | { | 644 | { |
| 645 | textprops[num_textprops].argnum = argnum; | 645 | textprops[num_textprops].argnum = argnum; |
| 646 | textprops[num_textprops].from = 0; | 646 | textprops[num_textprops].from = 0; |
| @@ -1060,7 +1060,7 @@ If you're not sure, whether to use `string-as-multibyte' or | |||
| 1060 | str_as_multibyte (SDATA (new_string), nbytes, | 1060 | str_as_multibyte (SDATA (new_string), nbytes, |
| 1061 | SBYTES (string), NULL); | 1061 | SBYTES (string), NULL); |
| 1062 | string = new_string; | 1062 | string = new_string; |
| 1063 | STRING_SET_INTERVALS (string, NULL); | 1063 | string_set_intervals (string, NULL); |
| 1064 | } | 1064 | } |
| 1065 | return string; | 1065 | return string; |
| 1066 | } | 1066 | } |
diff --git a/src/insdel.c b/src/insdel.c index 6cd46ac634b..1a66cfc6080 100644 --- a/src/insdel.c +++ b/src/insdel.c | |||
| @@ -976,7 +976,7 @@ insert_from_string_1 (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte, | |||
| 976 | 976 | ||
| 977 | offset_intervals (current_buffer, PT, nchars); | 977 | offset_intervals (current_buffer, PT, nchars); |
| 978 | 978 | ||
| 979 | intervals = STRING_INTERVALS (string); | 979 | intervals = string_get_intervals (string); |
| 980 | /* Get the intervals for the part of the string we are inserting. */ | 980 | /* Get the intervals for the part of the string we are inserting. */ |
| 981 | if (nbytes < SBYTES (string)) | 981 | if (nbytes < SBYTES (string)) |
| 982 | intervals = copy_intervals (intervals, pos, nchars); | 982 | intervals = copy_intervals (intervals, pos, nchars); |
| @@ -1413,7 +1413,7 @@ replace_range (ptrdiff_t from, ptrdiff_t to, Lisp_Object new, | |||
| 1413 | 1413 | ||
| 1414 | /* Get the intervals for the part of the string we are inserting-- | 1414 | /* Get the intervals for the part of the string we are inserting-- |
| 1415 | not including the combined-before bytes. */ | 1415 | not including the combined-before bytes. */ |
| 1416 | intervals = STRING_INTERVALS (new); | 1416 | intervals = string_get_intervals (new); |
| 1417 | /* Insert those intervals. */ | 1417 | /* Insert those intervals. */ |
| 1418 | graft_intervals_into_buffer (intervals, from, inschars, | 1418 | graft_intervals_into_buffer (intervals, from, inschars, |
| 1419 | current_buffer, inherit); | 1419 | current_buffer, inherit); |
diff --git a/src/intervals.c b/src/intervals.c index 504557dadb7..64e54eb7b43 100644 --- a/src/intervals.c +++ b/src/intervals.c | |||
| @@ -84,7 +84,7 @@ create_root_interval (Lisp_Object parent) | |||
| 84 | { | 84 | { |
| 85 | new->total_length = SCHARS (parent); | 85 | new->total_length = SCHARS (parent); |
| 86 | eassert (0 <= TOTAL_LENGTH (new)); | 86 | eassert (0 <= TOTAL_LENGTH (new)); |
| 87 | STRING_SET_INTERVALS (parent, new); | 87 | string_set_intervals (parent, new); |
| 88 | new->position = 0; | 88 | new->position = 0; |
| 89 | } | 89 | } |
| 90 | 90 | ||
| @@ -455,7 +455,7 @@ balance_possible_root_interval (register INTERVAL interval) | |||
| 455 | if (BUFFERP (parent)) | 455 | if (BUFFERP (parent)) |
| 456 | BUF_INTERVALS (XBUFFER (parent)) = interval; | 456 | BUF_INTERVALS (XBUFFER (parent)) = interval; |
| 457 | else if (STRINGP (parent)) | 457 | else if (STRINGP (parent)) |
| 458 | STRING_SET_INTERVALS (parent, interval); | 458 | string_set_intervals (parent, interval); |
| 459 | } | 459 | } |
| 460 | 460 | ||
| 461 | return interval; | 461 | return interval; |
| @@ -1206,7 +1206,7 @@ delete_interval (register INTERVAL i) | |||
| 1206 | if (BUFFERP (owner)) | 1206 | if (BUFFERP (owner)) |
| 1207 | BUF_INTERVALS (XBUFFER (owner)) = parent; | 1207 | BUF_INTERVALS (XBUFFER (owner)) = parent; |
| 1208 | else if (STRINGP (owner)) | 1208 | else if (STRINGP (owner)) |
| 1209 | STRING_SET_INTERVALS (owner, parent); | 1209 | string_set_intervals (owner, parent); |
| 1210 | else | 1210 | else |
| 1211 | abort (); | 1211 | abort (); |
| 1212 | 1212 | ||
| @@ -2126,7 +2126,7 @@ get_property_and_range (ptrdiff_t pos, Lisp_Object prop, Lisp_Object *val, | |||
| 2126 | else if (BUFFERP (object)) | 2126 | else if (BUFFERP (object)) |
| 2127 | i = find_interval (BUF_INTERVALS (XBUFFER (object)), pos); | 2127 | i = find_interval (BUF_INTERVALS (XBUFFER (object)), pos); |
| 2128 | else if (STRINGP (object)) | 2128 | else if (STRINGP (object)) |
| 2129 | i = find_interval (STRING_INTERVALS (object), pos); | 2129 | i = find_interval (string_get_intervals (object), pos); |
| 2130 | else | 2130 | else |
| 2131 | abort (); | 2131 | abort (); |
| 2132 | 2132 | ||
| @@ -2259,7 +2259,7 @@ copy_intervals_to_string (Lisp_Object string, struct buffer *buffer, | |||
| 2259 | return; | 2259 | return; |
| 2260 | 2260 | ||
| 2261 | interval_set_object (interval_copy, string); | 2261 | interval_set_object (interval_copy, string); |
| 2262 | STRING_SET_INTERVALS (string, interval_copy); | 2262 | string_set_intervals (string, interval_copy); |
| 2263 | } | 2263 | } |
| 2264 | 2264 | ||
| 2265 | /* Return 1 if strings S1 and S2 have identical properties; 0 otherwise. | 2265 | /* Return 1 if strings S1 and S2 have identical properties; 0 otherwise. |
| @@ -2272,8 +2272,8 @@ compare_string_intervals (Lisp_Object s1, Lisp_Object s2) | |||
| 2272 | ptrdiff_t pos = 0; | 2272 | ptrdiff_t pos = 0; |
| 2273 | ptrdiff_t end = SCHARS (s1); | 2273 | ptrdiff_t end = SCHARS (s1); |
| 2274 | 2274 | ||
| 2275 | i1 = find_interval (STRING_INTERVALS (s1), 0); | 2275 | i1 = find_interval (string_get_intervals (s1), 0); |
| 2276 | i2 = find_interval (STRING_INTERVALS (s2), 0); | 2276 | i2 = find_interval (string_get_intervals (s2), 0); |
| 2277 | 2277 | ||
| 2278 | while (pos < end) | 2278 | while (pos < end) |
| 2279 | { | 2279 | { |
diff --git a/src/lisp.h b/src/lisp.h index 873264af4ab..ea6f9dac249 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -752,12 +752,6 @@ static ptrdiff_t const STRING_BYTES_BOUND = | |||
| 752 | (STR) = empty_multibyte_string; \ | 752 | (STR) = empty_multibyte_string; \ |
| 753 | else XSTRING (STR)->size_byte = XSTRING (STR)->size; } while (0) | 753 | else XSTRING (STR)->size_byte = XSTRING (STR)->size; } while (0) |
| 754 | 754 | ||
| 755 | /* Get text properties. */ | ||
| 756 | #define STRING_INTERVALS(STR) (XSTRING (STR)->intervals + 0) | ||
| 757 | |||
| 758 | /* Set text properties. */ | ||
| 759 | #define STRING_SET_INTERVALS(STR, INT) (XSTRING (STR)->intervals = (INT)) | ||
| 760 | |||
| 761 | /* In a string or vector, the sign bit of the `size' is the gc mark bit. */ | 755 | /* In a string or vector, the sign bit of the `size' is the gc mark bit. */ |
| 762 | 756 | ||
| 763 | struct Lisp_String | 757 | struct Lisp_String |
| @@ -2420,6 +2414,22 @@ set_overlay_plist (Lisp_Object overlay, Lisp_Object plist) | |||
| 2420 | XOVERLAY (overlay)->plist = plist; | 2414 | XOVERLAY (overlay)->plist = plist; |
| 2421 | } | 2415 | } |
| 2422 | 2416 | ||
| 2417 | /* Get text properties of S. */ | ||
| 2418 | |||
| 2419 | LISP_INLINE INTERVAL | ||
| 2420 | string_get_intervals (Lisp_Object s) | ||
| 2421 | { | ||
| 2422 | return XSTRING (s)->intervals; | ||
| 2423 | } | ||
| 2424 | |||
| 2425 | /* Set text properties of S to I. */ | ||
| 2426 | |||
| 2427 | LISP_INLINE void | ||
| 2428 | string_set_intervals (Lisp_Object s, INTERVAL i) | ||
| 2429 | { | ||
| 2430 | XSTRING (s)->intervals = i; | ||
| 2431 | } | ||
| 2432 | |||
| 2423 | /* Defined in data.c. */ | 2433 | /* Defined in data.c. */ |
| 2424 | extern Lisp_Object Qnil, Qt, Qquote, Qlambda, Qunbound; | 2434 | extern Lisp_Object Qnil, Qt, Qquote, Qlambda, Qunbound; |
| 2425 | extern Lisp_Object Qerror_conditions, Qerror_message, Qtop_level; | 2435 | extern Lisp_Object Qerror_conditions, Qerror_message, Qtop_level; |
diff --git a/src/lread.c b/src/lread.c index 5d26b7f6b2f..90e204f426e 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -3189,7 +3189,7 @@ substitute_object_recurse (Lisp_Object object, Lisp_Object placeholder, Lisp_Obj | |||
| 3189 | /* Check for text properties in each interval. | 3189 | /* Check for text properties in each interval. |
| 3190 | substitute_in_interval contains part of the logic. */ | 3190 | substitute_in_interval contains part of the logic. */ |
| 3191 | 3191 | ||
| 3192 | INTERVAL root_interval = STRING_INTERVALS (subtree); | 3192 | INTERVAL root_interval = string_get_intervals (subtree); |
| 3193 | Lisp_Object arg = Fcons (object, placeholder); | 3193 | Lisp_Object arg = Fcons (object, placeholder); |
| 3194 | 3194 | ||
| 3195 | traverse_intervals_noorder (root_interval, | 3195 | traverse_intervals_noorder (root_interval, |
diff --git a/src/print.c b/src/print.c index 1e9f237ee82..8c6d1eabc18 100644 --- a/src/print.c +++ b/src/print.c | |||
| @@ -1194,7 +1194,7 @@ print_preprocess (Lisp_Object obj) | |||
| 1194 | { | 1194 | { |
| 1195 | case Lisp_String: | 1195 | case Lisp_String: |
| 1196 | /* A string may have text properties, which can be circular. */ | 1196 | /* A string may have text properties, which can be circular. */ |
| 1197 | traverse_intervals_noorder (STRING_INTERVALS (obj), | 1197 | traverse_intervals_noorder (string_get_intervals (obj), |
| 1198 | print_preprocess_string, Qnil); | 1198 | print_preprocess_string, Qnil); |
| 1199 | break; | 1199 | break; |
| 1200 | 1200 | ||
| @@ -1297,7 +1297,7 @@ static Lisp_Object | |||
| 1297 | print_prune_string_charset (Lisp_Object string) | 1297 | print_prune_string_charset (Lisp_Object string) |
| 1298 | { | 1298 | { |
| 1299 | print_check_string_result = 0; | 1299 | print_check_string_result = 0; |
| 1300 | traverse_intervals (STRING_INTERVALS (string), 0, | 1300 | traverse_intervals (string_get_intervals (string), 0, |
| 1301 | print_check_string_charset_prop, string); | 1301 | print_check_string_charset_prop, string); |
| 1302 | if (! (print_check_string_result & PRINT_STRING_UNSAFE_CHARSET_FOUND)) | 1302 | if (! (print_check_string_result & PRINT_STRING_UNSAFE_CHARSET_FOUND)) |
| 1303 | { | 1303 | { |
| @@ -1408,7 +1408,7 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag | |||
| 1408 | if (! EQ (Vprint_charset_text_property, Qt)) | 1408 | if (! EQ (Vprint_charset_text_property, Qt)) |
| 1409 | obj = print_prune_string_charset (obj); | 1409 | obj = print_prune_string_charset (obj); |
| 1410 | 1410 | ||
| 1411 | if (STRING_INTERVALS (obj)) | 1411 | if (string_get_intervals (obj)) |
| 1412 | { | 1412 | { |
| 1413 | PRINTCHAR ('#'); | 1413 | PRINTCHAR ('#'); |
| 1414 | PRINTCHAR ('('); | 1414 | PRINTCHAR ('('); |
| @@ -1499,9 +1499,9 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag | |||
| 1499 | } | 1499 | } |
| 1500 | PRINTCHAR ('\"'); | 1500 | PRINTCHAR ('\"'); |
| 1501 | 1501 | ||
| 1502 | if (STRING_INTERVALS (obj)) | 1502 | if (string_get_intervals (obj)) |
| 1503 | { | 1503 | { |
| 1504 | traverse_intervals (STRING_INTERVALS (obj), | 1504 | traverse_intervals (string_get_intervals (obj), |
| 1505 | 0, print_interval, printcharfun); | 1505 | 0, print_interval, printcharfun); |
| 1506 | PRINTCHAR (')'); | 1506 | PRINTCHAR (')'); |
| 1507 | } | 1507 | } |
diff --git a/src/textprop.c b/src/textprop.c index 1ec1ab11d2e..5366249be89 100644 --- a/src/textprop.c +++ b/src/textprop.c | |||
| @@ -161,7 +161,7 @@ validate_interval_range (Lisp_Object object, Lisp_Object *begin, Lisp_Object *en | |||
| 161 | XSETFASTINT (*begin, XFASTINT (*begin)); | 161 | XSETFASTINT (*begin, XFASTINT (*begin)); |
| 162 | if (begin != end) | 162 | if (begin != end) |
| 163 | XSETFASTINT (*end, XFASTINT (*end)); | 163 | XSETFASTINT (*end, XFASTINT (*end)); |
| 164 | i = STRING_INTERVALS (object); | 164 | i = string_get_intervals (object); |
| 165 | 165 | ||
| 166 | if (len == 0) | 166 | if (len == 0) |
| 167 | return NULL; | 167 | return NULL; |
| @@ -516,7 +516,7 @@ interval_of (ptrdiff_t position, Lisp_Object object) | |||
| 516 | { | 516 | { |
| 517 | beg = 0; | 517 | beg = 0; |
| 518 | end = SCHARS (object); | 518 | end = SCHARS (object); |
| 519 | i = STRING_INTERVALS (object); | 519 | i = string_get_intervals (object); |
| 520 | } | 520 | } |
| 521 | 521 | ||
| 522 | if (!(beg <= position && position <= end)) | 522 | if (!(beg <= position && position <= end)) |
| @@ -1274,10 +1274,10 @@ set_text_properties (Lisp_Object start, Lisp_Object end, Lisp_Object properties, | |||
| 1274 | && XFASTINT (start) == 0 | 1274 | && XFASTINT (start) == 0 |
| 1275 | && XFASTINT (end) == SCHARS (object)) | 1275 | && XFASTINT (end) == SCHARS (object)) |
| 1276 | { | 1276 | { |
| 1277 | if (! STRING_INTERVALS (object)) | 1277 | if (!string_get_intervals (object)) |
| 1278 | return Qnil; | 1278 | return Qnil; |
| 1279 | 1279 | ||
| 1280 | STRING_SET_INTERVALS (object, NULL); | 1280 | string_set_intervals (object, NULL); |
| 1281 | return Qt; | 1281 | return Qt; |
| 1282 | } | 1282 | } |
| 1283 | 1283 | ||