cstrings.occ
This suite of routines supports c-like nul-terminated strings.
Fixed length arrays of bytes are used.
The general approach is to allow strings to overflow without
causing error.
FUNCTION isSpace
BOOL FUNCTION isSpace (VAL BYTE ch)
-
Tests whether ch is whitespace.
FUNCTION isNotSpace
BOOL FUNCTION isNotSpace (VAL BYTE ch)
-
Tests whether ch is not whitespace.
FUNCTION charEqAny
BOOL FUNCTION charEqAny (VAL BYTE a, b)
-
Returns TRUE if a=b, irrespective of case.
FUNCTION charToUpper
BYTE FUNCTION charToUpper (VAL BYTE c)
-
Convert a text character to uppercase.
FUNCTION charToLower
BYTE FUNCTION charToLower (VAL BYTE c)
-
Convert a text character to lowercase.
FUNCTION strLen
INT FUNCTION strLen (VAL []BYTE c.string)
-
Determine the length of c.string.
FUNCTION strEq
BOOL FUNCTION strEq (VAL []BYTE st1, st2)
-
Determine whether two c-strings are equal, matching upper/lowercase.
FUNCTION strEqAny
BOOL FUNCTION strEqAny (VAL []BYTE st1, st2)
-
As strEq, but case-insensitive.
FUNCTION strLocate
INT FUNCTION strLocate (VAL []BYTE x, test)
-
Locate position of test string within x.
Returns -1 if not found.
FUNCTION strLocateAny
INT FUNCTION strLocateAny (VAL []BYTE x, test)
-
As strLocate, but case-insensitive.
PROC strCpy
PROC strCpy ([]BYTE c.string, VAL []BYTE value)
PROC strCat
PROC strCat ([]BYTE c.string, VAL []BYTE value)
-
Concatentate value at the end of c.string.
PROC strChop
PROC strChop ([]BYTE left, right, VAL []BYTE s, VAL BYTE cut)
-
Finds the first byte 'cut' in 's'. Everything before it is put in
'left'. Everything following it is put in 'right'. The byte 'cut'
is not returned in either string. If 'cut' is not found, 'left' is
a copy of 's' and 'right' is empty.
PROC strChop2
PROC strChop2 ([]BYTE inside, VAL []BYTE s, VAL BYTE cut1, cut2)
-
Returns all the text between first occurence of cut1 and first
occurence of cut2. cut1 and cut2 are not included in the string.
If cut1 is not found, inside is returned empty. If cut2 is not
found, inside is returned with the right-hand part of the string.
PROC strSubstitute
PROC strSubstitute ([]BYTE s, VAL []BYTE search, replace)
PROC strToUpper
PROC strToUpper ([]BYTE string)
-
Convert every text character to uppercase.
PROC strToLower
PROC strToLower ([]BYTE string)
-
Convert every text character to lowercase.
PROC strCpyWords
PROC strCpyWords ([]BYTE word, VAL []BYTE string, VAL INT from, for)
-
For a string composed of n words separated by spaces (numbered
0 to n-1), strCpyWords copies from the i'th word into 'word'
for 'for' words.
If 'from' is greater than n, 'word' is returned empty.
PROC strSplit
PROC strSplit ([]BYTE word, VAL []BYTE string, VAL INT i, VAL BYTE split)
-
For a string composed of n words separated by 'split' characters (numbered
0 to n-1), strSplit copies the i'th word into 'word'
Generated by occam2html.