CRE Programmer's Guide

String and Memory Block Functions
Common Run-Time Environment (CRE) Programmer’s Guide528146-004
8-27
Strspn
Strspn
The Strspn functions scan a string until they find a character in the string that does not
appear in a second string.
str
is a pointer to the string to scan.
span_chars
is a pointer to the string containing the characters to scan for in str.
Return Value
The Strspn functions return the number of bytes scanned at the beginning of str
before a character is encountered that is not in
span_chars. If all characters in str
appear in
span_chars, the length of str is returned.
Considerations
Both str and stop_chars must be terminated by a zero (null) byte to stop the scan.
Example
INT count;
STRING .s[0:100] := ["An example: how to use RTL_STRSPN",0];
STRING .tar[0:100]:= ["ABCDEFGHIJKLMNOPQRSTUVWXYZ" &
"abcdefghijklmnopqrstuvwxyz",0];
count := RTL_Strspn_(s, tar); ! count gets 10
Strstr
The Strstr functions determine whether one string is a substring of a second string.
INT PROC RTL_Strspn_( str, span_chars );
STRING .str; ! in
STRING .span_chars; ! in TNS only
INT(32) PROC RTL_StrspnX_( str, span_chars );
STRING .EXT str; ! in
STRING .EXT span_chars; ! in TNS only
INT PROC RTL_Strstr_( str, substr );
STRING .str; ! in
STRING .substr; ! in TNS only
INT(32) PROC RTL_StrstrX_( str, substr );
STRING .EXT str; ! in
STRING .EXT substr; ! in TNS only