declare smobs in alloc.c
[bpt/emacs.git] / doc / lispref / strings.texi
index 3401150..e6b00f0 100644 (file)
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
-@c Copyright (C) 1990-1995, 1998-1999, 2001-2013 Free Software
+@c Copyright (C) 1990-1995, 1998-1999, 2001-2014 Free Software
 @c Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @node Strings and Characters
@@ -48,13 +48,13 @@ Vectors}).  Unlike in C, Emacs Lisp strings are @emph{not} terminated
 by a distinguished character code.
 
   Since strings are arrays, and therefore sequences as well, you can
-operate on them with the general array and sequence functions
-documented in @ref{Sequences Arrays Vectors}.  For example, you can
-access or change individual characters in a string using the functions
-@code{aref} and @code{aset} (@pxref{Array Functions}).  However, note
-that @code{length} should @emph{not} be used for computing the width
-of a string on display; use @code{string-width} (@pxref{Width})
-instead.
+operate on them with the general array and sequence functions documented
+in @ref{Sequences Arrays Vectors}.  For example, you can access or
+change individual characters in a string using the functions @code{aref}
+and @code{aset} (@pxref{Array Functions}).  However, note that
+@code{length} should @emph{not} be used for computing the width of a
+string on display; use @code{string-width} (@pxref{Size of Displayed
+Text}) instead.
 
   There are two text representations for non-@acronym{ASCII}
 characters in Emacs strings (and in buffers): unibyte and multibyte.
@@ -268,7 +268,7 @@ string to be used as a shell command, see @ref{Shell Arguments,
 combine-and-quote-strings}.
 @end defun
 
-@defun split-string string &optional separators omit-nulls
+@defun split-string string &optional separators omit-nulls trim
 This function splits @var{string} into substrings based on the regular
 expression @var{separators} (@pxref{Regular Expressions}).  Each match
 for @var{separators} defines a splitting point; the substrings between
@@ -350,6 +350,11 @@ practice:
      @result{} ("o" "o" "o")
 @end example
 
+If the optional argument @var{trim} is non-@code{nil}, it should be a
+regular expression to match text to trim from the beginning and end of
+each substring.  If trimming makes the substring empty, it is treated
+as null.
+
 If you need to split a string into a list of individual command-line
 arguments suitable for @code{call-process} or @code{start-process},
 see @ref{Shell Arguments, split-string-and-unquote}.
@@ -418,8 +423,10 @@ the symbol names are used.  Case is always significant, regardless of
 
 This function is equivalent to @code{equal} for comparing two strings
 (@pxref{Equality Predicates}).  In particular, the text properties of
-the two strings are ignored.  But if either argument is not a string
-or symbol, an error is signaled.
+the two strings are ignored; use @code{equal-including-properties} if
+you need to distinguish between strings that differ only in their text
+properties.  However, unlike @code{equal}, if either argument is not a
+string or symbol, @code{string=} signals an error.
 
 @example
 (string= "abc" "abc")
@@ -516,6 +523,13 @@ the optional argument @var{ignore-case} is non-@code{nil}, the
 comparison ignores case differences.
 @end defun
 
+@defun string-suffix-p suffix string &optional ignore-case
+This function returns non-@code{nil} if @var{suffix} is a suffix of
+@var{string}; i.e., if @var{string} ends with @var{suffix}.  If the
+optional argument @var{ignore-case} is non-@code{nil}, the comparison
+ignores case differences.
+@end defun
+
 @defun compare-strings string1 start1 end1 string2 start2 end2 &optional ignore-case
 This function compares a specified part of @var{string1} with a
 specified part of @var{string2}.  The specified part of @var{string1}
@@ -581,9 +595,8 @@ are used primarily for making help messages.
 @cindex integer to string
 @cindex integer to decimal
 This function returns a string consisting of the printed base-ten
-representation of @var{number}, which may be an integer or a floating
-point number.  The returned value starts with a minus sign if the argument is
-negative.
+representation of @var{number}.  The returned value starts with a
+minus sign if the argument is negative.
 
 @example
 (number-to-string 256)
@@ -607,20 +620,18 @@ See also the function @code{format} in @ref{Formatting Strings}.
 This function returns the numeric value of the characters in
 @var{string}.  If @var{base} is non-@code{nil}, it must be an integer
 between 2 and 16 (inclusive), and integers are converted in that base.
-If @var{base} is @code{nil}, then base ten is used.  Floating point
+If @var{base} is @code{nil}, then base ten is used.  Floating-point
 conversion only works in base ten; we have not implemented other
-radices for floating point numbers, because that would be much more
+radices for floating-point numbers, because that would be much more
 work and does not seem useful.  If @var{string} looks like an integer
 but its value is too large to fit into a Lisp integer,
-@code{string-to-number} returns a floating point result.
+@code{string-to-number} returns a floating-point result.
 
 The parsing skips spaces and tabs at the beginning of @var{string},
 then reads as much of @var{string} as it can interpret as a number in
 the given base.  (On some systems it ignores other whitespace at the
-beginning, not just spaces and tabs.)  If the first character after
-the ignored whitespace is neither a digit in the given base, nor a
-plus or minus sign, nor the leading dot of a floating point number,
-this function returns 0.
+beginning, not just spaces and tabs.)  If @var{string} cannot be
+interpreted as a number, this function returns 0.
 
 @example
 (string-to-number "256")
@@ -777,15 +788,15 @@ integer.  @samp{%x} uses lower case and @samp{%X} uses upper case.
 Replace the specification with the character which is the value given.
 
 @item %e
-Replace the specification with the exponential notation for a floating
-point number.
+Replace the specification with the exponential notation for a
+floating-point number.
 
 @item %f
-Replace the specification with the decimal-point notation for a floating
-point number.
+Replace the specification with the decimal-point notation for a
+floating-point number.
 
 @item %g
-Replace the specification with notation for a floating point number,
+Replace the specification with notation for a floating-point number,
 using either exponential notation or decimal-point notation, whichever
 is shorter.