Mercurial > hg > xemacs-beta
comparison src/fns.c @ 5224:35c2b7e9c03f
Add #'substring-no-properties, omitting any extent data.
2010-06-01 Aidan Kehoe <kehoea@parhasard.net>
* fns.c (Fsubstring_no_properties):
Add this function, API taken from GNU, though ours drops all
extent data, not just properties.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Tue, 01 Jun 2010 20:32:41 +0100 |
parents | 71ee43b8a74d |
children | fbd1485af104 |
comparison
equal
deleted
inserted
replaced
5223:acc4a6c9f5f9 | 5224:35c2b7e9c03f |
---|---|
990 END may be omitted; then the subsequence runs to the end of SEQUENCE. | 990 END may be omitted; then the subsequence runs to the end of SEQUENCE. |
991 If START or END is negative, it counts from the end. | 991 If START or END is negative, it counts from the end. |
992 The returned subsequence is always of the same type as SEQUENCE. | 992 The returned subsequence is always of the same type as SEQUENCE. |
993 If SEQUENCE is a string, relevant parts of the string-extent-data | 993 If SEQUENCE is a string, relevant parts of the string-extent-data |
994 are copied to the new string. | 994 are copied to the new string. |
995 | |
996 See also `substring-no-properties', which only operates on strings, and does | |
997 not copy extent data. | |
995 */ | 998 */ |
996 (sequence, start, end)) | 999 (sequence, start, end)) |
997 { | 1000 { |
998 EMACS_INT len, s, e; | 1001 EMACS_INT len, s, e; |
999 | 1002 |
1076 { | 1079 { |
1077 ABORT (); /* unreachable, since CHECK_SEQUENCE (sequence) did not | 1080 ABORT (); /* unreachable, since CHECK_SEQUENCE (sequence) did not |
1078 error */ | 1081 error */ |
1079 return Qnil; | 1082 return Qnil; |
1080 } | 1083 } |
1084 } | |
1085 | |
1086 DEFUN ("substring-no-properties", Fsubstring_no_properties, 1, 3, 0, /* | |
1087 Return a substring of STRING, without copying the extents. | |
1088 END may be nil or omitted; then the substring runs to the end of STRING. | |
1089 If START or END is negative, it counts from the end. | |
1090 | |
1091 With one argument, copy STRING without its properties. | |
1092 */ | |
1093 (string, start, end)) | |
1094 { | |
1095 Charcount ccstart, ccend; | |
1096 Bytecount bstart, blen; | |
1097 Lisp_Object val; | |
1098 | |
1099 get_string_range_char (string, start, end, &ccstart, &ccend, | |
1100 GB_HISTORICAL_STRING_BEHAVIOR); | |
1101 bstart = string_index_char_to_byte (string, ccstart); | |
1102 blen = string_offset_char_to_byte_len (string, bstart, ccend - ccstart); | |
1103 val = make_string (XSTRING_DATA (string) + bstart, blen); | |
1104 | |
1105 return val; | |
1081 } | 1106 } |
1082 | 1107 |
1083 /* Split STRING into a list of substrings. The substrings are the | 1108 /* Split STRING into a list of substrings. The substrings are the |
1084 parts of original STRING separated by SEPCHAR. | 1109 parts of original STRING separated by SEPCHAR. |
1085 | 1110 |
5607 DEFSUBR (Fbase64_encode_region); | 5632 DEFSUBR (Fbase64_encode_region); |
5608 DEFSUBR (Fbase64_encode_string); | 5633 DEFSUBR (Fbase64_encode_string); |
5609 DEFSUBR (Fbase64_decode_region); | 5634 DEFSUBR (Fbase64_decode_region); |
5610 DEFSUBR (Fbase64_decode_string); | 5635 DEFSUBR (Fbase64_decode_string); |
5611 | 5636 |
5637 DEFSUBR (Fsubstring_no_properties); | |
5612 DEFSUBR (Fsplit_string_by_char); | 5638 DEFSUBR (Fsplit_string_by_char); |
5613 DEFSUBR (Fsplit_path); /* #### */ | 5639 DEFSUBR (Fsplit_path); /* #### */ |
5614 } | 5640 } |
5615 | 5641 |
5616 void | 5642 void |