commit: Add #'substring-no-properties, omitting any extent data.

Aidan Kehoe kehoea at parhasard.net
Tue Jun 1 15:50:58 EDT 2010


changeset:   5224:35c2b7e9c03f
tag:         tip
user:        Aidan Kehoe <kehoea at parhasard.net>
date:        Tue Jun 01 20:32:41 2010 +0100
files:       src/ChangeLog src/fns.c
description:
Add #'substring-no-properties, omitting any extent data.

2010-06-01  Aidan Kehoe  <kehoea at parhasard.net>

	* fns.c (Fsubstring_no_properties):
	Add this function, API taken from GNU, though ours drops all
	extent data, not just properties.


diff -r acc4a6c9f5f9 -r 35c2b7e9c03f src/ChangeLog
--- a/src/ChangeLog	Tue Jun 01 20:31:11 2010 +0100
+++ b/src/ChangeLog	Tue Jun 01 20:32:41 2010 +0100
@@ -1,3 +1,9 @@
+2010-06-01  Aidan Kehoe  <kehoea at parhasard.net>
+
+	* fns.c (Fsubstring_no_properties):
+	Add this function, API taken from GNU, though ours drops all
+	extent data, not just properties.
+
 2010-06-01  Aidan Kehoe  <kehoea at parhasard.net>
 
 	* glyphs.c (syms_of_glyphs):
diff -r acc4a6c9f5f9 -r 35c2b7e9c03f src/fns.c
--- a/src/fns.c	Tue Jun 01 20:31:11 2010 +0100
+++ b/src/fns.c	Tue Jun 01 20:32:41 2010 +0100
@@ -992,6 +992,9 @@
 The returned subsequence is always of the same type as SEQUENCE.
 If SEQUENCE is a string, relevant parts of the string-extent-data
 are copied to the new string.
+
+See also `substring-no-properties', which only operates on strings, and does
+not copy extent data.
 */
        (sequence, start, end))
 {
@@ -1078,6 +1081,28 @@
                    error */
       return Qnil;
     }
+}
+
+DEFUN ("substring-no-properties", Fsubstring_no_properties, 1, 3, 0, /* 
+Return a substring of STRING, without copying the extents.
+END may be nil or omitted; then the substring runs to the end of STRING.
+If START or END is negative, it counts from the end.
+
+With one argument, copy STRING without its properties.
+*/
+       (string, start, end))
+{
+  Charcount ccstart, ccend;
+  Bytecount bstart, blen;
+  Lisp_Object val;
+
+  get_string_range_char (string, start, end, &ccstart, &ccend,
+                         GB_HISTORICAL_STRING_BEHAVIOR);
+  bstart = string_index_char_to_byte (string, ccstart);
+  blen = string_offset_char_to_byte_len (string, bstart, ccend - ccstart);
+  val = make_string (XSTRING_DATA (string) + bstart, blen);
+
+  return val;
 }
 
 /* Split STRING into a list of substrings.  The substrings are the
@@ -5609,6 +5634,7 @@
   DEFSUBR (Fbase64_decode_region);
   DEFSUBR (Fbase64_decode_string);
 
+  DEFSUBR (Fsubstring_no_properties);
   DEFSUBR (Fsplit_string_by_char);
   DEFSUBR (Fsplit_path);	/* #### */
 }



More information about the XEmacs-Patches mailing list