| iswhsp_c |
|
Table of contents
Procedureiswhsp_c ( Determine whether a string is white space ) SpiceBoolean iswhsp_c ( ConstSpiceChar * string ) AbstractReturn a boolean value indicating whether a string contains only white space characters. Required_ReadingNone. KeywordsFILES TEXT Brief_I/OVARIABLE I/O DESCRIPTION -------- --- -------------------------------------------------- string I String to be tested. The function returns the boolean value SPICETRUE if the string is empty or contains only white space characters; otherwise it returns the value SPICEFALSE. Detailed_Input
string is a character pointer designating a string to be
searched for non-white-space characters.
Detailed_Output
The function returns the boolean value SPICETRUE if the string
contains only white space characters; otherwise it returns the
value SPICEFALSE.
White space characters are those in the set
{ ' ', '\f', '\n', '\r', '\t', '\v' }
ParametersNone. Exceptions
1) If the input string pointer is null, the error SPICE(NULLPOINTER)
is signaled.
2) An empty string, that is a string with a null character
at index 0, is considered to be blank.
FilesNone. ParticularsThis routine provides a short cut for testing lines for the presence of non-blank characters; this is a test which is performed frequently in CSPICE. Examples
The numerical results shown for this example may differ across
platforms. The results depend on the SPICE kernels used as
input, the compiler and supporting libraries, and the machine
specific arithmetic implementation.
1) Read a text file; print the non-blank lines.
Use the meta-kernel shown below as example of text file to
read.
KPL/MK
File name: iswhsp_ex1.tm
This meta-kernel is intended to support operation of SPICE
example programs.
This file contains only free formatted text (no data)
as it is used in the iswhsp_c example as a plain text
file, but it could also contain data.
...
End of meta-kernel
Example code begins here.
/.
Program iswhsp_ex1
./
#include <stdio.h>
#include "SpiceUsr.h"
int main()
{
/.
Local parameters.
./
#define MAXLEN 81
/.
Local variables.
./
SpiceBoolean eof;
SpiceChar line [MAXLEN];
eof = SPICEFALSE;
while ( !eof )
{
rdtext_c ( "iswhsp_ex1.tm", MAXLEN, line, &eof );
if ( !iswhsp_c(line) )
{
printf ( "%s\n", line );
}
}
return ( 0 );
}
When this program was executed on a Mac/Intel/cc/64-bit
platform, the output was:
KPL/MK
File name: iswhsp_ex1.tm
This meta-kernel is intended to support operation of SPICE
example programs.
This file contains only free formatted text (no data)
as it is used in the iswhsp_c example as a plain text
file, but it could also contain data.
...
End of meta-kernel
RestrictionsNone. Literature_References
[1] "American National Standard for Programming Languages -- C,"
Section 7.3.1.9., p.104, American National Standards Institute,
1990.
Author_and_InstitutionN.J. Bachman (JPL) J. Diaz del Rio (ODC Space) Version
-CSPICE Version 1.1.1, 10-AUG-2021 (JDR)
Edited the -Examples section to comply with NAIF standard.
Replaced non-existing "txtopr_c" and "readln_c" calls by
equivalent "rdtext_c" in the code example. Added example's
solution and sample input text file.
-CSPICE Version 1.1.0, 27-AUG-1999 (NJB)
Now checks for null input string.
-CSPICE Version 1.0.0, 24-FEB-1999 (NJB)
Arguments passed to isspace are now cast to unsigned char to
suppress compilation warnings on some systems.
-CSPICE Version 1.0.0, 08-FEB-1998 (NJB)
Index_Entriesread a non-blank line from a text file |
Fri Dec 31 18:41:08 2021