comparison src/fns.c @ 5089:99f8ebc082d9

Make #'substring an alias of #'subseq; give the latter the byte code. src/ChangeLog addition: 2010-03-03 Aidan Kehoe <kehoea@parhasard.net> * fns.c (Fsubstring): Removed. * search.c (Freplace_match): * minibuf.c (Ftry_completion): * lisp.h: * keymap.c (ensure_meta_prefix_char_keymapp): * dired.c (user_name_completion, file_name_completion): * console-x.c (x_canonicalize_console_connection): * bytecode.c (Bsubseq): * bytecode-ops.h (subseq): Move #'substring to Lisp, as an alias for #'subseq; change all C Fsubstring() calls to Fsubseq(), change the Bsubstring bytecode to Bsubseq. Motivation; not accepting vectors in #'substring is incompatible with GNU, and Common Lisp prefers #'subseq, it has no #'substring. lisp/ChangeLog addition: 2010-03-03 Aidan Kehoe <kehoea@parhasard.net> Move byte code #o117 to #'subseq, not #'substring. Make #'substring available as an alias for #'subseq in Lisp. * bytecomp.el (79, subseq, substring): * bytecomp.el (byte-compile-subseq): New. * update-elc.el (update-elc-chop-extension): Use #'subseq, not #'substring, the latter is not yet available. * subr.el (substring): New alias, to #'subseq. man/ChangeLog addition: 2010-03-03 Aidan Kehoe <kehoea@parhasard.net> * lispref/tips.texi (Comment Tips): * lispref/text.texi (Text Properties): * lispref/strings.texi (Creating Strings): * lispref/processes.texi (Input to Processes): * lispref/functions.texi (Argument List): * lispref/extents.texi (Duplicable Extents): Move examples that used substring to using subseq; in strings.texi, do not change the examples, but document that in this XEmacs, it is an alias for subseq, and that there may be some incompatibilities if you depend on that.
author Aidan Kehoe <kehoea@parhasard.net>
date Wed, 03 Mar 2010 18:40:12 +0000
parents c3d372419e09
children 7be849cb8828
comparison
equal deleted inserted replaced
5088:207dad9e74f7 5089:99f8ebc082d9
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);