void lparss_c ( ConstSpiceChar * list,
ConstSpiceChar * delims,
SpiceCell * set )
Parse a list of items separated by multiple delimiters, placing the
resulting items into a set.
CHARACTER, LIST, PARSING, STRING
VARIABLE I/O DESCRIPTION
-------- --- --------------------------------------------------
list I List of items delimited by delims.
delims I Single characters which delimit items.
set O Set containing items in the list, left justified.
list is a list of items delimited by any one of the
characters in the string delims. Consecutive delimiters,
and delimiters at the beginning and end of the list, are
considered to delimit empty items. A blank or empty list
is considered to contain a single, empty item. Leading
and trailing blanks in list are ignored.
delims contains the individual characters which delimit
the items in the list. These may be any ASCII
characters, including blanks.
However, by definition, consecutive blanks are NOT
considered to be consecutive delimiters. Nor are
a blank and any other delimiter considered to be
set is a CSPICE set containing the items in the list,
left justified. Any item in the list too long to fit into
an element of items is truncated on the right. Empty
(null) or blank items in the input string are mapped to
empty strings on output.
set should be declared by the caller as a character
SPICECHAR_CELL ( set, NMAX, LENGTH );
where NMAX is the maximum number of strings the set is
expected to hold and LENGTH is the maximum length of
the strings, counting the terminating null.
The strings in set will be sorted in increasing order,
and duplicates will be removed. Trailing blanks are
ignored in string comparisons.
1) If the size of the set is not large enough to accomodate all of
the items in the set, the error SPICE(SETEXCESS) is signaled.
2) The error SPICE(NULLPOINTER) is signaled if either of the input
string pointers is null.
3) If the set does not have character type, the error
SPICE(TYPEMISMATCH) will be signaled..
4) An empty input string will result in a single, empty output
token. This case is not an error.
5) If the string length associated with set is too short to
be usable when constructing a character Fortran-style cell,
the error will be diagnosed by routines in the call tree
of this routine. See the routine enchar_ for details.
The following examples illustrate the operation of lparss_c.
list == " A number of words separated by spaces. "
delims == " ,."
Let set be declared with size 20.
Element 0 of set == " "
Element 1 of set == "A"
Element 2 of set == "by"
Element 3 of set == "number"
Element 4 of set == "of"
Element 5 of set == "separated"
Element 6 of set == "spaces"
Element 7 of set == "words"
list == " 1986-187// 13:15:12.184 "
delims == " ,/-:"
nmax == 20
Element 0 of set == ""
Element 1 of set == "12.184"
Element 2 of set == "13"
Element 3 of set == "15"
Element 4 of set == "187"
Element 5 of set == "1986"
1) String comparisons performed by this routine are Fortran-style:
trailing blanks in the input array or key value are ignored.
This gives consistent behavior with CSPICE code generated by
the f2c translator, as well as with the Fortran SPICE Toolkit.
Note that this behavior is not identical to that of the ANSI
C library functions strcmp and strncmp.
N.J. Bachman (JPL)
I.M. Underwood (JPL)
-CSPICE Version 1.0.0, 27-AUG-2002 (NJB) (IMU)
parse a list of items