Mercurial > hg > xemacs-beta
comparison src/fns.c @ 5097:4a6b680a9577
merge
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Thu, 04 Mar 2010 07:26:05 -0600 |
parents | 99f8ebc082d9 |
children | 7be849cb8828 |
comparison
equal
deleted
inserted
replaced
5096:e0587c615e8b | 5097:4a6b680a9577 |
---|---|
945 } | 945 } |
946 } | 946 } |
947 return arg; | 947 return arg; |
948 } | 948 } |
949 | 949 |
950 DEFUN ("substring", Fsubstring, 2, 3, 0, /* | |
951 Return the substring of STRING starting at START and ending before END. | |
952 END may be nil or omitted; then the substring runs to the end of STRING. | |
953 If START or END is negative, it counts from the end. | |
954 Relevant parts of the string-extent-data are copied to the new string. | |
955 */ | |
956 (string, start, end)) | |
957 { | |
958 Charcount ccstart, ccend; | |
959 Bytecount bstart, blen; | |
960 Lisp_Object val; | |
961 | |
962 CHECK_STRING (string); | |
963 CHECK_INT (start); | |
964 get_string_range_char (string, start, end, &ccstart, &ccend, | |
965 GB_HISTORICAL_STRING_BEHAVIOR); | |
966 bstart = string_index_char_to_byte (string, ccstart); | |
967 blen = string_offset_char_to_byte_len (string, bstart, ccend - ccstart); | |
968 val = make_string (XSTRING_DATA (string) + bstart, blen); | |
969 /* Copy any applicable extent information into the new string. */ | |
970 copy_string_extents (val, string, 0, bstart, blen); | |
971 return val; | |
972 } | |
973 | |
974 DEFUN ("subseq", Fsubseq, 2, 3, 0, /* | 950 DEFUN ("subseq", Fsubseq, 2, 3, 0, /* |
975 Return the subsequence of SEQUENCE starting at START and ending before END. | 951 Return the subsequence of SEQUENCE starting at START and ending before END. |
976 END may be omitted; then the subsequence runs to the end of SEQUENCE. | 952 END may be omitted; then the subsequence runs to the end of SEQUENCE. |
977 If START or END is negative, it counts from the end. | 953 If START or END is negative, it counts from the end. |
978 The returned subsequence is always of the same type as SEQUENCE. | 954 The returned subsequence is always of the same type as SEQUENCE. |
981 */ | 957 */ |
982 (sequence, start, end)) | 958 (sequence, start, end)) |
983 { | 959 { |
984 EMACS_INT len, s, e; | 960 EMACS_INT len, s, e; |
985 | 961 |
962 if (STRINGP (sequence)) | |
963 { | |
964 Charcount ccstart, ccend; | |
965 Bytecount bstart, blen; | |
966 Lisp_Object val; | |
967 | |
968 CHECK_INT (start); | |
969 get_string_range_char (sequence, start, end, &ccstart, &ccend, | |
970 GB_HISTORICAL_STRING_BEHAVIOR); | |
971 bstart = string_index_char_to_byte (sequence, ccstart); | |
972 blen = string_offset_char_to_byte_len (sequence, bstart, ccend - ccstart); | |
973 val = make_string (XSTRING_DATA (sequence) + bstart, blen); | |
974 /* Copy any applicable extent information into the new string. */ | |
975 copy_string_extents (val, sequence, 0, bstart, blen); | |
976 return val; | |
977 } | |
978 | |
986 CHECK_SEQUENCE (sequence); | 979 CHECK_SEQUENCE (sequence); |
987 | |
988 if (STRINGP (sequence)) | |
989 return Fsubstring (sequence, start, end); | |
990 | 980 |
991 len = XINT (Flength (sequence)); | 981 len = XINT (Flength (sequence)); |
992 | 982 |
993 CHECK_INT (start); | 983 CHECK_INT (start); |
994 s = XINT (start); | 984 s = XINT (start); |
4794 DEFSUBR (Fbvconcat); | 4784 DEFSUBR (Fbvconcat); |
4795 DEFSUBR (Fcopy_list); | 4785 DEFSUBR (Fcopy_list); |
4796 DEFSUBR (Fcopy_sequence); | 4786 DEFSUBR (Fcopy_sequence); |
4797 DEFSUBR (Fcopy_alist); | 4787 DEFSUBR (Fcopy_alist); |
4798 DEFSUBR (Fcopy_tree); | 4788 DEFSUBR (Fcopy_tree); |
4799 DEFSUBR (Fsubstring); | |
4800 DEFSUBR (Fsubseq); | 4789 DEFSUBR (Fsubseq); |
4801 DEFSUBR (Fnthcdr); | 4790 DEFSUBR (Fnthcdr); |
4802 DEFSUBR (Fnth); | 4791 DEFSUBR (Fnth); |
4803 DEFSUBR (Felt); | 4792 DEFSUBR (Felt); |
4804 DEFSUBR (Flast); | 4793 DEFSUBR (Flast); |