ANSI-compatible string manipulation routines
short cmpstri (const unsigned char *s1, const unsigned char *s2); |
Performs case-insensitive string comparison.
cmpstri acts like strcmp, but the comparison is case-insensitive. More precisely, it internally converts all uppercase characters to lowercase (unlike stricmp, which converts all lowercase characters to uppercase).
char *strcat (char *dest, const char *src); |
Appends src to dest.
strcat appends a copy of src to the end of dest, overwriting
the null character terminating the string pointed to by dest.
The length of the resulting
string is strlen(dest) + strlen(src)
. strcat returns a pointer to the
concatenated strings (this is dest, in fact).
Note: This routine assumes that dest
points to a buffer large enough to hold the concatenated string.
char *strchr (const char *str, short c); |
Finds c in str.
strchr scans a string in the forward direction, looking for a specific character. strchr finds the first occurrence of the character c in the string str. The null-terminator is considered to be part of the string, so that, for example,
strchr (s, 0)
returns a pointer to the terminating null character of the string s. Returns a pointer to the first occurrence of the character c in str. If c does not occur in str, strchr returns NULL.
short strcmp (const unsigned char *s1, const unsigned char *s2); |
Compares one string to another.
strcmp performs an unsigned comparison of s1 to s2. It starts with the first character in each string and continues with subsequent characters until the corresponding characters differ or until the end of the strings is reached. strcmp returns a value that is
< 0 if s1 is less than s2
== 0 if s1 is the same as s2
> 0 if s1 is greater than s2
More precisely, if the strings differ, the value of the first nonmatching character in s2
subtracted from the corresponding character in s1 is returned.
Note: This routine is declared as "short" although the ANSI standard proposes "long". This is important,
because TIOS the strncmp routine puts garbage in the higher half of the d0 register.
See also: strncmp, cmpstri, stricmp
char *strcpy (char *dest, const char *src); |
Copies string src to dest.
strcpy copies string src to dest, stopping after the terminating null
character has been moved. Returns dest.
Note: If the objects pointed to by src and dest overlap in memory, the
behavior is undefined. strcpy assumes that src points to a buffer large enough to
hold dest.
unsigned long strcspn (const char *s1, const char *s2); |
Scans a string.
strcspn returns the length of the initial segment of string s1 that consists entirely of characters not from string s2. If string s1 contains no characters from string s2, strcspn returns the length of string s1.
char *strerror (short err_no); |
Gives an error message string.
strerror returns a pointer to string which contains text of the system error message
err_no. Note that this is not a TI-Basic error message, but a low level
error message. Here is a complete table of such messages:
0 | no error |
1 | no such file entry |
2 | I/O error |
3 | not a serial device |
4 | out of memory |
5 | permission denied |
6 | block device required |
7 | no such device |
8 | invalid argument |
9 | file table is full |
10 | device directory is full |
11 | no space left on device |
12 | no more allocation blocks |
13 | no more data blocks on device |
14 | file is open |
15 | no RAM space configured |
16 | no heap space configured |
17 | seek can't extend read only file |
18 | bad file descriptor - file not open |
19 | invalid signal number |
20 | argument out of range |
21 | result out of range |
short stricmp (const unsigned char *s1, const unsigned char *s1); |
Performs case-insensitive string comparison.
stricmp acts like strcmp, but the comparison is
case-insensitive. More precisely, it internally converts all lowercase
characters to uppercase (unlike cmpstri, which
converts all uppercase characters to lowercase).
Note: This function is buggy in the AMS versions 2.00 through 2.03: If
s1 contains characters above 127 (i.e. extended/international
characters), and these characters are really needed for the comparison, it
always returns a negative value. So, if you really need to use this function,
make sure that you never call it with such characters in s1.
unsigned long strlen (const char *str); |
Calculates length of a string.
strlen calculates the length of str. Returns the number of characters in str, not counting the terminating null character.
char *strncat (char *dest, const char *src, unsigned long maxlen); |
Appends at most maxlen characters of src to dest.
strncat copies at most maxlen characters of src to the end of dest and then
appends a null character. The null character terminating src is
overwritten by the first character in dest. The maximum length of the resulting string is
strlen(dest) + maxlen. strncat returns dest.
Note: This routine assumes that src
points to a buffer large enough to hold the concatenated string.
Since strncat appends a null character to the result, it may add maxlen+1
characters to the string.
short strncmp (const unsigned char *s1, const unsigned char *s2, unsigned long maxlen); |
Compares at most maxlen characters of one string to another.
strncmp makes the same unsigned comparison as strcmp, but looks at no more than maxlen characters. It starts with the first character in each string and continues with subsequent characters until the corresponding characters differ or until it has examined maxlen characters. strncmp returns an int value based on the result of comparing s1 (or part of it) to s2 (or part of it):
< 0 if s1 is less than s2
== 0 if s1 is the same as s2
> 0 if s1 is greater than s2
More precisely, if the strings differ, the value of the first nonmatching character in s2
subtracted from the corresponding character in s1 is returned. The
subtraction casts the input strings to unsigned chars so that the characters
in the range 128..255 are considered above the characters in the range 0..127.
Note: This routine is declared as "short" although the ANSI standard proposes "long". This is important,
because TIOS the strncmp routine puts garbage in the higher half of the d0 register.
See also: strcmp
char *strncpy (char *dest, const char *src, unsigned long maxlen); |
Copies at most maxlen characters of src to dest.
strncpy copies up to maxlen characters from src into dest, truncating or
null-padding dest. The target string, dest, might not be null-terminated if
the length of src is maxlen or more. Returns dest.
Note: If the objects pointed to by src and dest overlap in memory, the
behavior is undefined. strcpy assumes that src points to a buffer large enough to
hold maxlen characters.
char *strpbrk (const char *s1, const char *s2); |
Scans one string for the first occurrence of any character that's in a second string.
strpbrk scans a string, s1, for the first occurrence of any character appearing in s2. strpbrk returns a pointer to the first occurrence of any of the characters in s2. If none of the s2 characters occurs in s1, it returns NULL.
char *strrchr (const char *str, short c); |
Finds the last occurrence of c in str.
strrchr scans a string in the reverse direction, looking for a specific character. strrchr finds the last occurrence of the character c in the string str. The null-terminator is considered to be part of the string. strrchr returns a pointer to the last occurrence of the character c. If c does not occur in str, strrchr returns NULL.
unsigned long strspn (const char *s1, const char *s2); |
Scans a string for a segment that is a subset of a set of characters.
strspn finds the initial segment of string s1 that consists entirely of characters from string s2. Returns the length of the initial segment of s1 that consists of characters entirely from s2. If s1 contains no characters from s2, NULL is returned.
char *strstr (const char *str, const char *substr); |
Finds the first occurrence of a substring in another string.
strstr scans str for the first occurrence of the substring substr. strstr returns a pointer to the element in str where substr begins (points to substr in str). If substr does not occur in str, strstr returns NULL.
char *strtok (char *s1, const char *s2); |
Scans s1 for the first token not contained in s2.
strtok considers the string s1 to consist of a sequence of zero or more text tokens, separated by spans of one or more characters from the separator string s2. The first call to strtok returns a pointer to the first character of the first token in s1 and writes a null character into s1 immediately following the returned token. Subsequent calls with NULL for the first argument will work through the string s1 in this way, until no tokens remain. The separator string, s2, can be different from call to call. strtok returns a pointer to the token found in s1. A null pointer is returned when there are no more tokens.